# Pydantic AI Harness: stripping ANSI codes can stall every agent run

> A regular expression in Pydantic AI Harness runs in quadratic time on long lines, so one large tool result can freeze the whole process.

- **Severity:** Medium: Real and reproducible, but needs unusual setup, user help or a narrow audience. Plan a fix.
- **Category:** Vulnerability
- **Published by:** Pydantic
- **Disclosed:** 2026-11-18
- **CVE:** CVE-2026-133161
- **CVSS:** 7.5
- **Affects:** Pydantic AI, Pydantic AI Harness, pydantic-ai-harness (PyPI)
- **Research by:** [Daniel Coles](https://github.com/manus-pi), [Jace](https://github.com/manus-use)
- **Primary source:** https://github.com/pydantic/pydantic-ai/security/advisories/GHSA-m4cr-m4qc-9hh3
- **Page:** https://theinjection.dev/items/pydantic-ai-harness-strip-ansi-redos/

CVE-2026-133161 lets attacker-influenced tool output block the event loop in Pydantic AI Harness for tens of seconds to minutes. The flaw needs the non-default strip_ansi setting and is fixed in pydantic-ai-harness 0.70.0.

## What happened

Pydantic published advisory GHSA-m4cr-m4qc-9hh3 on November 18, 2026, after Daniel Coles and Jace reported a denial of service in its agent harness package. The advisory carries CVE-2026-133161, a CVSS 3.1 score of 7.5 and the weakness class CWE-1333. The fix ships in pydantic-ai-harness 0.70.0.

## How it works

The ToolOutputLimits capability strips ANSI escape sequences when strip_ansi is set to True, using a pattern whose runtime grows with the square of the line length. A few hundred kilobytes of tool output carrying many unterminated escape sequences keeps that pattern busy for tens of seconds to minutes. Stripping happens on the event loop before the capability applies its size limits, so those limits never bound the cost.

## Who is affected

Applications on pydantic-ai-harness 0.4.0 through 0.69.0 that set strip_ansi to True are exposed, and the same capability was named OverflowingToolOutput before version 0.13.0. An attacker needs only to place text in something a tool returns: a shell command's output, a file read, a fetched page or an MCP server's reply. Every other request and agent run in that process waits.

## What to do

Upgrade pydantic-ai-harness to 0.70.0 or later. Until then, leave strip_ansi at its default of False, which is the workaround Pydantic gives. Applications pinned to Pydantic AI v1 cannot move the harness past 0.4.0, so they must either move to Pydantic AI v2 with harness 0.70.0 or keep strip_ansi off.

## Quick facts

- **CVE:** CVE-2026-133161
- **CVSS 3.1:** 7.5 (Pydantic)
- **Affected:** pydantic-ai-harness 0.4.0 through 0.69.0, with strip_ansi set to True
- **Fixed in:** pydantic-ai-harness 0.70.0
- **Attack type:** Quadratic regular expression on attacker-influenced tool output (CWE-1333)
- **Found by:** Daniel Coles and Jace
- **Disclosed:** November 18, 2026, by Pydantic

## Questions

### Am I affected by CVE-2026-133161 if I never set strip_ansi?

Applications that never set strip_ansi are not exposed to CVE-2026-133161. The advisory states that the setting defaults to False and that only applications turning it on are affected. Pydantic still lists upgrading pydantic-ai-harness to 0.70.0 as the mitigation, and names leaving the setting at its default as the interim workaround for anyone who cannot upgrade.

### What does CVE-2026-133161 actually break?

CVE-2026-133161 blocks the event loop in whichever process runs Pydantic AI Harness, which delays every other request and agent run sharing it. Pydantic puts the stall at tens of seconds to minutes for a tool result of a few hundred kilobytes. Confidentiality and integrity impact are both rated none in the CVSS vector, so the damage is availability only.

### How do I fix CVE-2026-133161 on Pydantic AI v1?

Pydantic AI v1 cannot take pydantic-ai-harness past 0.4.0, a version the advisory lists as affected. Pydantic gives two options: move the application to Pydantic AI v2 together with pydantic-ai-harness 0.70.0, or stay on v1 and keep strip_ansi at its default of False. Leaving the setting off removes the exposure without any upgrade.

## Sources

1. [Pydantic Advisory](https://github.com/pydantic/pydantic-ai/security/advisories/GHSA-m4cr-m4qc-9hh3)
2. [GitHub Advisory](https://github.com/advisories/GHSA-wvp9-4g4g-qwgm)
