Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB
CVE-2026-107287 Overview
CVE-2026-107287 is a resource exhaustion vulnerability in Pydantic AI, a Python agent framework for building Generative AI applications and workflows. The flaw affects the local web_fetch_tool and the WebFetch local fallback across versions 1.77.0 through 1.107.6, and 2.0.0 through 2.51.x. Attacker-controlled HTML containing deeply nested block elements triggers excessive CPU and memory consumption during HTML-to-Markdown conversion. The conversion routine repeatedly reprocesses accumulated text, expanding intermediate output before the returned-content limit applies. Provider-native web fetching is unaffected. Pydantic resolved the issue in versions 1.107.7 and 2.52.0.
Critical Impact
A model-directed fetch of malicious HTML can stall the Pydantic AI process, delaying other agent work and causing denial of service on the host.
Affected Products
- Pydantic AI versions 1.77.0 through 1.107.6 (Python)
- Pydantic AI versions 2.0.0 through 2.51.x (Python)
- Deployments using the local web_fetch_tool or WebFetch local fallback
Discovery Timeline
- 2026-10-08 - CVE-2026-107287 published to NVD
- 2026-10-14 - Last updated in NVD database
Technical Details for CVE-2026-107287
Vulnerability Analysis
The vulnerability resides in the HTML-to-Markdown conversion path invoked by Pydantic AI's local web fetching tools. When the agent fetches a page under model direction, the local pipeline parses the HTML and converts it to Markdown before truncating the output to the configured content limit. For HTML containing deeply nested block elements, the converter walks and re-walks accumulated text at each nesting level. Intermediate string allocations grow super-linearly with nesting depth, consuming CPU cycles and memory until the operation completes or the process is starved. The returned-content size cap is applied only after conversion, so it does not bound the work performed during parsing. This classifies as a resource exhaustion issue tracked under [CWE-400].
Root Cause
The root cause is unbounded algorithmic work inside the HTML-to-Markdown converter. The function repeatedly reprocesses previously generated text as it ascends the nested block structure. There is no incremental size guard inside the conversion loop, so attacker-controlled nesting dictates runtime and memory usage. The content-length limit sits outside the hot loop and cannot interrupt pathological inputs.
Attack Vector
Exploitation requires the agent to fetch an attacker-controlled URL using the local web_fetch_tool or the WebFetch local fallback. An attacker hosts an HTML document with thousands of nested <div>, <section>, or similar block elements. When the model is prompted or coerced to retrieve that URL, the Pydantic AI process spends excessive CPU and memory converting the payload. Concurrent agent requests on the same process are delayed or blocked, producing a denial-of-service condition. Provider-native fetchers that bypass the local converter are not affected. See the Pydantic AI Security Advisory GHSA-v36g-jcw9-x7cw for technical details.
Detection Methods for CVE-2026-107287
Indicators of Compromise
- Pydantic AI worker processes showing sustained high CPU usage correlated with outbound HTTP fetches initiated by the local web_fetch_tool.
- Memory growth in agent processes immediately following a model-directed URL fetch, without a corresponding increase in returned content size.
- Agent request latency spikes or timeouts affecting multiple in-flight tool calls on the same process.
Detection Strategies
- Instrument the local web fetch path to log fetched URL, response size, conversion duration, and peak resident memory per call.
- Alert when HTML-to-Markdown conversion time exceeds a baseline threshold or when conversion duration greatly exceeds network fetch time.
- Review agent audit logs for model-directed fetches to low-reputation or newly observed domains preceding resource spikes.
Monitoring Recommendations
- Track Pydantic AI package versions across environments and flag any host still running a version earlier than 1.107.7 or 2.52.0.
- Monitor process-level CPU, memory, and thread utilization for services hosting Pydantic AI agents and page on sustained saturation.
- Capture outbound URLs requested by the agent and correlate them with downstream performance metrics for anomaly review.
How to Mitigate CVE-2026-107287
Immediate Actions Required
- Upgrade Pydantic AI to version 1.107.7 or 2.52.0 across all environments running agents that use local web fetching.
- Audit agent configurations to identify use of the local web_fetch_tool and the WebFetch local fallback.
- Where feasible, switch to provider-native web fetching, which is not affected by this vulnerability.
Patch Information
Pydantic released fixes in Pydantic AI Release v1.107.7 and Pydantic AI Release v2.52.0. The code changes are available in Pydantic AI Pull Request #8984 and Pydantic AI Pull Request #8985, with corresponding commits 2b247add and 2fd38792.
Workarounds
- Restrict the set of URLs that agents can fetch using an allowlist of trusted domains until patching is complete.
- Run agent processes with strict CPU and memory cgroup limits so a single malicious fetch cannot starve other work.
- Place a reverse proxy or fetch sidecar in front of the agent that rejects HTML responses exceeding a maximum nesting depth.
- Enforce per-request timeouts around tool invocations so stalled conversions are cancelled before cascading into service degradation.
# Configuration example
pip install --upgrade "pydantic-ai>=1.107.7,<2.0.0"
# or, for the 2.x line
pip install --upgrade "pydantic-ai>=2.52.0"
# Verify installed version
python -c "import pydantic_ai; print(pydantic_ai.__version__)"
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB

