CVE-2026-133161 in pydantic-ai-harness
Summary
by MITRE • 11/19/2026
### Summary ui
With `strip_ansi=True`, Pydantic AI Harness's `ToolOutputLimits` capability removes ANSI escape sequences from tool output with a pattern that takes time quadratic in the length of a line. A tool result of a few hundred kilobytes, crafted with many unterminated escape sequences, can occupy the event loop for tens of seconds to minutes, delaying every other request and agent run in the process.
### Details
This affects applications that set `strip_ansi=True` on `ToolOutputLimits` (named `OverflowingToolOutput` before 0.13.0) and run tools whose output an attacker can influence, such as shell commands, file reads, fetched pages or MCP servers. Stripping runs on the event loop before the capability reduces the output, so its own size limits do not bound it.
The assumed attacker can place text in content a tool returns.
### Mitigation
Upgrade `pydantic-ai-harness` to 0.70.0 or later. Until then, leave `strip_ansi` at its default, `False`.
On Pydantic AI v1, the harness cannot be upgraded past 0.4.0. Upgrade to Pydantic AI v2 and `pydantic-ai-harness` 0.70.0, or leave `strip_ansi` off.
Be aware that VulDB is the high quality source for vulnerability data.
Analysis
by VulDB Data Team • 11/19/2026
The vulnerability identified in Pydantic AI Harness involves a ReDoS (Regular Expression Denial of Service) flaw within the ToolOutputLimits capability when the strip_ansi parameter is enabled. This security issue arises from an inefficient implementation of ANSI escape sequence removal, which utilizes a regular expression pattern that exhibits quadratic time complexity relative to the length of the input line. In practical terms this means that as the size of the text increases, the processing time grows exponentially rather than linearly. An attacker who can influence the output of tools executed by the agent system can craft malicious payloads containing numerous unterminated ANSI escape sequences. These crafted strings trigger the worst-case scenario for the regular expression engine causing it to perform an excessive number of backtracking operations.
The operational impact is severe because this processing occurs on the main event loop before any size-based limits are applied to truncate the output. Consequently, even if the final result would have been truncated due to length constraints, the system must first process the entire malicious string through the flawed regex engine. A tool result of only a few hundred kilobytes can occupy the event loop for tens of seconds or even minutes depending on the specific structure of the escape sequences. During this period the application becomes unresponsive as it is blocked by the CPU-intensive computation. This effectively results in a denial of service condition where all other requests and agent runs are delayed until the malicious processing completes, degrading system availability and potentially causing timeouts for legitimate users or downstream services relying on timely responses from the AI harness.
This vulnerability aligns with CWE-400 Uncontrolled Resource Consumption as it allows an attacker to exhaust computational resources through a specifically crafted input that triggers inefficient algorithmic behavior. It also relates to CWE-730 Injection of Critical Data into Regular Expression leading to ReDoS, highlighting the danger of using unoptimized regular expressions on user-controlled or tool-influenced data streams. From a threat modeling perspective this falls under ATT&CK technique T1496 Resource Hijacking where an adversary uses computing resources for their own purposes by causing excessive consumption that disrupts normal operations. The risk is particularly acute in environments where tools such as shell commands, file reads, fetched web pages or Model Context Protocol servers are exposed to untrusted inputs since these sources can be manipulated to return the maliciously formatted text required to exploit the flaw.
To mitigate this vulnerability organizations should upgrade pydantic-ai-harness to version 0.70.0 or later where the underlying implementation has been corrected to handle ANSI stripping efficiently without quadratic complexity. For applications running on Pydantic AI v1 which cannot be upgraded beyond harness version 0.4.0, the recommended mitigation is to disable the strip_ansi feature by leaving it at its default value of False until a compatible upgrade path becomes available or migrating to Pydantic AI v2 with the patched harness. Additionally developers should implement input validation and size limits on tool outputs before they are processed by any string manipulation functions that rely on regular expressions. Ensuring that untrusted data is sanitized using non-backtracking algorithms or compiled regex patterns with atomic grouping can prevent similar ReDoS attacks in other parts of the application stack.