Skip to content

Instantly share code, notes, and snippets.

@aydinnyunus
Created March 10, 2025 19:36
Show Gist options
  • Save aydinnyunus/4d71e7d9a433f3afc658724b903f4d23 to your computer and use it in GitHub Desktop.
Save aydinnyunus/4d71e7d9a433f3afc658724b903f4d23 to your computer and use it in GitHub Desktop.
CVE-2024-28607

Vulnerability Report: Bypass in isPrivate() Function

CVE-2024-28607

Summary: An issue in the isPrivate() function of the NPM ip-utils package (version 2.4.0 and before) allows an attacker to bypass private IP detection, potentially leading to security risks such as unauthorized access, SSRF, or information leakage.


Affected Function:

Source Code:

function isPrivate (ipaddress: string): Boolean {
  return /^(::f{4}:)?10\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i
      .test(ipaddress) ||
    /^(::f{4}:)?192\.168\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(ipaddress) ||
    /^(::f{4}:)?172\.(1[6-9]|2\d|30|31)\.([0-9]{1,3})\.([0-9]{1,3})$/i
      .test(ipaddress) ||
    /^(::f{4}:)?127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(ipaddress) ||
    /^(::f{4}:)?169\.254\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(ipaddress) ||
    /^f[cd][0-9a-f]{2}:/i.test(ipaddress) ||
    /^fe80:/i.test(ipaddress) ||
    /^::1$/.test(ipaddress) ||
    /^::$/.test(ipaddress);
}

Bypasses Identified:

1. Non-Standard IPv4 Representation Bypass

Some non-standard notations bypass the private IP detection:

  • isPrivate("0x7f.1") → Expected true, but returns false (127.0.0.1 in hexadecimal notation)
  • isPrivate("127.1") → Expected true, but returns false (shorthand for 127.0.0.1)

2. Octal Representation Bypass

  • isPrivate("0177.0.0.1") → Expected true, but returns false (0177 = 127 in octal notation)

Impact:

  • Security Risk: Attackers can use these bypass techniques to evade security controls, leading to potential Server-Side Request Forgery (SSRF), access control bypass, or information leakage.
  • Affected Applications: Any application relying on this function for private IP detection may be vulnerable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment