Skip to content
pydantic-aiGHSA-2jrp-274c-jhv3

Pydantic AI has Server-Side Request Forgery (SSRF) in URL Download Handling

High8.6CVE-2026-25580 · Published Feb 6, 2026 · updated Jul 13, 2026

## Summary A Server-Side Request Forgery (SSRF) vulnerability exists in Pydantic AI's URL download functionality. When applications accept message history from untrusted sources, attackers can include malicious URLs that cause the server to make HTTP requests to internal network resources, potentially accessing internal services or cloud credentials. **This vulnerability only affects applications that accept message history from external users**, such as those using: - **`Agent.to_web`** or **`clai web`** to serve a chat interface - **`VercelAIAdapter`** for Vercel AI SDK integration - **`AGUIAdapter`** or **`Agent.to_ag_ui`** for AG-UI protocol integration - Custom APIs that accept message history from user input Applications that only use hardcoded or developer-controlled URLs are not affected. ### Description The `download_item()` helper function downloads content from URLs without validating that the target is a public internet address. When user-supplied message history contains URLs, attackers can: 1. **Access internal services**: Request `http://127.0.0.1`, `localhost`, or private IP ranges (`10.x.x.x`, `172.16.x.x`, `192.168.x.x`) 2. **Steal cloud credentials**: Acces...

GitHub advisory

Affected versions

PackageAffectedFixed in
pydantic-ai
PyPI
>= 0.0.26, < 1.56.01.56.0
Details and references

## Summary A Server-Side Request Forgery (SSRF) vulnerability exists in Pydantic AI's URL download functionality. When applications accept message history from untrusted sources, attackers can include malicious URLs that cause the server to make HTTP requests to internal network resources, potentially accessing internal services or cloud credentials. **This vulnerability only affects applications that accept message history from external users**, such as those using: - **`Agent.to_web`** or **`clai web`** to serve a chat interface - **`VercelAIAdapter`** for Vercel AI SDK integration - **`AGUIAdapter`** or **`Agent.to_ag_ui`** for AG-UI protocol integration - Custom APIs that accept message history from user input Applications that only use hardcoded or developer-controlled URLs are not affected. ### Description The `download_item()` helper function downloads content from URLs without validating that the target is a public internet address. When user-supplied message history contains URLs, attackers can: 1. **Access internal services**: Request `http://127.0.0.1`, `localhost`, or private IP ranges (`10.x.x.x`, `172.16.x.x`, `192.168.x.x`) 2. **Steal cloud credentials**: Access cloud metadata endpoints (AWS IMDSv1 at `169.254.169.254`, GCP, Azure, Alibaba Cloud) 3. **Scan internal networks**: Enumerate internal hosts and ports ### Who Is Affected You are affected if your application: 1. **Uses `Agent.to_web` or `clai web`** - The web interface accepts file attachments via the Vercel AI Data Stream Protocol, where users can provide arbitrary URLs through chat messages. 2. **Uses `VercelAIAdapter`** - Chat interfaces built with Vercel AI SDK allow users to submit messages containing URLs that are processed server-side. 3. **Uses `AGUIAdapter` or `Agent.to_ag_ui`** - The AG-UI protocol allows users to provide file references with URLs as part of agent interactions. 4. **Exposes a custom API accepting message history** - Any endpoint that accepts message history or `ImageUrl`, `AudioUrl`, `VideoUrl`, `DocumentUrl` objects from user input. ### Attack Scenario Via chat interface, an attacker submits a message with a file attachment pointing to an internal resource: ```json { "role": "user", "parts": [ {"type": "file", "mediaType": "image/png", "url": "http://169.254.169.254/latest/meta-data/iam/security-credentials/"} ] } ``` ### Affected Model Integrations Multiple model integrations download URL content in certain conditions: | Provider | Downloaded Types | |----------|------------------| | `OpenAIChatModel` | `AudioUrl`, `DocumentUrl` | | `AnthropicModel` | `DocumentUrl` (`text/plain`) | | `GoogleModel` (GLA) | All URL types (except YouTube and Files API URLs) | | `XaiModel` | `DocumentUrl` | | `BedrockConverseModel` | `ImageUrl`, `DocumentUrl`, `VideoUrl` (non-S3 URLs) | | `OpenRouterModel` | `AudioUrl` | ## Remediation ### Upgrade to Patched Version **Upgrade** to the patched version or later. The fix adds comprehensive SSRF protection: - Blocks private/internal IP addresses by default - Always blocks cloud metadata endpoints (even with `allow-local`) - Only allows `http://` and `https://` protocols - Resolves hostnames before requests to prevent DNS rebinding - Validates each redirect target ### New `force_download='allow-local'` Option If an application legitimately needs to access local/private network resources (e.g., in a fully trusted internal environment), it can explicitly opt in: ```python from pydantic_ai import ImageUrl # Default behavior: private IPs are blocked ImageUrl(url="http://internal-service/image.png") # Raises ValueError # Opt-in to allow local access (use with caution) ImageUrl(url="http://internal-service/image.png", force_download='allow-local') ``` **Important**: Cloud metadata endpoints (`169.254.169.254`, `fd00:ec2::254`, `100.100.100.200`) are **always blocked**, even with `allow-local`. ### Workaround for Older Versions If a project cannot upgrade immediately,

CVSS 3.1
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:N/A:N
Severity from
GitHub (reviewed advisory)
Weakness
CWE-918
Also known as
CVE-2026-25580, PYSEC-2026-2976, PYSEC-2026-2980

More pydantic-ai advisories

All pydantic-ai
Advisory
pydantic-ai: server-side request forgery
Medium6.8Aug 13
pydantic-ai: server-side request forgery
Medium6.8Jun 26
Pydantic AI: SSRF cloud-metadata blocklist bypass via IPv4-mapped IPv6 (Incomplete fix of CVE-2026-25580)
Medium6.8May 21
Pydantic AI has Stored XSS via Path Traversal in Web UI CDN URL
High7.1Feb 6

Critical advisories by email

Wednesdays: the week’s critical and high advisories in the AI and data stack, with the fixed versions. Only in weeks that have some.

Double opt-in. Unsubscribe any time.