-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## `validate_url` ran four layers. `requests` parsed the URL once more.\n\nCVE-2026-45400 is the SSRF bypass in Open WebUI's `validate_url` fixed in 0.9.5. Pre-patch (0.9.4), `backend/open_webui/retrieval/web/utils.py:67`:\n\n```python\ndef validate_url(url: Union[str, Sequence[str]]):\n if isinstance(url, str):\n if isinstance(validators.url(url), validators.ValidationError):\n raise ValueError(ERROR_MESSAGES.INVALID_URL)\n\n parsed_url = urllib.parse.urlparse(url)\n\n # Protocol validation - only allow http/https\n if parsed_url.scheme not in ['http', 'https']:\n raise ValueError(ERROR_MESSAGES.INVALID_URL)\n\n if WEB_FETCH_FILTER_LIST:\n if not is_string_allowed(url, WEB_FETCH_FILTER_LIST):\n raise ValueError(ERROR_MESSAGES.INVALID_URL)\n\n if not ENABLE_RAG_LOCAL_WEB_FETCH:\n parsed_url = urllib.parse.urlparse(url)\n ipv4_addresses, ipv6_addresses = resolve_hostname(parsed_url.hostname)\n # This is technically still vulnerable to DNS rebinding attacks,\n # as we don't control WebBaseLoader\n for ip in ipv4_addresses + ipv6_addresses:\n addr = ipaddress.ip_address(ip)\n if not addr.is_global:\n raise ValueError(ERROR_MESSAGES.INVALID_URL)\n return True\n```\n\nFour checks. None of them sloppy. A `validators`-library URL syntax check, a scheme allowlist, a `WEB_FETCH_FILTER_LIST` blocklist for operators who want to deny specific hosts, and the resolve-and-block layer that calls `socket.getaddrinfo` on the parsed hostname and refuses to fetch when any returned address fails the `ipaddress.ip_address(ip).is_global` predicate. The function was written by people who had read about SSRF. The standing comment above the resolve gate is its proof:\n\n```python\n# This is technically still vulnerable to DNS rebinding attacks,\n# as we don't control WebBaseLoader\n```\n\nThe team had thought about the gap between `validate_url` and the consuming loader. The gap they had thought about was temporal. They were watching the seam for an attacker who could change DNS answers between the resolution and the fetch. The seam turned out to admit a spatial attacker first.\n\nEvery caller of `validate_url` follows the same shape: validate the URL, then hand the original string to `requests.get` or `aiohttp.ClientSession.get`. `backend/open_webui/retrieval/utils.py:181`:\n\n```python\nvalidate_url(url)\n...\n# allow_redirects=False prevents redirect-based SSRF: validate_url() above is\n# called once on the originally-submitted URL...\n```\n\nThe originally-submitted URL is what `validate_url` checked. The originally-submitted URL is what `requests` reparses. They read the same bytes. They do not necessarily produce the same host.\n\n## The URL `http://127.0.0.1:6666\\@1.1.1.1` produced two different hosts\n\nThe PoC URL recorded in [GHSA-8w7q-q5jp-jvgx](https://github.com/advisories/GHSA-8w7q-q5jp-jvgx) is one line:\n\n```\nhttp://127.0.0.1:6666\\@1.1.1.1\n```\n\n`urllib.parse.urlparse` is, in practice, an RFC 3986 parser. RFC 3986's authority grammar is `userinfo \"@\" host [ \":\" port ]`. `@` is the userinfo-host delimiter. The userinfo character set is permissive and the parser does not recognise backslash as a delimiter. `urlparse` reads the netloc as `127.0.0.1:6666\\@1.1.1.1`, splits on `@`, and returns:\n\n```\nscheme = 'http'\nhostname = '1.1.1.1'\nport = None\npath = ''\n```\n\n`requests` and `aiohttp` use urllib3-style authority parsing, which follows WHATWG-aligned conventions for HTTP. The WHATWG URL Standard declares backslash equivalent to forward slash in `http`, `https`, `ws`, `wss`, and `ftp` URLs. The same byte string, parsed under those rules, normalises to:\n\n```\nhttp://127.0.0.1:6666/@1.1.1.1\n │── host:port ─│\n │── path ──│\n```\n\nHost: `127.0.0.1`. Port: `6666`. Path: `/@1.1.1.1`.\n\nThe patch commit message names the four characters the two parsers split on differently: backslash, tab, CR, LF. None of them is a legal byte inside an unescaped URL; each must be percent-encoded if it appears as data. Neither `urlparse` nor `urllib3` performs that percent-encoding at parse time. They each pick a different normalisation, and the normalisations name different hosts.\n\nWalk the four pre-patch layers of `validate_url` against the PoC string. `validators.url('http://127.0.0.1:6666\\\\@1.1.1.1')` returns true; the library's regex is liberal about characters in the userinfo position. `parsed_url.scheme` is `'http'`; the allowlist passes it. `WEB_FETCH_FILTER_LIST` runs `is_string_allowed` against the literal URL; operator blocklists are written for hostnames operators name, not for backslash-encoded loopback addresses, and the default value is empty. The resolve gate runs `socket.getaddrinfo('1.1.1.1', None)`, gets back `1.1.1.1`, runs `ipaddress.ip_address('1.1.1.1').is_global`, gets back `True`, and returns. The function approves the URL.\n\nThe next line in every caller is `requests.get(url, ...)`. `urllib3` reparses the same string. The TCP connection opens to `127.0.0.1` on port `6666`.\n\nFour checks ran against `urlparse`'s view of the URL. None of them ran against the URL `requests` was about to dial.\n\n## The patch did not unify the two parsers. It refused the bytes where they would disagree.\n\nThe 0.9.5 patch (commit [`e7ba8978`](https://github.com/open-webui/open-webui/commit/e7ba8978c68b672a9ef44b72091ff3ff59f098b5)) adds eight lines at the top of `validate_url`:\n\n```diff\n@@ def validate_url(url):\n if isinstance(validators.url(url), validators.ValidationError):\n raise ValueError(ERROR_MESSAGES.INVALID_URL)\n \n+ # Reject parser-confusing chars: urlparse and requests/aiohttp split\n+ # on these differently, e.g. http://127.0.0.1\\@1.1.1.1 → urlparse\n+ # extracts 1.1.1.1 (public, passes filter) while requests connects\n+ # to 127.0.0.1 (internal). Same shape with tab/CR/LF.\n+ if any(ch in url for ch in ('\\\\', '\\t', '\\n', '\\r')):\n+ log.warning(f'Blocked URL with parser-confusing char: {url!r}')\n+ raise ValueError(ERROR_MESSAGES.INVALID_URL)\n+\n parsed_url = urllib.parse.urlparse(url)\n```\n\nThe four pre-patch layers are unchanged. `urlparse` still reads `1.1.1.1` as the hostname of the malicious URL. `urllib3` still reads `127.0.0.1`. The resolve-and-block gate still trusts `urlparse`. The new layer is a string-level character check; it runs before either URL parser sees the input and refuses the URL whenever it contains a character that would make the two parses disagree.\n\nThis is the bouncer-fix shape. The fix in [s3-proxy CVE-2026-42882](/posts/s3-proxy-cve-2026-42882-two-parses-one-bouncer) added a third middleware layer to detect when the auth path and the handler path would diverge; the auth middleware and the handler still consumed different representations. The fix in [Nitro CVE-2026-44373](/posts/nitro-cve-2026-44373-upstream-decoded-the-bytes) added an `isPathInScope` helper to pre-decode `%2F` and refuse forwarding when the decoded path escaped the scope; the radix3 match and the forwarded bytes still travelled across a TCP connection to an upstream that decoded once more. Open WebUI's fix for CVE-2026-45400 is the third instance of the move in the catalog: refuse the input where the two parses would disagree, do not make them agree.\n\nThe choice has a rationale the commit message states. Unifying `urlparse` with `urllib3` would mean either patching CPython (the `urlparse` maintainers have repeatedly declined to track WHATWG, citing standard-library compatibility) or threading an alternative URL parser into a function whose four other checks all consume `urlparse` output. The bouncer is cheaper than the rewrite. The principle the commit message gives: \"None of these characters is valid in an unencoded URL... so this is a pure defensive rejection with no legitimate-input false positives.\" The fix accepts that the two parsers will continue to disagree about strings nobody should be sending, and refuses to forward any of those strings to the parser that decides where the TCP socket opens.\n\n## The second time Open WebUI's gate ran on bytes the next layer would change\n\nThe exhibit that sits next to this one in Open WebUI's own history is [CVE-2026-44721](/posts/open-webui-cve-2026-44721-input-had-no-angle-brackets), where `sanitizeResponseContent` escaped `<` and `>` in the model-description input, the input contained neither character, and `marked.parse` then converted the markdown link `[Click](javascript:alert())` into the `` element the sanitiser was supposed to block. The fix wrapped `marked.parse`'s output in `DOMPurify.sanitize`. The sanitiser ran on the input. The renderer produced the output. The two strings shared a function call between them; the function call manufactured the bytes the gate would have rejected.\n\nBoth bugs live in the same product. They share neither code path nor language. The CVE-2026-45400 SSRF lives in Python under `backend/open_webui/retrieval/`; the CVE-2026-44721 XSS lived in TypeScript under `src/lib/components/chat/`. They were authored by different contributors and fixed by different maintainers in different release cycles. What they share is the assumption that a value checked at the top of a function is the value used at the bottom of it. That assumption is held widely. It is held in any code that reads a string, validates it, and forwards it to a library that will reparse it.\n\nThe pattern catalog has [nineteen prior exhibits of this shape](/patterns/gate-before-canonicalize). Most live in URL or HTTP-path parsing; several live in argument-list lexing, signature verification, or Kerberos hostname resolution. Open WebUI's pair adds two more substrates: markdown rendering and HTTP authority parsing. The class signature applies verbatim in both. The gate inspects the wrapped form. The action consumes the unwrapped one. The patch shape in this exhibit, refuse where they would disagree, is the catalog's third instance of the bouncer move and its first in pure Python.\n\nPoC: [GHSA-8w7q-q5jp-jvgx](https://github.com/advisories/GHSA-8w7q-q5jp-jvgx). Patch: [open-webui/open-webui@e7ba8978](https://github.com/open-webui/open-webui/commit/e7ba8978c68b672a9ef44b72091ff3ff59f098b5).","closing_line":"The patch did not teach `urlparse` what `requests` sees. It refused the URLs where they would disagree.","hook_md":"Open WebUI's `validate_url` ran four checks on the URL before `requests.get` saw it. A `validators`-library URL syntax check. A scheme allowlist. An operator-configurable blocklist. A DNS resolution against `urllib.parse.urlparse(url).hostname` followed by a refusal to fetch when any answer was not globally routable. The fourth check is the SSRF gate. The hostname it resolved was the hostname `requests` was not about to dial.","post_id":447,"slug":"open-webui-cve-2026-45400-block-list-asked-urlparse","title":"CVE-2026-45400: Open WebUI's Private-IP Block List Asked `urlparse`. `requests` Asked a Different Parser.","type":"initial","unreadable_sentence":"Four checks ran against `urlparse`'s view of the URL. None of them ran against the URL `requests` was about to dial."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCam5F6AAKCRDeZjl4jgkQ JvxNAQDj2XUTh4s+0jnJ1mCsKS/DTV0HR79VFVB8dJLjzz7gwgEAj5p3/GNHr9eT PbMcHIC7+/36b2xrNyIBruPWpcEBrgo= =GkbQ -----END PGP SIGNATURE-----