Pydantic AI's built-in web chat UI has a path traversal + XSS flaw allowing an attacker to serve arbitrary JavaScript to anyone who clicks a crafted link, silently stealing their full AI chat history. If your development or internal teams use Agent.to_web() or clai web, patch to v1.51.0 immediately — these UIs often carry sensitive prompts, internal data, and credentials typed into chat. Low EPSS and required user interaction reduce urgency, but developer tooling is routinely unprotected.
Affected Systems
| Package | Ecosystem | Vulnerable Range | Patched |
|---|---|---|---|
| pydantic-ai | pip | >= 1.34.0, < 1.51.0 | 1.51.0 |
| pydantic-ai-slim | pip | >= 1.34.0, < 1.51.0 | 1.51.0 |
| pydantic_ai | — | — | No patch |
Severity & Risk
Recommended Action
- 1. Patch: Upgrade pydantic-ai and pydantic-ai-slim to v1.51.0 or later immediately. 2. Inventory: Identify all internal or external deployments using Agent.to_web() or clai web — including developer laptops, staging environments, and internal demos. 3. Workaround if patching is delayed: Block or strip the 'version' query parameter at the reverse proxy or WAF layer; alternatively, disable the web UI feature and use programmatic API access instead. 4. Detection: Search web/app server logs for requests to the Pydantic AI UI endpoint containing '../', '%2e%2e%2f', or version parameter values that do not match a valid semantic version string. 5. Post-incident: Treat any sensitive data (credentials, internal architecture details, PII) shared via the chat interface in affected versions as potentially compromised — rotate credentials and review exposed conversations.
Classification
Compliance Impact
This CVE is relevant to:
Technical Details
NVD Description
Pydantic AI is a Python agent framework for building applications and workflows with Generative AI. From 1.34.0 to before 1.51.0, a path traversal vulnerability in the Pydantic AI web UI allows an attacker to serve arbitrary JavaScript in the context of the application by crafting a malicious URL. In affected versions, the CDN URL is constructed using a version query parameter from the request URL. This parameter is not validated, allowing path traversal sequences that cause the server to fetch and serve attacker-controlled HTML/JavaScript from an arbitrary source on the same CDN, instead of the legitimate chat UI package. If a victim clicks the link or visits it via an iframe, attacker-controlled code executes in their browser, enabling theft of chat history and other client-side data. This vulnerability only affects applications that use Agent.to_web to serve a chat interface and clai web to serve a chat interface from the CLI. These are typically run locally (on localhost), but may also be deployed on a remote server. This vulnerability is fixed in 1.51.0.
Exploitation Scenario
An attacker targeting an AI engineering team discovers via LinkedIn or GitHub that developers are using Pydantic AI to build an internal RAG assistant with an Agent.to_web() UI. The attacker crafts a URL to the internal app with a 'version' parameter containing path traversal sequences pointing to attacker-controlled HTML hosted on the legitimate CDN used by Pydantic AI. The URL is sent as a Slack DM ('hey, can you check if this agent response looks right to you?') or embedded in a GitHub issue comment on the target's repo. When the developer opens the link, the attacker's JavaScript executes in the context of the Pydantic AI chat interface, silently POSTing the full conversation history — including any API keys, internal system prompts, or proprietary data typed into the chat — to an attacker-controlled endpoint. The developer sees nothing unusual.
Weaknesses (CWE)
CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:N References
- github.com/advisories/GHSA-wjp5-868j-wqv7
- github.com/pydantic/pydantic-ai/releases/tag/v1.51.0
- github.com/pydantic/pydantic-ai/security/advisories/GHSA-wjp5-868j-wqv7
- nvd.nist.gov/vuln/detail/CVE-2026-25640
- github.com/pydantic/pydantic-ai/releases/tag/v1.51.0 Product Release
- github.com/pydantic/pydantic-ai/security/advisories/GHSA-wjp5-868j-wqv7 Vendor