GHSA-3gh4-cghq-f8v4: Pip/pydantic-ai-slim vulnerability
Summary
Pydantic AI's OpenTelemetry instrumentation supports InstrumentationSettings(includecontent=False) to exclude message content — user prompts, model completions, tool call arguments and responses — from exported telemetry, so that agents can be monitored without sending sensitive content to the observability backend.
Retry prompts — the feedback messages Pydantic AI sends back to the model when its output fails validation or an output validator raises ModelRetry — were not covered by this setting when they were not associated with a tool call, as with structured output modes that don't use tool calls (e.g. NativeOutput or PromptedOutput) and output validators applied to text output. Their full content was recorded on model request spans even with includecontent=False. Since validation feedback can quote invalid values from the model's response, message content that the setting was configured to withhold could reach the telemetry backend.
Details
Retry prompts without an associated tool call were serialized into span message attributes (such as genai.input.messages and pydanticai.allmessages) as regular text parts, and this path did not apply the includecontent check that every other message part applies. Retry prompts tied to a tool call, and all other message content, were redacted correctly.
Impact
This does not grant an attacker any new access to the agent or its data: the content is only visible to whoever can read the exported telemetry. The exposure matters when traces are exported to a destination whose audience is broader or less trusted than the agent's own data — a third-party observability vendor or a shared backend — which is the scenario includecontent=False exists for. The disclosed content is limited to retry feedback: validation error details, which can quote invalid values from the model's output, or output-validator ModelRetry messages.
Who Is Affected
You are affected if you enabled instrumentation with includecontent=False and your agent can produce retry prompts outside of tool calls: it uses a structured output mode that doesn't rely on tool calls (such as NativeOutput or PromptedOutput), or output validators on text output. You are not affected if you don't set includecontent=False, or if all of your agent's retries come from tool calls (including the default tool-based structured output mode), which were redacted correctly.
Remediation
Upgrade to a patched version; retry prompt content now honors includecontent=False like all other message content. If you rely on this setting, consider reviewing previously exported traces for retry prompt content that should not have been recorded.
Workaround for Unpatched Versions
If you cannot upgrade, scrub or drop the message attributes (genai.input.messages, genai.output.messages, pydanticai.allmessages) in your telemetry pipeline (for example with an OpenTelemetry Collector processor), or use tool-based structured output modes, whose retry feedback honors includecontent=False.
Credits
Reported privately by the University of Sydney Security Research Team (Liyi Zhou, Ziyue Wang, Strick, Maurice, Chenchen Yu), and later independently discovered and reported publicly, with a fix, by @sean-kim05.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
pip/pydantic-ai-slimto a version that resolves this vulnerability.Fixed in 2.27.1 - Upgrade
Upgrade
pip/pydantic-ai-slimto a version that resolves this vulnerability.Fixed in 1.107.4 - Upgrade
Upgrade
pip/pydantic-aito a version that resolves this vulnerability.Fixed in 2.27.1 - Upgrade
Upgrade
pip/pydantic-aito a version that resolves this vulnerability.Fixed in 1.107.4 - Configuration
Scrub or drop the message attributes gen_ai.input.messages, gen_ai.output.messages, and pydantic_ai.all_messages from telemetry.
Telemetry pipeline / OpenTelemetry Collector gen_ai.input.messages, gen_ai.output.messages, pydantic_ai.all_messages = scrub or drop - Configuration
Use a tool-based structured output mode instead of a mode that does not rely on tool calls, such as NativeOutput or PromptedOutput; tool-based retry feedback honors include_content=False.
Pydantic AI structured output mode = tool-based structured output mode - Operational
Review previously exported traces for retry prompt content that should not have been recorded.
Event History
Frequently Asked Questions
Which deployments are affected by this telemetry disclosure?
Deployments using Pydantic AI OpenTelemetry instrumentation with include_content=False are affected when retry prompts are generated without an associated tool call. This includes structured output modes such as NativeOutput or PromptedOutput, and output validators applied to text output.
What content can be exposed despite content exclusion being enabled?
The full retry-prompt content can be exported. Validation feedback may quote invalid values from a model response, allowing content intended to be withheld to reach the observability backend.
How can I determine whether telemetry contains the exposed data?
Inspect exported model request spans for retry-prompt content in message attributes, including gen_ai.input.messages and pydantic_ai.all_messages. Retry prompts serialized as regular text parts on this path did not receive the include_content=False filtering.