According to technical analyses and security advisories, two high-severity regular-expression denial of service (ReDoS) vulnerabilities were recently disclosed within the safety mechanisms of the Pydantic AI ecosystem, specifically targeting components designed to protect applications from malicious or malformed tool outputs.
High-Severity Advisories in Pydantic AI Harness
The security notices, tracked as GHSA-m4cr-m4qc-9hh3 and GHSA-5m5q-5qj4-gx9h, landed on November 17, 2026. They targeted pydantic-ai-harness version 0.70.0, which shipped as part of the broader Pydantic AI v2.70.0 release. According to published documentation, the first vulnerability resided inside the ToolOutputLimits capability when handling ANSI-escape sequence stripping via strip_ansi=True. A pattern utilized there required quadratic time relative to line length, allowing a few hundred kilobytes of unterminated escape sequences to monopolize the event loop. The second vulnerability affected the default JWT pattern inside redact_secrets and secret_data(), causing catastrophic backtracking when scanning attacker-influenced text. Subsequent checks in version v2.71.0 confirmed that no further regressions or modifications occurred regarding these specific advisories.

The Mechanics of Nested Quantifier Failures
Both vulnerabilities stem from a classic regex anti-pattern involving nested or overlapping quantifiers. When a pattern permits multiple equivalent ways to parse the same input stretch—such as a quantifier placed inside another quantifier—the regex engine attempts exhaustive backtracking combinations. As documented in independent reproductions, input sizes as small as twenty to thirty bytes can trigger multi-second timeouts or exponential execution spikes. Because sanitization tasks like token redaction and escape stripping rely heavily on fuzzy matching, developers frequently introduce leniency that inadvertently invites these ambiguous, high-cost structures.
Broader Implications for Agent Guardrails
The discovery of these vulnerabilities highlights a paradoxical risk in modern AI architectures: the very code deployed to protect systems can inadvertently serve as an attack surface. Agent runtimes, API gateways, and guardrails frequently rely on regular expressions to sanitize tool responses, headers, and files read from external services before passing them back into language models or logging sinks. When these boundaries process attacker-influenced data, an unoptimized pattern can easily become a vector for denial-of-service disruptions, stalling event loops without requiring massive payloads. This issue extends well beyond any single library or framework, emphasizing that security audits must scrutinize defensive parsing logic just as rigorously as core business code. Developers building automated agents, Model Context Protocol gateways, or custom safety wrappers should audit their validation layers for nested quantifiers, replacing greedy matching patterns with linear alternatives like negated character classes, atomic groups, or hand-written scanners.

Validating Fixes Through Local Reproduction
To better understand how these regex structures fail, developer demonstrations utilizing only the Python 3 standard library contrast vulnerable regex shapes against fixed, linear patterns. These implementations involve replacing nested escape-body quantifiers with single-pass expressions such as \x1b\[[0-9;]*m and matching JWT segments explicitly rather than relying on nested repetition. Enforcing strict subprocess timeouts during testing ensures that runaway regex engines can be terminated cleanly, offering a practical method for engineering teams to verify their own regex safety margins before deployment.
Editorial graphic and headline text by Signal Titans.
Source: Two ReDoS Bugs Were Hiding in Pydantic AI's Own Safety Features · GitHub – themsquared/redos-guardrail-demo · GitHub

Leave a Reply