CVE-2026-107286
Denial‑of‑service via stuck anyio capacity slots in Pydantic AI streaming (≤2.53).
- CVSS 7.5
- CWE-772
- Resource Management
- Remote
Pydantic AI is a Python agent framework for building applications and workflows with Generative AI. From 2.10.0 until 2.53.0, streamed requests made through ConcurrencyLimitedModel or limit_model_concurrency can retain shared concurrency slots because anyio.CapacityLimiter associates an acquired slot with the borrowing task while streaming cleanup can run in a different task. Early stream termination, cancellation, consumer exceptions, or complete stream_text() consumption with debounce_by=0.1 can therefore leave capacity occupied, eventually preventing later requests that share the long-lived limiter from proceeding and causing a denial of service. Agent-level max_concurrency and non-streaming model requests are not affected. This issue is fixed in version 2.53.0.
- CWE
- CWE-772
- CVSS base score
- 7.5
- Published
- 2026-10-08
- OWASP
- A06 Vulnerable and Outdated Components
- Orthogonal defect classification
- Timing/Serialization
- Code defect classification
- Timing Issues
- Category
- Resource Management
- Subcategory
- Resource Exhaustion
- Accessibility scope
- Remote
- Impact
- Denial of Service (DoS)
- Affected component
- Pydantic AI
- Fixed by upgrading
- Yes
Solution
Upgrade Pydantic AI to version 2.53.0 or later.
Vulnerable code sample
import anyio
from pydantic_ai import ConcurrencyLimitedModel
async def stream_response(prompt: str, limiter: anyio.CapacityLimiter):
# VULNERABLE: acquire slot but release may happen in a different task
await limiter.acquire()
model = ConcurrencyLimitedModel(max_concurrency=limiter)
async for chunk in model.stream_text(prompt):
yield chunk
# release is expected in the streaming cleanup task, which may not runPatched code sample
import anyio
from pydantic_ai import ConcurrencyLimitedModel
async def stream_response(prompt: str, limiter: anyio.CapacityLimiter):
# FIX: use context manager so slot is released in the same task
async with limiter:
model = ConcurrencyLimitedModel(max_concurrency=limiter)
async for chunk in model.stream_text(prompt):
yield chunkPublished 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.
- Fix `RuntimeError` and a leaked slot when streaming through `ConcurrencyLimitedModel` (#9478) (pydantic/pydantic-ai)
pydantic_ai_slim/pydantic_ai/agent/__init__.py,pydantic_ai_slim/pydantic_ai/agent/__init__.py · _PreparedAgentRun.open,pydantic_ai_slim/pydantic_ai/concurrency.py,pydantic_ai_slim/pydantic_ai/concurrency.py · AbstractConcurrencyLimiter.release,pydantic_ai_slim/pydantic_ai/concurrency.py · ConcurrencyLimiter.acquire,pydantic_ai_slim/pydantic_ai/concurrency.py · ConcurrencyLimiter.available_count,pydantic_ai_slim/pydantic_ai/concurrency.py · ConcurrencyLimiter.max_running,pydantic_ai_slim/pydantic_ai/concurrency.py · ConcurrencyLimiter.running_count,pydantic_ai_slim/pydantic_ai/concurrency.py · ConcurrencyLimiter.__init__,pydantic_ai_slim/pydantic_ai/models/concurrency.py,pydantic_ai_slim/pydantic_ai/models/concurrency.py · ConcurrencyLimitedModel.compact_messages,pydantic_ai_slim/pydantic_ai/models/concurrency.py · ConcurrencyLimitedModel.count_tokensand 3 more
Cite this entry
@misc{vaitp:cve2026107286,
title = {{Denial‑of‑service via stuck anyio capacity slots in Pydantic AI streaming (≤2.53).}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-107286},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-107286/}}
}
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 ::
