CVE-2026-107287
Excessive CPU/memory from deep HTML-to-Markdown conversion in Pydantic AI web_fetch_tool.
- CVSS 6.5
- CWE-400
- Resource Management
- Local
Pydantic AI is a Python agent framework for building applications and workflows with Generative AI. From 1.77.0 until 1.107.7 and 2.52.0, the local web_fetch_tool and the WebFetch local fallback can consume excessive CPU and memory during HTML-to-Markdown conversion of attacker-controlled HTML containing deeply nested block elements. Conversion repeatedly reprocesses accumulated text and can greatly expand intermediate output before the returned-content limit is applied, allowing a model-directed fetch to delay other work in the process. Provider-native web fetching is not affected. This issue is fixed in versions 1.107.7 and 2.52.0.
- CWE
- CWE-400
- CVSS base score
- 6.5
- Published
- 2026-10-08
- OWASP
- A04 Insecure Design
- Orthogonal defect classification
- Timing/Serialization
- Code defect classification
- Timing Issues
- Category
- Resource Management
- Subcategory
- Resource Exhaustion
- Accessibility scope
- Local
- Impact
- Denial of Service (DoS)
- Affected component
- Pydantic AI
- Fixed by upgrading
- Yes
Solution
Upgrade Pydantic AI to ≥ 1.107.7 (or ≥ 2.52.0 for the 2.x line).
Vulnerable code sample
import sys
from pydantic_ai.tools import WebFetchTool
def fetch_and_convert(url: str) -> str:
# VULNERABLE: unlimited HTML‑to‑Markdown recursion can explode on crafted HTML
html = WebFetchTool().fetch(url) # returns raw HTML string
# The library internally calls html2text without limits, causing resource exhaustion
markdown = html2text.html2text(html) # type: ignore[name-defined]
return markdown[:10000] # truncate only final output, not intermediate expansionPatched code sample
import sys
from pydantic_ai.tools import WebFetchTool
import html2text
def fetch_and_convert(url: str) -> str:
# FIX: bound HTML‑to‑Markdown conversion to prevent exponential growth
html = WebFetchTool().fetch(url) # returns raw HTML string
# Configure html2text with a safe maximum output length
parser = html2text.HTML2Text()
parser.body_width = 0
parser.unicode_snob = True
parser.ignore_links = True
parser.single_line_break = True
parser.wrap_links = False
# Limit intermediate output size to avoid explosion
parser.max_output_len = 50000 # arbitrary safe cap
markdown = parser.handle(html)
return markdown[:10000]Published fix
Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.
- Bound HTML conversion cost in `web_fetch` (#8984) (pydantic/pydantic-ai)
pydantic_ai_slim/pydantic_ai/common_tools/web_fetch.py,pydantic_ai_slim/pydantic_ai/common_tools/web_fetch.py · WebFetchLocalTool.__call__,pydantic_ai_slim/pydantic_ai/common_tools/web_fetch.py · _convert_html,pydantic_ai_slim/pydantic_ai/common_tools/web_fetch.py · _MarkdownConverter.convert_li,pydantic_ai_slim/pydantic_ai/common_tools/web_fetch.py · _MarkdownConverter.__init__ - Backport bounded `web_fetch` HTML conversion to v1 (#8985) (pydantic/pydantic-ai)
pydantic_ai_slim/pydantic_ai/common_tools/web_fetch.py,pydantic_ai_slim/pydantic_ai/common_tools/web_fetch.py · WebFetchLocalTool.__call__,pydantic_ai_slim/pydantic_ai/common_tools/web_fetch.py · _convert_html,pydantic_ai_slim/pydantic_ai/common_tools/web_fetch.py · _MarkdownConverter.convert_li,pydantic_ai_slim/pydantic_ai/common_tools/web_fetch.py · _MarkdownConverter.__init__
Cite this entry
@misc{vaitp:cve2026107287,
title = {{Excessive CPU/memory from deep HTML-to-Markdown conversion in Pydantic AI web_fetch_tool.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-107287},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-107287/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.
The supreme art of war is to subdue the enemy without fighting.
Sun Tzu – “The Art of War”
:: Shaping the future through research and ingenuity ::
