{"id":"CVE-2026-25640","aliases":["CVE-2026-25640","GHSA-wjp5-868j-wqv7","PYSEC-2026-2979","PYSEC-2026-2983"],"related":[],"kind":"vulnerability","state":"published","title":"Pydantic AI affected by Stored XSS via Path Traversal in Web UI CDN URL","summary":"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.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"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.","source":"cvelist"},{"lang":"en","text":"## Summary\n\nA Path Traversal vulnerability in the [Pydantic AI web UI](https://ai.pydantic.dev/web/) allows an attacker to serve arbitrary JavaScript in the context of the application by crafting a malicious URL. 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.\n\n**This vulnerability only affects applications that use:**\n- **`Agent.to_web`** to serve a chat interface\n- **`clai web`** to serve a chat interface from the CLI\n\nThese are typically run locally (on `localhost`), but may also be deployed on a remote server.\n\n### Description\n\nThe web UI serves its frontend HTML by fetching it from a CDN. 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.\n\n### Who Is Affected\n\nProjects are affected if your application uses `Agent.to_web` or `clai web` to serve the Pydantic AI chat interface.\n\n### Attack Scenario\n\n1. An attacker crafts a URL pointing to the victim's Pydantic AI web UI instance (either `localhost` with the known port, or a remote server endpoint) with a malicious `version` query parameter containing path traversal sequences.\n\n2. The attacker gets the victim to visit this URL — directly via a link, through a redirect, or by embedding it in an iframe.\n\n3. When the victim's browser loads the page, the server fetches and serves attacker-controlled HTML/JavaScript instead of the legitimate chat UI.\n\n4. The attacker's JavaScript executes in the victim's browser in the context of the Pydantic AI web application, with access to:\n   - **Chat history** stored in `localStorage` (all user messages and AI responses)\n   - **Session cookies** that are not set as `HttpOnly`, if authentication middleware is configured\n\n## Remediation\n\n### Upgrade to Patched Version\n\n**Upgrade** to the patched version or later. The fix removes the user-controllable `version` parameter entirely. The CDN URL is now hardcoded at startup and cannot be influenced by request parameters.\n\nA new `html_source` parameter is available on `Agent.to_web` and `create_web_app` for applications that need to customize the UI source (e.g., for enterprise environments, offline usage, or custom UI builds). This parameter is only settable in application code, not via query parameters.","format":"markdown","source":"ghsa"},{"lang":"es","text":"Pydantic AI es un framework de agente Python para construir aplicaciones y flujos de trabajo con IA Generativa. Desde la 1.34.0 hasta antes de la 1.51.0, una vulnerabilidad de salto de ruta en la interfaz de usuario web de Pydantic AI permite a un atacante servir JavaScript arbitrario en el contexto de la aplicación al crear una URL maliciosa. En las versiones afectadas, la URL de la CDN se construye utilizando un parámetro de consulta de versión de la URL de la solicitud. Este parámetro no se valida, lo que permite secuencias de salto de ruta que hacen que el servidor obtenga y sirva HTML/JavaScript controlado por el atacante desde una fuente arbitraria en la misma CDN, en lugar del paquete legítimo de la interfaz de usuario de chat. Si una víctima hace clic en el enlace o lo visita a través de un iframe, el código controlado por el atacante se ejecuta en su navegador, lo que permite el robo del historial de chat y otros datos del lado del cliente. Esta vulnerabilidad solo afecta a las aplicaciones que usan Agent.to_web para servir una interfaz de chat y clai web para servir una interfaz de chat desde la CLI. Estas suelen ejecutarse localmente (en localhost), pero también pueden implementarse en un servidor remoto. Esta vulnerabilidad se corrige en la 1.51.0.","source":"nvd"}],"published":"2026-02-06T18:51:57.000Z","modified":"2026-07-15T02:18:55.463Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:L/A:N","score":7.1,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:L/A:N","score":7.1,"rating":"HIGH"},{"scorer":"redhat-SADP","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:L/A:N","score":7.1,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:L/A:N","score":7.1,"rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:N","score":5.4,"rating":"MEDIUM"},{"scorer":"PyPA Advisory Database","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:L/A:N","score":7.1,"rating":"HIGH"}],"cwes":["CWE-22","CWE-79"],"affected":[{"ranges":[{"version":">= 1.34.0, < 1.51.0","status":"affected"}],"vendor":"pydantic","product":"pydantic-ai","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Enterprise Linux AI (RHEL AI) 3","package":"rhelai3/bootc-cuda-rhel9","cpe":"cpe:/a:redhat:enterprise_linux_ai:3","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Enterprise Linux AI (RHEL AI) 3","package":"rhelai3/disk-image-cuda-rhel9","cpe":"cpe:/a:redhat:enterprise_linux_ai:3","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"1.34.0","status":"affected","fixed":"1.51.0"}],"ecosystem":"PyPI","package":"pydantic-ai","purl":"pkg:pypi/pydantic-ai","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"1.34.0","status":"affected","fixed":"1.51.0"}],"ecosystem":"PyPI","package":"pydantic-ai-slim","purl":"pkg:pypi/pydantic-ai-slim","source":"ghsa"},{"ranges":[{"status":"affected","introduced":"1.34.0","fixed":"1.51.0"}],"vendor":"pydantic","product":"pydantic_ai","cpe":"cpe:2.3:a:pydantic:pydantic_ai:*:*:*:*:*:python:*:*","source":"nvd"},{"ranges":[{"type":"ecosystem","introduced":"1.34.0","status":"affected","fixed":"1.51.0"}],"ecosystem":"PyPI","package":"pydantic-ai","purl":"pkg:pypi/pydantic-ai","source":"pysec"},{"ranges":[{"type":"ecosystem","introduced":"1.34.0","status":"affected","fixed":"1.51.0"}],"ecosystem":"PyPI","package":"pydantic-ai-slim","purl":"pkg:pypi/pydantic-ai-slim","source":"pysec"}],"references":[{"url":"https://github.com/pydantic/pydantic-ai/security/advisories/GHSA-wjp5-868j-wqv7","tags":["vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/pydantic/pydantic-ai/releases/tag/v1.51.0","tags":["product","release-notes","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://access.redhat.com/security/cve/CVE-2026-25640","tags":["vdb-entry","x-refsource-redhat"],"sources":["cvelist","nvd"]},{"url":"https://bugzilla.redhat.com/show_bug.cgi?id=2437753","tags":["issue-tracking","x-refsource-redhat"],"sources":["cvelist","nvd"]},{"url":"https://security.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-25640.json","tags":["x-sadp-csaf-vex"],"sources":["cvelist","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-25640","tags":["advisory"],"sources":["ghsa","pysec"]},{"url":"https://github.com/pydantic/pydantic-ai","tags":["package"],"sources":["ghsa","pysec"]},{"url":"https://pypi.org/project/pydantic-ai","tags":["package"],"sources":["pysec"]},{"url":"https://github.com/advisories/GHSA-wjp5-868j-wqv7","tags":["advisory"],"sources":["pysec"]},{"url":"https://pypi.org/project/pydantic-ai-slim","tags":["package"],"sources":["pysec"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"partial","date":"2026-02-06T20:16:17.763Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-25640","url":"https://www.cve.org/CVERecord?id=CVE-2026-25640","licence":"CVE Terms of Use","modified":"2026-07-15T01:16:10.402Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-wjp5-868j-wqv7","url":"https://github.com/advisories/GHSA-wjp5-868j-wqv7","licence":"CC-BY-4.0","modified":"2026-07-13T16:43:43.442Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-25640","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-25640","licence":"Public domain","modified":"2026-07-15T02:18:55.463Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2026-2979","url":"https://osv.dev/vulnerability/PYSEC-2026-2979","licence":"CC-BY-4.0","modified":"2026-07-13T16:43:43.442Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2026-2983","url":"https://osv.dev/vulnerability/PYSEC-2026-2983","licence":"CC-BY-4.0","modified":"2026-07-13T16:43:43.442Z"}],"updatedAt":"2026-11-25T22:59:13.572Z","epss":{"score":0.00371,"percentile":0.33116,"date":"2026-12-01T12:00:22.000Z"}}