CVE-2026-107292
DNS rebinding enables same‑origin attacks on localhost Pydantic AI agents.
- CVSS 6.4
- CWE-346
- Authentication, Authorization, and Session Management
- Remote
Pydantic AI is a Python agent framework for building applications and workflows with Generative AI. From 1.34.0 until 2.30.0, the Agent.to_web() and clai web development chat server does not validate the Host header, allowing a website visited by a developer to use DNS rebinding to reach a loopback-hosted agent as a same-origin service. The hostile page can read the served UI and submit chat requests that execute agent tools with the local process's privileges and credentials, causing data disclosure or unwanted side effects. Binding to localhost, Origin checks, and CSRF tokens do not prevent the same-origin DNS rebinding path. This issue is fixed in versions 1.107.5 and 2.30.0.
- CWE
- CWE-346
- CVSS base score
- 6.4
- Published
- 2026-10-08
- OWASP
- A05 Security Misconfiguration
- Orthogonal defect classification
- Interface
- Code defect classification
- Incorrect Interface
- Category
- Authentication, Authorization, and Session Management
- Subcategory
- Cross-Site Request Forgery (CSRF)
- Accessibility scope
- Remote
- Impact
- Unauthorized Access
- Affected component
- Pydantic AI
- Fixed by upgrading
- Yes
Solution
Upgrade Pydantic AI to version 1.107.5 (or any 2.x release ≥ 2.30.0).
Vulnerable code sample
from fastapi import FastAPI, Request, Response
from pydantic import BaseModel
app = FastAPI()
class Message(BaseModel):
content: str
# VULNERABLE: accepts any Host header, enabling DNS rebinding
@app.post("/chat")
async def chat_endpoint(request: Request, msg: Message):
# No validation of request.headers['host']
# Process the message and return a response
result = {"reply": f"Echo: {msg.content}"}
return Response(content=str(result), media_type="application/json")Patched code sample
from fastapi import FastAPI, Request, Response, HTTPException
from pydantic import BaseModel
app = FastAPI()
class Message(BaseModel):
content: str
# FIX: validate Host header against allowed hosts to prevent DNS rebinding
@app.post("/chat")
async def chat_endpoint(request: Request, msg: Message):
host = request.headers.get("host", "")
if host not in {"localhost", "127.0.0.1"}:
raise HTTPException(status_code=400, detail="Invalid Host header")
result = {"reply": f"Echo: {msg.content}"}
return Response(content=str(result), media_type="application/json")Published fix
Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.
- Add `allowed_hosts` to `Agent.to_web()` and `clai web` (v1 backport) (#7438) (pydantic/pydantic-ai)
pydantic_ai_slim/pydantic_ai/agent/__init__.py · Agent.to_web,pydantic_ai_slim/pydantic_ai/ui/_web/api.py · create_api_app,pydantic_ai_slim/pydantic_ai/ui/_web/app.py,pydantic_ai_slim/pydantic_ai/ui/_web/app.py · create_web_app,pydantic_ai_slim/pydantic_ai/_cli/web.py · run_web_command,pydantic_ai_slim/pydantic_ai/_cli/__init__.py · _cli_web - Add `allowed_hosts` to `Agent.to_web()` and `clai web` (#7437) (pydantic/pydantic-ai)
pydantic_ai_slim/pydantic_ai/agent/__init__.py · Agent.to_web,pydantic_ai_slim/pydantic_ai/ui/_web/api.py · create_api_app,pydantic_ai_slim/pydantic_ai/ui/_web/app.py,pydantic_ai_slim/pydantic_ai/ui/_web/app.py · create_web_app,pydantic_ai_slim/pydantic_ai/_cli/web.py · run_web_command
Cite this entry
@misc{vaitp:cve2026107292,
title = {{DNS rebinding enables same‑origin attacks on localhost Pydantic AI agents.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-107292},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-107292/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.
The supreme art of war is to subdue the enemy without fighting.
Sun Tzu – “The Art of War”
:: Shaping the future through research and ingenuity ::
