-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## The gate and its parser disagree on what an IPv4-mapped IPv6 looks like\n\nCVE-2026-43929 lands on ssrfcheck 1.3.0 and earlier. ssrfcheck's `parseURL` opens with `new URL(normalizeURLStr(input))`. WHATWG URL is what Node implements behind the global `URL`, and the spec has one rule for IPv4-mapped IPv6: when the host is an IPv6 literal containing a dotted-IPv4 tail, the parser converts the tail to two hex hextets before returning the host. That conversion is the canonicalization step the regex is supposed to look at.\n\n```js\n// src/parse-url.js\nfunction parseURL(input, autoPrependProtocol) {\n const RESULT_INVALID_URL = { validSchema: false };\n\n try {\n const url = new URL(normalizeURLStr(input));\n const ipcheck = trimBrackets(url.hostname);\n const ipVersion = isIP(ipcheck);\n const hostIsIp = !!ipVersion;\n // ...\n return Object.assign(url, {\n ip: hostIsIp ? ipcheck : null,\n validSchema: true,\n hasUnsafeChars,\n ipVersion,\n hostIsIp,\n });\n } catch {\n // ...\n }\n}\n```\n\nFor input `http://[::ffff:127.0.0.1]/`, the chain produces, verifiable in any Node REPL:\n\n```\n> new URL('http://[::ffff:127.0.0.1]/').hostname\n'[::ffff:7f00:1]'\n> new URL('http://[::ffff:169.254.169.254]/').hostname\n'[::ffff:a9fe:a9fe]'\n> new URL('http://[0:0:0:0:0:ffff:127.0.0.1]/').hostname\n'[::ffff:7f00:1]'\n```\n\nThe brackets come off in `trimBrackets`. `isIP('::ffff:7f00:1')` returns 6. The string `::ffff:7f00:1` is the only representation of that input the rest of the library will ever see.\n\nNow look at the regex chain `privIp6` ran against it for two years and four months.\n\n```js\n// src/is-private-ip.js (pre-patch, 1.3.0)\nfunction privIp6 (ip) {\n return /^::$/.test(ip) ||\n /^::1$/.test(ip) ||\n /^::f{4}:([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})$/.test(ip) ||\n /^::f{4}:0.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})$/.test(ip) ||\n /^64:ff9b::([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})$/.test(ip) ||\n /^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(ip) ||\n /^2001::([0-9a-fA-F]{0,4}):?(...truncated for brevity...)*/.test(ip) ||\n /^f[c-d]([0-9a-fA-F]{2,2}):/i.test(ip) ||\n /^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(ip) ||\n /^ff([0-9a-fA-F]{2,2}):/i.test(ip)\n}\n```\n\nThree of those regexes are reserved for IPv4-bearing IPv6 ranges: `::ffff:` (IPv4-mapped, RFC 4291), `::ffff:0.` (a typo with five capture groups for a thing that has four), and `64:ff9b::` (NAT64, RFC 6052). All three require literal dots inside the IPv6 host. All three test for a string the upstream `new URL()` will never have produced.\n\nThe rest of the regex chain (`100::`, `2001::`, `2001:db8::`, `2002::`, `fc/fd` ULAs, `fe80::` link-local, `ff00::` multicast) is written in hex prefix form. Those regexes match the WHATWG canonical form and work correctly. The dot-form regexes match nothing the pipeline can feed them.\n\n## The control flow that ships the bypass\n\n```js\n// src/index.js\nconst {\n ip, hostIsIp, ipVersion, hostname,\n /* ... */\n} = parseURL(input, options.autoPrependProtocol);\n\n// ...other validators omitted...\n\nif (hostIsIp && (options.noIP || isLoopbackAddr(ip) || isPrivateIP(ip, ipVersion))) {\n return false;\n}\n\nreturn true;\n```\n\nFor `http://[::ffff:127.0.0.1]/`:\n\n- `hostIsIp` is `true` (the host parsed as a v6 literal).\n- `isLoopbackAddr('::ffff:7f00:1')` checks `/^127\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}$/` and `/^::1$/`. Neither matches.\n- `isPrivateIP('::ffff:7f00:1', 6)` calls `privIp6`. None of the regexes match. Returns `false`.\n\n`isSSRFSafeURL` returns `true`. The application reads \"safe\" and dials the URL. Node's network stack resolves `[::ffff:127.0.0.1]` the way every operating system since RFC 4291 has resolved it: as IPv4 over the v6 syntax, connecting to `127.0.0.1`.\n\nRun the seven URLs the CVE-2026-43929 reporter filed against pre-patch ssrfcheck 1.3.0 in a Node REPL:\n\n```\nBYPASS -> http://[::ffff:127.0.0.1]/\nBYPASS -> http://[::ffff:169.254.169.254]/\nBYPASS -> http://[::ffff:192.168.1.1]/\nBYPASS -> http://[::ffff:10.0.0.1]/\nBYPASS -> http://[::ffff:172.16.0.1]/\nBYPASS -> http://[::ffff:7f00:1]/\nBYPASS -> http://[0:0:0:0:0:ffff:127.0.0.1]/\nBLOCKED -> http://127.0.0.1/\nBLOCKED -> http://[::1]/\n```\n\nThe second row, `169.254.169.254`, is the cloud-metadata address shared by AWS, GCP, and Azure. A backend running ssrfcheck against a user-supplied URL parameter, with no other defense in the chain, will return AWS IMDS credentials when asked. The library cleared the request as safe.\n\n## The diff describes a regex that was never going to work\n\nThe 1.4.0 fix replaces the entire `privIp6` regex chain with a `BlockList` check. The relevant lines:\n\n```js\n// src/is-private-ip.js (post-patch, 1.4.0)\nconst IPV4_BEARING_IPV6_BLOCKLIST = new BlockList();\nIPV4_BEARING_IPV6_BLOCKLIST.addSubnet('::ffff:0:0', 96, 'ipv6');\nIPV4_BEARING_IPV6_BLOCKLIST.addSubnet('::ffff:0:0:0', 96, 'ipv6');\nIPV4_BEARING_IPV6_BLOCKLIST.addSubnet('64:ff9b::', 96, 'ipv6');\nIPV4_BEARING_IPV6_BLOCKLIST.addSubnet('64:ff9b:1::', 48, 'ipv6');\nIPV4_BEARING_IPV6_BLOCKLIST.addSubnet('::', 96, 'ipv6');\n\nfunction privIp6 (ip) {\n const normalized = normalizeIPv6ForBlockList(ip);\n if (isIP(normalized) !== 6) return false;\n const embeddedIPv4 = ipv4FromIPv4BearingIPv6(normalized);\n return Boolean(\n (embeddedIPv4 && privIp4(embeddedIPv4)) ||\n DIRECT_PRIVATE_IPV6_BLOCKLIST.check(normalized, 'ipv6')\n );\n}\n```\n\n`BlockList` is the right primitive. It operates on the binary form of the address, the same regardless of textual representation. A `/96` mask over `::ffff:0:0` catches every IPv4-mapped IPv6 host the parser will produce, in hex or in any dotted-form survivor, because `BlockList` does not read the string. The check now runs at the representational level the parser actually emits.\n\nWhat the diff does not say out loud: the dot-form regexes the patch deletes had a runtime hit count of zero. The library shipped them, the test runner never exercised them through the public API, and no input the library could give them in production would have matched them. Removing them changed the runtime behavior by zero. The patch is not, in any input that reaches it, replacing a broken check with a working one. It is replacing an absent check with a present one.\n\nLook at the interim fix, commit `59e1475`, the first attempt on the same day the reporter filed:\n\n```diff\n+function ipv4FromMappedIPv6(ip) {\n+ const normalized = ip.toLowerCase();\n+ const match = normalized.match(/^::f{4}:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/);\n+ if (!match) return null;\n+ /* unpack high/low hextets back to dotted IPv4 */\n+}\n+\n function privIp6 (ip) {\n+ const mappedIPv4 = ipv4FromMappedIPv6(ip);\n+ if (mappedIPv4) return privIp4(mappedIPv4);\n+\n return /^::$/.test(ip) ||\n /^::1$/.test(ip) ||\n /^::f{4}:([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})$/.test(ip) ||\n /^::f{4}:0.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})$/.test(ip) ||\n // ...all the other dead regexes kept in place...\n```\n\nThe author wrote a new branch in hex form, placed it ahead of the regex chain, and left every dot-form regex below it. The dot-form regexes survived first contact with the fix. They survived because the author was patching the symptom, not the file. Three more commits later, on the way to 1.4.0, the entire chain was replaced. The dead regexes never matched a string on the way out the door.\n\nThe dot-form branch was, in the operational sense, a comment that compiles.\n\n## Pattern: Gate Before Canonicalize, mirrored\n\nssrfcheck is the eleventh exhibit on [Gate Before Canonicalize](/patterns/gate-before-canonicalize). The pattern in this catalog covers a security predicate that inspects the wrapped form of an input while the action below it consumes the unwrapped form. Most of the prior exhibits run the predicate before the canonicalization step. [Gotenberg's regex case-sensitively matches `^https?://` and `net/url.Parse` lowercases the scheme after](/posts/gotenberg-cve-2026-40280-named-fix-adds-the-bug). [Alfresco's path blacklist matches `..` and Tomcat resolves `..;` to the same parent reference](/posts/alfresco-share-blacklist-misses-the-semicolon). [Gotenberg again, where `[::ffff:127.0.0.1]` evades the deny-list regex and `net/netip.ParseAddr` unmaps it to the IPv4 the regex was supposed to block](/posts/gotenberg-cve-2026-42596-patch-removed-the-default-protection).\n\nssrfcheck runs the canonicalization step first. `new URL()` rewrites the input into the WHATWG canonical form, then the predicate sees the canonical form, then `privIp6` tests it with a regex written for what the user typed at the keyboard. Same disease, mirrored ordering. Where Gotenberg's structural fix would be to canonicalize before the regex runs, ssrfcheck's structural fix is to rewrite the predicate against the form the parser already produced. The 1.4.0 diff does that rewrite by switching the predicate from textual pattern match to binary `BlockList`.\n\nThe fact that this is the third exhibit this catalog has filed against a private-IP gate in a Node.js or Go HTTP client should be read in order. [EspoCRM's host check had no IPv4 parser and libcurl did](/posts/espocrm-cve-2026-33534-host-check-had-no-ipv4-parser): the strict PHP parser rejected `0177.0.0.1`; libcurl's `inet_aton` accepted it and dialed `127.0.0.1`. [Open-WebSearch wrote the IPv6 deny list and `isIP('[::1]')` made the dispatcher exit before reading it](/posts/open-websearch-cve-2026-42260-block-list-never-reached): the brackets stayed on, the dispatcher's first call returned 0, the v6 enforcement path was unreachable. ssrfcheck wrote the IPv6 deny list and the regex was for a form the parser strips: brackets came off, `isIP` returned 6, the dispatcher entered `privIp6`, and the regex did not match because the parser had already canonicalized away the substring the regex matched.\n\nThree different libraries, authored independently in two different languages, by three different maintainers, in two different release months. The pattern lives at the layer where developers think about IPv4-mapped IPv6 as a textual form (`::ffff:127.0.0.1`) and operating systems route it as a binary one (the loopback IPv4 underneath). Any gate that reads the address as a string and inspects it for human-typed substrings is going to lose to any parser that canonicalizes before the gate runs.\n\n## The quiet part\n\nThe library is named for the check. The check, for the most common SSRF bypass primitive in 2026, did not exist. Three regex lines in `src/is-private-ip.js` were written for a string format that the library's own URL parser, on the way in, rewrites away. Every test that exercised the function through `isSSRFSafeURL` reached the function with the post-canonical hex form. None of those tests reached the dot-form branch. The dot-form branch shipped from initial commit on December 18, 2023, and was deleted on April 26, 2026, without ever having matched a string the library could give it.\n\nThe reporter, [@hits313](https://github.com/hits313), filed the CVE-2026-43929 advisory in late April 2026. The first commit responding to the report was authored the same day. The dead code shipped for two years and four months between when the regex was first committed and when somebody asked what input it was supposed to receive.\n\nA library called `ssrfcheck` running a regex that matched no string the library could feed it is the kind of finding the genre records dryly. The patch is the admission. The 1.4.0 diff replaces a regex chain whose IPv4-bearing branches had a runtime hit count of zero with a `BlockList` chain that has a non-zero hit count. The runtime behavior of the new code is the runtime behavior the README always promised. The runtime behavior of the old code was advertising.\n\nPoC: [advisories/GHSA-j4rj-2jr5-m439](https://github.com/advisories/GHSA-j4rj-2jr5-m439)\n","closing_line":"The library named for the check shipped without making it.","hook_md":"ssrfcheck is a Node.js package whose product is one function. `isSSRFSafeURL(url)` returns `true` if the URL is safe to fetch, `false` if it would reach a private address. The README links the OWASP SSRF cheat sheet. The tagline reads \"checks IP of any range.\" CVE-2026-43929 is the finding that for the most common SSRF bypass primitive of 2026, IPv4-mapped IPv6 reaching cloud metadata, the check did not exist.\n\nThe mechanism is a regex in `src/is-private-ip.js` written to match the form `::ffff:127.0.0.1`. The library's own URL parser, before the regex runs, rewrites `[::ffff:127.0.0.1]` to `[::ffff:7f00:1]`. The regex required dots. The parser emitted hex. The two were never going to meet.\n\nThe regex has been in the file since the initial commit. December 18, 2023. Twenty-eight months.","post_id":372,"slug":"ssrfcheck-cve-2026-43929-dot-form-regex-the-parser-strips","title":"CVE-2026-43929: ssrfcheck's Private-IP Regex Was Written for a String Its Own URL Parser Strips","type":"initial","unreadable_sentence":"The dot-form branch was, in the operational sense, a comment that compiles."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCav5aKgAKCRDeZjl4jgkQ JnT0AP9Lp7aDm/4mDm+ArwSTdH/xIDGPCqFNAd4rVXW/SA8bfQEAln1rM8FVIDlV LghEJz/xA/YpoYgzMjcOTXOzMturvAc= =NSED -----END PGP SIGNATURE-----