-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## What the file already knew\n\nIn Open-WebSearch 2.1.6, the SSRF defense lives in one function, `isPrivateOrLocalHostname(hostname: string)` in `src/utils/urlSafety.ts`. It is called from two upstream paths: from `validatePublicWebUrl`, the zod refiner installed on the `fetchWebContent` MCP tool's `url` argument, and from `assertPublicHttpUrl`, which `fetchWebContent` calls again at the request stage and at every final-URL stage after a redirect.\n\n```typescript\nexport function isPrivateOrLocalHostname(hostname: string): boolean {\n const host = hostname.trim().toLowerCase();\n if (!host) {\n return true;\n }\n\n if (host === 'localhost' || host.endsWith('.localhost')) {\n return true;\n }\n\n if (host === 'metadata.google.internal' || host === 'metadata.azure.internal') {\n return true;\n }\n\n const integerIp = parseIntegerIpv4Literal(host);\n if (integerIp && isPrivateIpv4(integerIp)) {\n return true;\n }\n\n if (isPrivateOrLocalIp(host)) {\n return true;\n }\n\n return false;\n}\n```\n\nRead the function's intent before reading its failure. The developer thought about a wide threat surface and wrote the matching block list:\n\n- `localhost` and any `.localhost` subdomain.\n- Two cloud metadata services by name, GCP's `metadata.google.internal` and Azure's `metadata.azure.internal`.\n- IPv4 integer literals, so `http://2130706433/` is normalized to `127.0.0.1` and rejected.\n- IPv4 dotted via `isPrivateIpv4`: `10/8`, `127/8`, `0/8`, `100.64/10` CGNAT, `169.254/16` (link-local and AWS IMDS), `172.16/12`, `192.168/16`, `198.18/15` benchmarking.\n- IPv6 via `isPrivateIpv6`: `::1` exact, `::` exact, `::ffff:*` IPv4-mapped (re-validated through `isPrivateIpv4`, so both `::ffff:7f00:1` and `::ffff:169.254.169.254` would be caught), `fc/fd` unique-local, and `fe[89ab]` link-local.\n\nThe pre-patch test file backs the inventory up. `127.0.0.1`, `10.0.0.5`, `192.168.1.1`, `169.254.169.254`, `::1`, `fd00::1` are all named in the host-check cases and asserted blocked. `http://169.254.169.254/latest/meta-data` is named in the URL-check cases and asserted blocked. The developer enumerated AWS IMDS by path, by IP, in writing. The CVE-2026-42260 bypass matrix is twelve URLs. None of them appear in the pre-patch tests. Every one of them sails through.\n\n## The first line is the bug\n\n`isPrivateOrLocalHostname` does several literal-name checks first, then dispatches IP classification through `isPrivateOrLocalIp`:\n\n```typescript\nfunction isPrivateOrLocalIp(ip: string): boolean {\n const version = isIP(ip);\n if (version === 4) {\n return isPrivateIpv4(ip);\n }\n if (version === 6) {\n return isPrivateIpv6(ip);\n }\n return false;\n}\n```\n\n`isIP` is `node:net`'s strict IP-literal parser. It returns 4 for a valid dotted IPv4, 6 for a valid IPv6 textual address, and 0 for anything else.\n\nThe hostname value passed into the function comes from upstream:\n\n```typescript\nexport function isPublicHttpUrl(url: string): boolean {\n try {\n const parsed = new URL(url);\n if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {\n return false;\n }\n return !isPrivateOrLocalHostname(parsed.hostname);\n } catch {\n return false;\n }\n}\n```\n\nWhat is `new URL('http://[::1]/').hostname`? The WHATWG URL spec, which Node implements, defines the hostname of a URL whose host is an IPv6 literal as the bracketed textual address. Node hands back `'[::1]'`. With the brackets.\n\n```\n> new URL('http://[::1]/').hostname\n'[::1]'\n> isIP('[::1]')\n0\n> isIP('::1')\n6\n```\n\nWhen the URL host is `[::1]`, the control flow inside `isPrivateOrLocalIp` resolves to:\n\n1. `version = isIP('[::1]') = 0`\n2. `version === 4` is false\n3. `version === 6` is false\n4. `return false`\n\n`isPrivateIpv6` is never called. The `::1` exact branch, the `::` exact branch, the `::ffff:*` IPv4-mapped branch, the `fc/fd` unique-local branch, the `fe[89ab]` link-local branch, none of that code runs for any URL whose host is given in bracketed IPv6 form. The block list is in the file. The control flow does not reach it.\n\nEvery URL in the CVE-2026-42260 bypass matrix shares this property:\n\n```\nhttp://[::1]/\nhttp://[::]/\nhttp://[::ffff:127.0.0.1]/\nhttp://[::ffff:7f00:1]/\nhttp://[0:0:0:0:0:ffff:127.0.0.1]/\nhttp://[0:0:0:0:0:0:0:1]/\nhttp://[::0:1]/\nhttp://[0:0::1]/\nhttp://[::ffff:a00:1]/\nhttp://[::ffff:c0a8:1]/\nhttp://[::ffff:a9fe:1]/\nhttp://[::ffff:169.254.169.254]/latest/meta-data\n```\n\nEach one is dispatched through `isIP`, returns 0, and the gate concludes \"public.\"\n\nNode's HTTP client does not have this problem. When `axios.get('http://[::ffff:169.254.169.254]/latest/meta-data')` reaches the socket layer, the address is parsed by the Node net stack, which understands IPv6 textual form and the IPv4-mapped representation. On a Linux host with the dual stack enabled, which is the default on every cloud Linux distribution, the kernel recognizes the `::ffff:` mapped form and dials the IPv4 endpoint `169.254.169.254`. AWS IMDSv1 replies. The response body is returned to the caller of the MCP tool.\n\nThe hostname-string deny-list and the connection's address parser are reading different things. The deny-list reads `[::ffff:169.254.169.254]`, decides it is not an IP, decides it is therefore not private, lets it through. The connection reads `::ffff:169.254.169.254`, recognizes it as the IPv4-mapped form, dials `169.254.169.254`. The two layers disagree about what the bytes said. Between the disagreement is the SSRF.\n\n## DNS is the second leg of the bypass\n\nThe advisory names a second class of bypass. `isPrivateOrLocalHostname` looks at the hostname literal. It does not resolve DNS. An attacker who controls `attacker.example` and points its A record at `127.0.0.1`, or its AAAA at `::1`, sails through every check the function performs: it is not `localhost`, it is not on the two-entry metadata-internal list, it does not parse as an integer IP, `isIP('attacker.example')` returns 0. The function returns `false`. The URL is \"public.\"\n\n`axios.get('http://attacker.example/')` triggers DNS resolution. The resolver returns the attacker-chosen private address. Node's HTTP client dials it. The MCP tool retrieves the loopback service and returns the body.\n\nThe pre-flight validator inspects the form before resolution. The connection performs the resolution. Both layers do their job correctly in isolation, and the boundary between them does not exist.\n\n## Who the caller is\n\nOpen-WebSearch is an MCP server. The HTTP transport binds `0.0.0.0:3000` by default; `MODE=both` (HTTP plus stdio) is the out-of-the-box configuration. The README states that no API keys or authentication are required. The Docker quick-start example runs with `ENABLE_CORS=true -e CORS_ORIGIN=*`.\n\nThe `fetchWebContent` tool's argument schema runs `isPublicHttpUrl` as a zod refinement. That refinement is the only gate between the caller and `axios.get` against an arbitrary URL whose response body becomes the tool's return value.\n\nThe intended caller is not a human attacker typing URLs. The intended caller is an LLM agent. The agent fetches a webpage on the operator's behalf: a search result link, a URL the operator pasted, a URL another tool produced. The webpage may contain prompt-injection content instructing the agent to fetch a follow-up URL.\n\nThe agent does not need to understand the bypass. It needs only to be persuaded to call:\n\n```\nfetchWebContent({ url: \"http://[::ffff:169.254.169.254]/latest/meta-data/iam/security-credentials/\" })\n```\n\nThe MCP server, sitting on the operator's cloud instance, performs the request from its own network position. The instance metadata service responds. The agent receives the response body, IAM role credentials included. The next prompt-injection step in the webpage tells the agent to forward those credentials to an attacker-controlled URL through, again, `fetchWebContent`.\n\nThis is non-blind SSRF, scoped to whatever the operator's network position can reach. The HTTP transport, the agent's prompt-injection susceptibility, and the missing bracket strip compose into \"the LLM exfiltrates the host's cloud credentials.\" Each component is held by a different party. None of the parties are individually wrong about anything they own.\n\n## The same disease, in a different organ\n\nThe pattern is [gate-before-canonicalize](/patterns/gate-before-canonicalize), applied to hostnames rather than paths. A security check inspects an input for a forbidden form. A downstream subsystem canonicalizes the same input, strips brackets, resolves DNS, unwraps the IPv4-mapped form to its IPv4 endpoint, into that forbidden form. The check sees the wrapped representation. The action sees the unwrapped one.\n\nThe closest sibling is [CVE-2026-42596 in Gotenberg](/posts/gotenberg-cve-2026-42596-patch-removed-the-default-protection), the same disease in Go. Gotenberg's default deny-list regex byte-matches against the URL host. `[::ffff:127.0.0.1]` does not appear in any character class of the regex; `net/netip.ParseAddr` unmaps it to `127.0.0.1` at dial time. The regex sees the wrapped form, the dial sees the unwrapped one. The same gap, in the same direction, on a different language stack.\n\nOpen-WebSearch's variant is sharper in one direction. Gotenberg's regex was never written to match the IPv4-mapped IPv6 form; the deny-list author did not enumerate that form. Open-WebSearch's `isPrivateIpv6` *was* written to match it, with explicit logic that strips the `::ffff:` prefix and feeds the trailing IPv4 through the existing IPv4 private-range check. The branch is in the source. It is unreachable because the dispatcher's first action is a strict IP parser that rejects the bracketed form the URL parser produced.\n\n[CVE-2025-41242 in Spring](/posts/spring-uridecode-ghost-bits-jetty-finishes), [CVE-2026-26336 in Alfresco](/posts/alfresco-share-blacklist-misses-the-semicolon), and [CVE-2026-42882 in s3-proxy](/posts/s3-proxy-cve-2026-42882-two-parses-one-bouncer) all cleave at the same joint. A defender's parse and an actor's parse disagreed about what the bytes said.\n\n## What the patch admits\n\nThe fix for CVE-2026-42260 in commit `8c35c6b` lands the bracket strip in two lines:\n\n```diff\n export function isPrivateOrLocalHostname(hostname: string): boolean {\n- const host = hostname.trim().toLowerCase();\n- if (!host) {\n- return true;\n- }\n-\n- if (host === 'localhost' || host.endsWith('.localhost')) {\n+ const raw = hostname.trim().toLowerCase();\n+ const host = raw.startsWith('[') && raw.endsWith(']') ? raw.slice(1, -1) : raw;\n+ if (!host || host === 'localhost' || host.endsWith('.localhost')) {\n return true;\n }\n```\n\nAfter the strip, the patch replaces the hand-rolled `isPrivateIpv6` and `isPrivateIpv4` with `ipaddr.js`'s `range()` classifier. `range()` returns `'unicast'` for public addresses and one of `'loopback'`, `'private'`, `'linkLocal'`, `'uniqueLocal'`, `'ipv4Mapped'`, `'reserved'`, `'multicast'`, `'broadcast'`, `'unspecified'` for not-public. The custom enumeration is replaced by a library enum that someone else maintains.\n\nThen comes the comment.\n\n```typescript\n// Fast-path only. The authoritative SSRF boundary is request-filtering-agent\n// in src/utils/httpRequest.ts, which re-validates at connect time.\nexport function isPrivateOrLocalHostname(hostname: string): boolean {\n```\n\nThe function that used to be the gate is now annotated as a fast-path. The new boundary is in `httpRequest.ts`. The same commit removes the standalone `directHttpsAgent` from that file entirely, replacing it with `RequestFilteringHttpAgent` and `RequestFilteringHttpsAgent` from the `request-filtering-agent` package. Every outbound axios request that is not going through a configured outbound proxy now routes through these filtering agents:\n\n```diff\n-import https from 'node:https';\n import { HttpsProxyAgent } from 'https-proxy-agent';\n+import {\n+ RequestFilteringHttpAgent,\n+ RequestFilteringHttpsAgent\n+} from 'request-filtering-agent';\n...\n- requestOptions.httpsAgent = getDirectHttpsAgent(allowInsecureTls);\n+ requestOptions.httpAgent = getFilteringHttpAgent();\n+ requestOptions.httpsAgent = getFilteringHttpsAgent(allowInsecureTls);\n```\n\nThe filtering agents hook the socket's `lookup` and `connect` callbacks. They see the resolved IP literal the socket is about to dial, after DNS, after IPv4-mapped unwrap, after every transform the kernel applies between hostname and packet. The boundary moved to the place where there is only one representation left.\n\nThe string-based `isPrivateOrLocalHostname` survives in the source, with its block list intact, now correctly described in a comment as a fast-path optimization rather than an enforcement layer. The patch does not delete the function. It demotes it.\n\n## The block list is not the lesson\n\nThe developer wrote a deny-list with every IPv6 form named, named cloud metadata services by hostname, named AWS IMDS by IP literal and by URL path, and shipped a test suite that asserted each named form was blocked. The deny-list is comprehensive against the forms the developer enumerated. The bug is not in the enumeration.\n\nThe bug is that a deny-list applied to a hostname string is applied to one of the many representations the address has. The kernel, the URL parser, the DNS resolver, and the IP-literal parser disagree about which representation they are reading. `new URL` keeps the brackets. `node:net.isIP` rejects the brackets. `axios.get` strips the brackets and dials the address inside them. The connection's parser is more permissive than the gate's parser, and the gap is the SSRF.\n\nThe structural fix is to put the check where there is only one representation left. The patch does that. It leaves the gate's parse in place, annotated, and adds the actor's parse as the new boundary. The same advisory that named twelve bracketed bypasses also names DNS rebinding; the connect-time check catches both with one mechanism.\n\nPoC and disclosure: [GHSA-v228-72c7-fx8j](https://github.com/Aas-ee/open-webSearch/security/advisories/GHSA-v228-72c7-fx8j). Patched in 2.1.7, commit [`8c35c6b`](https://github.com/Aas-ee/open-webSearch/commit/8c35c6bb5b7690ca2740eef135e74ebc43571614). Reported by Shmulik Cohen at Apiiro.","closing_line":"The pre-flight validator is still in the file. The comment above it now says it is not the boundary.","hook_md":"The pre-patch `src/utils/urlSafety.ts` in Open-WebSearch contains a defense-in-depth IPv6 deny list. It rejects `::1`, the unspecified address, the `fc/fd` unique-local block, the `fe[89ab]` link-local block, and the IPv4-mapped form `::ffff:*`, where the mapped IPv4 is fed back through a private-range check that already catches `169.254.169.254`. Every IPv6 form in the GHSA-v228-72c7-fx8j bypass matrix is named in the source. None of it is ever reached. CVE-2026-42260 is what happens when the function's first action is `isIP(hostname)`, the hostname came from `new URL('http://[::1]/').hostname`, and Node hands the string back with the brackets still attached.","post_id":351,"slug":"open-websearch-cve-2026-42260-block-list-never-reached","title":"CVE-2026-42260: Open-WebSearch Wrote The IPv6 Block List. The Control Flow Never Reaches It.","type":"initial","unreadable_sentence":"The block list is in the file. The control flow does not reach it."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCajmiTgAKCRDeZjl4jgkQ JiGDAP0V/+hD/kGqxDDrk6YAt/FKPUkHTZCLiK0uSfAtpFzEIAD/Xoe8ncmLPicC YAMLESECAOlGoHc7el8EOGdMu2dHtA0= =ret6 -----END PGP SIGNATURE-----