CVE-2026-25580: Pydantic AI Affected by Server-Side Request Forgery (SSRF) in URL Download Handling

Published Feb 6, 2026
·
Updated

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.toweb or clai web to serve a chat interface - VercelAIAdapter for Vercel AI SDK integration - AGUIAdapter or Agent.toagui 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 downloaditem() 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.toweb 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.toagui - 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 forcedownload='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 pydanticai 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", forcedownload='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:

python import ipaddress import socket from urllib.parse import urlparse

from pydanticai import Agent, ModelMessage, ModelRequest from pydanticai.messages import AudioUrl, DocumentUrl, ImageUrl, VideoUrl

def isprivateurl(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 ipstr = socket.gethostbyname(hostname) ip = ipaddress.ipaddress(ipstr)

# Block private, loopback, and link-local addresses return ip.isprivate or ip.isloopback or ip.islinklocal except (socket.gaierror, ValueError): return True # DNS resolution failed, block it

def filterprivateurls(messages: list[ModelMessage]) -> list[ModelMessage]: """Remove URL parts that target private/internal addresses.""" urltypes = (ImageUrl, AudioUrl, VideoUrl, DocumentUrl) filtered = [] for msg in messages: if isinstance(msg, ModelRequest): safeparts = [ part for part in msg.parts if not (isinstance(part, urltypes) and isprivateurl(part.url)) ] if safeparts: filtered.append(ModelRequest(parts=safeparts)) else: filtered.append(msg) return filtered

Apply the filter to your agent agent = Agent('openai:gpt-5', historyprocessors=[filterprivateurls])

Technical Details of the Fix

The fix introduces a new ssrf.py module with comprehensive protection:

1. Protocol validation: Only http:// and https:// allowed 2. DNS resolution before request: Prevents DNS rebinding attacks 3. 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) 4. Cloud metadata always blocked: 169.254.169.254, fd00:ec2::254, 100.100.100.200 5. Safe redirect handling: Each redirect validated before following (max 10)

Other sources

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.

MITRE

Affected Software

3 affected componentsFixes available
pip/pydantic-ai-slim>=0.0.26<1.56.0
1.56.0
pip/pydantic-ai>=0.0.26<1.56.0
1.56.0
Pydantic Pydantic Ai Python>=0.0.26<1.56.0

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade pip/pydantic-ai-slim to a version that resolves this vulnerability.

    Fixed in 1.56.0
  2. Upgrade

    Upgrade pip/pydantic-ai to a version that resolves this vulnerability.

    Fixed in 1.56.0
  3. Upgrade

    Upgrade pydantic ai to a version that resolves this vulnerability.

    Fixed in 1.56.0
  4. Configuration

    If you must access local/private network resources in a fully trusted internal environment, set force_download='allow-local' (note: cloud metadata endpoints 169.254.169.254, fd00:ec2::254, 100.100.100.200 are always blocked even with allow-local).

    Pydantic AI ImageUrl force_download = 'allow-local'
  5. Compensating control

    If you cannot upgrade, use a history processor to filter out user-supplied URLs targeting local/private addresses in message history (e.g., block http://127.0.0.1, localhost, and private ranges 10.x.x.x, 172.16.x.x–172.31.x.x, 192.168.x.x; also block cloud metadata endpoints 169.254.0.0/16, fd00:ec2::254, and 100.64.0.0/10; validate protocol is only http:// and https://, resolve hostnames before requesting to prevent DNS rebinding, and validate each redirect target with a maximum of 10).

Event History

Feb 6, 2026
Advisory Published
via GitHub·06:32 PM
Data Sourced
via GitHub·06:32 PM
DescriptionSeverityWeaknessAffected Software
CVE Published
via MITRE·09:01 PM
Data Sourced
via MITRE·09:01 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·09:16 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·09:16 PM
RemedyAffected Software
Feb 9, 2026
Data Sourced
via Red Hat·11:05 AM
DescriptionSeverityAffected Software
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2026-25580?

CVE-2026-25580 is classified as a critical vulnerability due to its potential for Server-Side Request Forgery (SSRF) attacks.

2

How do I fix CVE-2026-25580?

To remediate CVE-2026-25580, upgrade to version 1.56.0 of the pydantic-ai or pydantic-ai-slim packages.

3

What types of applications are affected by CVE-2026-25580?

Applications that use Pydantic AI's URL download functionality and accept input from untrusted sources are affected by CVE-2026-25580.

4

What can attackers do with CVE-2026-25580?

Attackers can exploit CVE-2026-25580 to make the server perform unauthorized HTTP requests to internal network resources.

5

Is CVE-2026-25580 present in older versions of the software?

Yes, CVE-2026-25580 affects versions of pydantic-ai and pydantic-ai-slim prior to 1.56.0.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203