CVE-2026-25580: Pydantic AI has Server-Side Request Forgery (SSRF) in URL Download Handling
Pydantic AI's download_item() helper fetched any URL in message history without checking that the target was a public address. An app that accepts message history from outside users lets an attacker make the server reach internal services and cloud metadata. Upgrade pydantic-ai or pydantic-ai-slim to 1.56.0.
Published Feb 6, 2026 · Analysis Nov 24, 2026
What an attacker can do
When a message holds an ImageUrl, AudioUrl, VideoUrl or DocumentUrl, some model integrations download the content on the server before they call the model. download_item() did that with no check on where the URL pointed. The advisory lists which integrations download which types, for example OpenAIChatModel for audio and documents, GoogleModel for nearly all URL types, and BedrockConverseModel for non-S3 images, documents and video (CWE-918).
Only apps that take message history from untrusted users are exposed. The advisory names Agent.to_web and clai web, VercelAIAdapter, AGUIAdapter and Agent.to_ag_ui, and custom APIs that accept message history. Apps that use only developer-controlled URLs are not affected.
The attack is one chat message with a file part whose URL points at an internal address. No login and no user interaction are needed. The advisory lists three outcomes: reaching services on 127.0.0.1 and private ranges, stealing cloud credentials from metadata endpoints such as AWS IMDSv1 at 169.254.169.254, and scanning internal hosts and ports. The 3.1 score of 8.6 reflects a changed scope and high confidentiality impact.
Who is affected
Affected: the pip packages pydantic-ai and pydantic-ai-slim, from 0.0.26 up to but not including 1.56.0. Version 1.56.0 is patched in both. You are exposed only if user-supplied message history, or URL objects built from user input, reach an agent.
Check your versions:
pip show pydantic-ai pydantic-ai-slimSearch your code for to_web, VercelAIAdapter, AGUIAdapter, to_ag_ui and any API that takes message history from users.
pydantic-ai
- Ecosystem
- PyPI
- Affected
- >= 0.0.26, < 1.56.0
- Fixed in
- 1.56.0
- Check
pip show pydantic-ai
pydantic-ai-slim
- Ecosystem
- PyPI
- Affected
- >= 0.0.26, < 1.56.0
- Fixed in
- 1.56.0
- Check
pip show pydantic-ai-slim
How to fix it
Upgrade pydantic-ai or pydantic-ai-slim to 1.56.0 or later:
pip install --upgrade "pydantic-ai-slim>=1.56.0"The fix adds a new _ssrf.py module. It blocks private and internal addresses by default, always blocks cloud metadata endpoints, allows only http and https, resolves hostnames before the request to stop DNS rebinding, and validates each redirect target, with a maximum of 10. A force_download option set to allow-local lets trusted internal apps opt in to local addresses, but metadata endpoints stay blocked.
If you cannot upgrade, the advisory gives a history processor that drops URL parts that resolve to private, loopback or link-local addresses.
How to tell if you were hit
Review server logs and egress logs for outbound requests from the agent host to 169.254.169.254, 100.100.100.200, localhost or private ranges that follow a chat request. Review stored message history for file parts whose URL host is internal. On cloud hosts, check metadata access logs and any use of the role's credentials from other addresses.
If metadata was reached, rotate the role's credentials.
Original advisory
From the GitHub Advisory Database (CC BY 4.0).
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:
- 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) - Steal cloud credentials: Access cloud metadata endpoints (AWS IMDSv1 at
169.254.169.254, GCP, Azure, Alibaba Cloud) - Scan internal networks: Enumerate internal hosts and ports
Who Is Affected
You are affected if your application:
- 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.
- Uses `VercelAIAdapter` - Chat interfaces built with Vercel AI SDK allow users to submit messages containing URLs that are processed server-side.
- Uses `AGUIAdapter` or `Agent.to_ag_ui` - The AG-UI protocol allows users to provide file references with URLs as part of agent interactions.
- Exposes a custom API accepting message history - Any endpoint that accepts message history or
ImageUrl,AudioUrl,VideoUrl,DocumentUrlobjects from user input.
Attack Scenario
Via chat interface, an attacker submits a message with a file attachment pointing to an internal resource:
{
"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://andhttps://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:
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, use a history processor to filter out URLs targeting local/private addresses:
import ipaddress
import socket
from urllib.parse import urlparse
from pydantic_ai import Agent, ModelMessage, ModelRequest
from pydantic_ai.messages import AudioUrl, DocumentUrl, ImageUrl, VideoUrl
def is_private_url(url: str) -> bool:
"""Check if a URL targets a private/internal IP address."""
try:
parsed = urlparse(url)
hostname = parsed.hostname
if not hostname:
return True # Invalid URL, block it
# Resolve hostname to IP
ip_str = socket.gethostbyname(hostname)
ip = ipaddress.ip_address(ip_str)
# Block private, loopback, and link-local addresses
return ip.is_private or ip.is_loopback or ip.is_link_local
except (socket.gaierror, ValueError):
return True # DNS resolution failed, block it
def filter_private_urls(messages: list[ModelMessage]) -> list[ModelMessage]:
"""Remove URL parts that target private/internal addresses."""
url_types = (ImageUrl, AudioUrl, VideoUrl, DocumentUrl)
filtered = []
for msg in messages:
if isinstance(msg, ModelRequest):
safe_parts = [
part for part in msg.parts
if not (isinstance(part, url_types) and is_private_url(part.url))
]
if safe_parts:
filtered.append(ModelRequest(parts=safe_parts))
else:
filtered.append(msg)
return filtered
# Apply the filter to your agent
agent = Agent('openai:gpt-5', history_processors=[filter_private_urls])Technical Details of the Fix
The fix introduces a new _ssrf.py module with comprehensive protection:
- Protocol validation: Only
http://andhttps://allowed - DNS resolution before request: Prevents DNS rebinding attacks
- Private IP blocking (by default):
127.0.0.0/8,::1/128(loopback)10.0.0.0/8,172.16.0.0/12,192.168.0.0/16(private)169.254.0.0/16,fe80::/10(link-local)100.64.0.0/10(CGNAT)fc00::/7(unique local)2002::/16(6to4, can embed private IPv4)- Cloud metadata always blocked:
169.254.169.254,fd00:ec2::254,100.100.100.200 - Safe redirect handling: Each redirect validated before following (max 10)
Credited to YuvalElbar6, doredry.
Questions
- Which pydantic-ai version fixes CVE-2026-25580?
1.56.0, for both pydantic-ai and pydantic-ai-slim. The affected range starts at 0.0.26.
- Am I affected if my URLs are hardcoded?
No. The advisory says apps that use only hardcoded or developer-controlled URLs are not affected. The risk is message history or URL objects that come from external users.
- Does the fix still allow internal URLs?
Only by opting in with force_download set to allow-local. Cloud metadata endpoints stay blocked even then. Use the option only in a fully trusted internal environment.
- Is CVE-2026-25580 exploited in the wild?
The sources do not say so. The entry has no CISA catalog data, and the EPSS score is about 0.7 percent.
References
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology
More Pydantic AI vulnerabilities
All Pydantic AI entriesCVE-2026-107286
Pydantic AI: Concurrency-limited models can keep their slot when a streamed request ends early
high7.5Oct 8, 2026CVE-2026-107287
Pydantic AI: Excessive resource use when local web fetching converts nested HTML
medium6.5Oct 8, 2026CVE-2026-107289
Pydantic AI: SSRF cloud-metadata blocklist bypass via IPv6 zone identifiers
medium6.8Oct 8, 2026CVE-2026-107290
Pydantic AI: Event loop blocked by quadratic title extraction in `web_fetch`
medium6.5Oct 8, 2026CVE-2026-107291
Pydantic AI OpenTelemetry instrumentation: exception events on tool and agent run spans include content when `include_content=False`
low2.3Oct 8, 2026CVE-2026-107292
Pydantic AI Web chat UI (`Agent.to_web()`, `clai web`): the local chat endpoint does not validate the `Host` header
medium6.4Oct 8, 2026
