Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB
CVE-2026-107295 Overview
CVE-2026-107295 is a Cross-Site Request Forgery (CSRF) vulnerability [CWE-352] affecting Pydantic AI, a Python agent framework for building generative AI applications. The flaw exists in the Agent.to_web() method and the clai web development chat endpoint from version 1.34.0 through 1.107.4 and 2.28.0. The chat endpoint fails to validate the request Content-Type, allowing any website a developer visits to issue a browser-compatible request to a loopback-hosted chat server. The agent then executes tools with the privileges and credentials of the local process.
Critical Impact
A malicious webpage visited by a developer running a local Pydantic AI chat server can trigger agent execution and tool invocation using the developer's local credentials, including bypass of requires_approval=True tool gates relayed through the client.
Affected Products
- Pydantic AI 1.34.0 through versions prior to 1.107.4
- Pydantic AI 2.x through versions prior to 2.28.0
- Any application exposing Agent.to_web() or using the clai web command
Discovery Timeline
- 2026-10-08 - CVE-2026-107295 published to NVD
- 2026-10-13 - Last updated in NVD database
Technical Details for CVE-2026-107295
Vulnerability Analysis
The Pydantic AI web UI chat endpoint accepts JSON bodies but does not reject requests arriving with non-JSON Content-Type headers. Browsers permit three CORS-safelisted content types (text/plain, multipart/form-data, application/x-www-form-urlencoded) and no-content-type requests to be sent cross-origin without a preflight. All four cases can carry a valid JSON body. A malicious page can therefore POST attacker-controlled JSON to http://localhost:<port>/chat and invoke the live agent.
Binding the server to localhost does not mitigate this. The browser running on the developer's machine satisfies the loopback requirement, and the Same-Origin Policy does not block the request itself; it only blocks the response from being read. For CSRF, reading the response is unnecessary; the side effect of running the agent and its tools is sufficient.
Root Cause
The /chat endpoint in pydantic_ai_slim/pydantic_ai/ui/_web/api.py lacked an allowlist check on the Content-Type header. Without requiring application/json, the endpoint accepted CORS-simple requests that bypass preflight. Client-relayed tool approval decisions compounded the issue: tools marked requires_approval=True were still reachable because the approval flow was mediated by the untrusted client.
Attack Vector
The attack requires a developer to visit an attacker-controlled page while running a local Pydantic AI chat server. The page submits a form POST or fetch() request with a safelisted content type to the loopback chat endpoint. The agent processes the attacker-supplied prompt and executes exposed tools using the local process credentials, including filesystem access, API keys, and model provider tokens.
# Security patch in pydantic_ai_slim/pydantic_ai/ui/_web/api.py
# Enforces an application/json Content-Type allowlist as a CSRF control.
# `/chat` requires exactly this content type. This is a CSRF control, not content negotiation: a
# browser can send the three CORS-safelisted content types (`text/plain`, `multipart/form-data`,
# `application/x-www-form-urlencoded`) — or no content type at all — cross-origin with no preflight,
# and every one of them can carry a JSON body. Without this check, a page the developer happens to
# visit while running the web UI could start an agent run on their machine, and execute whatever
# tools the served agent exposes. `application/json` is not safelisted, so requiring it forces a
# preflight, which `options_chat` refuses.
#
# Keep this an allowlist. A denylist of the safelisted types would miss the no-content-type case,
# and would silently stop covering anything added to the safelist later.
JSON_MEDIA_TYPE = 'application/json'
Source: GitHub Commit d2690201
Stop Remote Code Execution Before It Runs
Singularity™ Endpoint detects and blocks exploit attempts at machine speed, including zero-days and novel attack techniques.
Stop Exploit AttemptsDetection Methods for CVE-2026-107295
Indicators of Compromise
- Access log entries on local Pydantic AI chat servers showing POST requests to /chat with Content-Type values of text/plain, multipart/form-data, or application/x-www-form-urlencoded.
- Agent runs initiated with Origin or Referer headers pointing to external domains rather than the local developer UI.
- Unexpected tool invocations in Pydantic AI logs occurring without corresponding developer interaction in the bundled UI.
Detection Strategies
- Inspect HTTP access logs for requests to loopback chat endpoints that lack the application/json content type.
- Audit agent run histories for tool executions whose timing correlates with browser activity rather than developer intent.
- Review installed Pydantic AI versions across developer workstations and flag any instance in the vulnerable range.
Monitoring Recommendations
- Instrument the chat endpoint with structured logging that records Content-Type, Origin, and Referer headers.
- Alert on any approval of requires_approval=True tools that occurs during browsing sessions.
- Track outbound API calls initiated by the local agent process for anomalies in volume or destination.
How to Mitigate CVE-2026-107295
Immediate Actions Required
- Upgrade Pydantic AI to 1.107.4 for the v1 branch or 2.28.0 for the v2 branch without delay.
- Stop any running Agent.to_web() or clai web instance on vulnerable versions until the upgrade is complete.
- Rotate credentials, API keys, and model provider tokens exposed to the local agent process if abuse is suspected.
Patch Information
The fix was shipped in Pydantic AI v1.107.4 and v2.28.0. The patches enforce an application/jsonContent-Type allowlist on the /chat endpoint, which forces a CORS preflight that options_chat refuses. See GHSA-h4xc-3qfq-jf93 for the complete advisory and PR #7382 and PR #7383 for the code changes.
Workarounds
- Do not browse untrusted sites while a local Pydantic AI web UI is running on an unpatched installation.
- Place the chat server behind a reverse proxy that rejects any request whose Content-Type is not application/json.
- Restrict the toolset exposed by locally served agents to remove destructive or credentialed operations until patched.
# Upgrade Pydantic AI to a fixed release
pip install --upgrade 'pydantic-ai>=1.107.4,<2' \
|| pip install --upgrade 'pydantic-ai>=2.28.0'
# Verify the installed version
python -c "import pydantic_ai; print(pydantic_ai.__version__)"
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB

