2026-02-06, Pydantic AI web UI: SSRF + CDN-path traversal → XSS (GHSAs)¶
GitHub advisories:
- SSRF in URL download handling: https://github.com/advisories/GHSA-2jrp-274c-jhv3
- Stored XSS via path traversal in web UI CDN URL: https://github.com/advisories/GHSA-wjp5-868j-wqv7
Summary¶
Two high-impact issues were disclosed affecting applications that expose Pydantic AI’s web UI / chat interface:
- SSRF: if your app accepts message history (or “file” parts) from untrusted users, attacker-supplied URLs can cause your server to fetch internal resources (e.g.,
127.0.0.1, RFC1918, metadata services). - Client-side compromise (XSS): if the web UI can be influenced to load attacker-controlled HTML/JS (via a path traversal style URL construction), an attacker can execute code in the user’s browser context and steal chat history and other browser-accessible data.
Who is at risk¶
You are in-scope if you:
- Use
Agent.to_web/clai web(or similar) to serve a browser-based chat UI, and - Allow untrusted users to submit message history or message “parts” that include URL references.
Higher risk when:
- The UI is exposed on a remote host (not just
localhost). - The server environment has access to cloud metadata endpoints or internal APIs.
- Chat history contains secrets (API keys, tokens, incident notes) that are retrievable client-side.
Immediate actions¶
- Upgrade to the fixed versions (preferred)
- Apply upstream patches for both issues (see advisory “Fixed in” versions).
- Assume chat history may be sensitive
- Treat chat logs and localStorage as potential secret-bearing data.
- Constrain outbound fetches (defense-in-depth)
- Block access to:
127.0.0.0/8,::1, RFC1918 ranges, link-local, CGNAT, and other non-public ranges.- Cloud metadata endpoints (e.g.,
169.254.169.254) always.
- Validate every redirect target and defend against DNS rebinding (resolve + verify).
- Do not accept arbitrary message history without a sanitizer/processor
- Strip or reject URL-based parts unless explicitly required.
Detection / hunt¶
- Server logs: suspicious downloads to internal IPs, loopback, link-local, or unusual domains.
- Egress monitoring: HTTP(S) calls from the app to RFC1918 or metadata service ranges.
- Web access logs: unexpected query parameters to the chat UI endpoints; requests that look like crafted “version”/asset selectors.
- Client-side: reports of “weird UI behavior” or unexpected redirects; sudden loss/changes of chat state.
Notes¶
Even if your UI is “intended to be local only”, many incidents start with an accidental exposure (tunnel, misconfigured reverse proxy, 0.0.0.0 bind). Treat “local web UIs” as potentially internet-reachable and harden accordingly.
October 8 follow-up: the same local chat UI, now a browser-reachable tool-execution surface (CVE-2026-107295 / GHSA-h4xc-3qfq-jf93 high, and CVE-2026-107292 / GHSA-q2xc-rrxj-58x9 medium)¶
Two more Agent.to_web() / clai web legs (fixed 1.107.4/2.28.0 and 1.107.5/2.30.0):
- No Content-Type check on the chat endpoint: a website the developer visits POSTs to
http://localhost:<port>(text/plain simple request, no preflight, no CORS needed), the agent runs, and its tools execute with the local process's privileges and credentials.requires_approval=Truetools were also reachable because the endpoint trusts approval decisions relayed by the client, client-side approval UIs are not access controls. Fix: requireContent-Type: application/jsonbefore parsing. - No Host-header validation → DNS rebinding makes the local UI same-origin: attacker name TTL=0 → loopback, browser treats
http://attacker-tld:portas same-origin, Origin checks and any token in the served UI are defeated; Chromium's Local Network Access gates subresources but not top-level navigations, and Safari doesn't implement it. Fix: Host allow-list with421 Misdirected Request.
Durable rules (this is the same product's web-UI surface on its third advisory generation, same-product re-sweep again):
- Local dev/agent UIs get the full browser-origin battery by default: simple-content-type POST, DNS rebinding, Host decision table, top-level-navigation exceptions to LNA. Loopback binding proves nothing, the victim's browser is the attack path (July 8 browser-to-loopback family).
- Approval/confirmation flows rendered in a local web UI must be re-authorized server-side: any endpoint that accepts a client-relayed "user approved" decision has no approval gate at all. Grep:
approved/approvalfields in request models. - Black-box probe on any local agent/dashboard port you find during desktop/loopback recon: POST a simple text/plain body and watch for state change; rebind a lab domain to 127.0.0.1 and check for
421-style Host rejection vs same-origin reads.
October 22 follow-up: the fourth generation, UploadedFile reference parts bypass the URL scheme allowlist and resolve with the server's own cloud identity (GHSA-h7p7-w5gc-xj3w / CVE-2026-54249, >= 1.65.0, < 1.106.0 and >= 2.0.0b1, < 2.0.0b6)¶
Pydantic AI's UI adapters (e.g. the Vercel AI adapter) reconstruct file parts from client-submitted message history and forward them to the model provider. File URL parts get validated against a scheme allowlist first, but UploadedFile references, which point at a provider file ID or a cloud-storage URI (s3://…, gs://…), were forwarded with no validation at all. The provider resolves that reference using the server's identity (IAM role, service account, provider API key), so a client crafting message history that embeds an attacker-chosen UploadedFile makes the application read files from its own account, or another tenant's, whenever object naming is enumerable, through the app's credentials, not the client's.
Operator reading:
- Validation is per part-type, not per sink. The scheme allowlist guards exactly one message-part shape. Every file-reference shape that reaches the same outbound provider call, URL part, uploaded-file reference, provider file ID, bucket URI, needs its own check; a guard written for one shape is not inherited by siblings. Grep fingerprint: adapter code that branches on part type (
urlvsuploaded_file/file-ID) where only one branch calls the validator. - Resolution-time identity is the confused deputy here. The fetch does not happen in your client or even in your server process, it happens in the model provider's storage plane as the server's credential. This is one step past the classic SSRF fold on this page (February 6 leg): same client-controlled-reference → server-identity-fetch shape, but the read channel is the provider's object store, and the evidence surface is model output/response, not an HTTP response.
- Probe battery on any agent app that accepts client-supplied message history: submit every file-part shape separately,
urlwith blocked schemes, anUploadedFilewith a foreign provider file ID, ans3:///gs://URI to a canary object you placed in the app's own bucket, and a guessable-name object in a sibling tenant's bucket (lab only). A part shape that reaches the provider without a validation error is the finding, regardless of whether the fetch succeeds, error text often confirms resolution attempt. - Same-product re-sweep pays a fourth time on this page's surface (Feb 6 originals → Oct 8 browser-origin legs → Oct 22 reference-part leg): every
to_web/UI-adapter fix release is a re-enumeration trigger for the next part/shape gap.
Validation boundaries: your own agent app with disposable provider accounts and canary objects only; never attempt to read real tenant objects or enumerate third-party buckets.
November 25 follow-up: the fifth generation, PlaywrightBrowser egress policy enforced on HTTP + page WebSockets only, WebRTC, WebTransport, WebSocketStream, and FedCM all walk around it (GHSA-fqpx-wxvv-g359 / CVE-2026-136641, medium, pydantic-ai-harness before 0.74.0)¶
The harness's browser tool enforces its egress allowlist on HTTP requests and page WebSockets only. A page the agent opens (attacker-influenced content is the assumed threat) can still make the browser: (1) send WebRTC STUN/TURN and WebTransport setups to refused hosts/ports even under an all-request-kinds allowlist policy, giving a STUN-answer oracle for whether an internal host responds (no body readable); (2) open WebSocketStream connections, ordinary WebSockets the WS guard never sees, from a page, frame, or worker, and read the full response from private addresses; (3) fire FedCM (navigator.credentials.get with an IdP) so the browser itself fetches the provider's /.well-known/web-identity, config, accounts, and client-metadata URLs with page-chosen config path and client ID, exfiltrating to hosts outside allowed_domains, with the accounts request carrying the provider cookies from the browser profile. The 0.74.0 fix strips RTCPeerConnection/WebTransport/WebSocketStream/IdentityCredential constructors and launches Chromium with FedCM/WebSocketStream disabled, but the advisory itself lists the residual paths: WebTransport from workers, WebSocketStream from workers under cdp_url-attached browsers, WebTransport in site-isolated sandboxed iframes (headless=False + cdp_url), and documents loaded before guard attachment under cdp_context='default'.
Operator rules for agent-browser assessments:
- Egress policy = protocol-parity matrix, not a URL filter. Enumerate every channel the engine can originate: fetch/XHR, EventSource, WebSocket, WebSocketStream, WebRTC (STUN/TURN/datachannel), WebTransport/HTTP3, WebRTC-style UDP, FedCM/auto-fetch/preload, form navigation. For each, ask who enforces the policy: the network layer (unbypassable) or an in-page interceptor (constructor-strippable, worker-scoped-missable, attach-order-missable). Interceptor-enforced policies fail on the channels nobody wired in, here four of them.
- Constructor removal is guard-by-obliteration: test the residual-context battery. After any "we delete the dangerous globals" fix, re-run the battery in every execution context: main frame, cross-origin iframe, worker (dedicated + shared), sandboxed iframe in its own process,
cdp_url-attached pre-existing browser, and pre-attachment documents. The fix's own text ("these paths stay open") is a free test plan. - Browser-native protocols carry attacker-chosen URLs with victim-profile state. FedCM here is the credential-riding SSRF shape from this page's Oct 22 leg re-expressed in the browser: attacker picks the config URL, the browser adds profile cookies. Any headless/profile-backed browser tool with an egress guard gets the FedCM probe (
identityUrlto an owned listener, watch for cookie-bearing accounts fetches) plus a STUN probe against lab canaries. - Genealogy on this page: Feb 6 SSRF/XSS originals, Oct 8 browser-origin/DNS-rebinding legs, Oct 22 UploadedFile reference leg, Nov 25 protocol-channel legs. Same-product re-sweep pays a fifth time: every fix release re-enumerates the next guard gap.
Validation boundaries: lab agent apps, owned STUN/TURN/FedCM listeners, synthetic internal canaries you control, no real browser profiles with live sessions.