Pydantic AI SSRF in deserialized tool results
pydantic-ai · pydantic-ai-slim
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| pydantic pydantic-ai |
| No fix yet |
| pydantic pydantic-ai |
| No fix yet |
| pydantic pydantic-ai-slim |
| No fix yet |
| pydantic pydantic-ai-slim |
|
pydantic-ai · pydantic-ai-slim
| Product | Affected | Fixed in |
|---|---|---|
| pydantic pydantic-ai |
| No fix yet |
| pydantic pydantic-ai |
| No fix yet |
| pydantic pydantic-ai-slim |
| No fix yet |
| pydantic pydantic-ai-slim |
|
| No fix yet |
When message history is serialized and loaded again, a tool result that contains a JSON object in the serialized shape of one of Pydantic AI's file types is rebuilt as that file. A third party who controls data a tool returns, such as a record that an MCP server or a function tool returns from an external system, can use this to make the application download a URL on its local network, or make the model provider read an s3:// object or uploaded file with the application's credentials. Applications are affected when tool results can contain third-party data, message history containing those results is serialized and loaded again (stored history, history a UI adapter holds on the server, or Temporal, DBOS or Prefect durable execution), and the model is one Pydantic AI downloads files for, one that honors force_download, or one whose provider resolves non-HTTP file URLs or uploaded files. History that a client submits through the Vercel AI or AG-UI adapter in the default mode is not affected. The issue is fixed in pydantic-ai and pydantic-ai-slim 1.107.10 and 2.66.0.
From the CVE record · Pydantic
In pydantic-ai and pydantic-ai-slim, a tool result shaped like a Pydantic AI file can be rebuilt as that file when message history is serialized and loaded again. A third party controlling data returned by a tool can cause an application to download a local-network URL or cause a model provider to read an S3 object or uploaded file using the application's credentials. This requires third-party data in tool results, serialization and reloading of the resulting history, and a model or provider that downloads or resolves the file; client-submitted history through the Vercel AI or AG-UI adapter in default mode is not affected.
Engineers running pydantic-ai or pydantic-ai-slim before the fixed releases 1.107.10 and 2.66.0 should check whether their applications meet these conditions.