Pydantic AI is a Python agent framework for building applications and workflows with Generative AI. From 0.0.26 to before 1.56.0, aServer-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. This vulnerability is fixed in 1.56.0.
Pydantic AI Affected by Server-Side Request Forgery (SSRF) in URL Download Handling
Problem type
Affected products
pydantic
>= 0.0.26, < 1.56.0 - AFFECTED
References
https://github.com/pydantic/pydantic-ai/security/advisories/GHSA-2jrp-274c-jhv3
https://github.com/pydantic/pydantic-ai/commit/d398bc9d39aecca6530fa7486a410d5cce936301
GitHub Security Advisories
GHSA-2jrp-274c-jhv3
Pydantic AI has Server-Side Request Forgery (SSRF) in URL Download Handling
https://github.com/advisories/GHSA-2jrp-274c-jhv3Summary
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_weborclai webto serve a chat interfaceVercelAIAdapterfor Vercel AI SDK integrationAGUIAdapterorAgent.to_ag_uifor 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_weborclai 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
AGUIAdapterorAgent.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:
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)
https://github.com/pydantic/pydantic-ai/security/advisories/GHSA-2jrp-274c-jhv3
https://github.com/pydantic/pydantic-ai/commit/d398bc9d39aecca6530fa7486a410d5cce936301
https://nvd.nist.gov/vuln/detail/CVE-2026-25580
https://github.com/advisories/GHSA-2jrp-274c-jhv3
JSON source
https://cveawg.mitre.org/api/cve/CVE-2026-25580Click to expand
{
"dataType": "CVE_RECORD",
"dataVersion": "5.2",
"cveMetadata": {
"cveId": "CVE-2026-25580",
"assignerOrgId": "a0819718-46f1-4df5-94e2-005712e83aaa",
"assignerShortName": "GitHub_M",
"dateUpdated": "2026-02-06T21:01:38.035Z",
"dateReserved": "2026-02-03T01:02:46.715Z",
"datePublished": "2026-02-06T21:01:38.035Z",
"state": "PUBLISHED"
},
"containers": {
"cna": {
"providerMetadata": {
"orgId": "a0819718-46f1-4df5-94e2-005712e83aaa",
"shortName": "GitHub_M",
"dateUpdated": "2026-02-06T21:01:38.035Z"
},
"title": "Pydantic AI Affected by Server-Side Request Forgery (SSRF) in URL Download Handling",
"descriptions": [
{
"lang": "en",
"value": "Pydantic AI is a Python agent framework for building applications and workflows with Generative AI. From 0.0.26 to before 1.56.0, aServer-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. This vulnerability is fixed in 1.56.0."
}
],
"affected": [
{
"vendor": "pydantic",
"product": "pydantic-ai",
"versions": [
{
"version": ">= 0.0.26, < 1.56.0",
"status": "affected"
}
]
}
],
"problemTypes": [
{
"descriptions": [
{
"lang": "en",
"description": "CWE-918: Server-Side Request Forgery (SSRF)",
"cweId": "CWE-918",
"type": "CWE"
}
]
}
],
"references": [
{
"url": "https://github.com/pydantic/pydantic-ai/security/advisories/GHSA-2jrp-274c-jhv3",
"name": "https://github.com/pydantic/pydantic-ai/security/advisories/GHSA-2jrp-274c-jhv3",
"tags": [
"x_refsource_CONFIRM"
]
},
{
"url": "https://github.com/pydantic/pydantic-ai/commit/d398bc9d39aecca6530fa7486a410d5cce936301",
"name": "https://github.com/pydantic/pydantic-ai/commit/d398bc9d39aecca6530fa7486a410d5cce936301",
"tags": [
"x_refsource_MISC"
]
}
],
"metrics": [
{
"cvssV3_1": {
"version": "3.1",
"vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:N/A:N",
"attackVector": "NETWORK",
"attackComplexity": "LOW",
"privilegesRequired": "NONE",
"userInteraction": "NONE",
"scope": "CHANGED",
"confidentialityImpact": "HIGH",
"integrityImpact": "NONE",
"availabilityImpact": "NONE",
"baseScore": 8.6,
"baseSeverity": "HIGH"
}
}
]
}
}
}