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-107286 Overview
CVE-2026-107286 is a resource management flaw in Pydantic AI, a Python agent framework for building Generative AI applications and workflows. The vulnerability affects versions 2.10.0 through 2.52.x and stems from improper release of concurrency slots when streaming through ConcurrencyLimitedModel or limit_model_concurrency. The underlying anyio.CapacityLimiter ties an acquired slot to the task that borrowed it, but streaming cleanup can run in a different task. As a result, early stream termination, cancellation, consumer exceptions, or complete stream_text() consumption with debounce_by=0.1 can leave capacity occupied. Long-running limiters eventually block all subsequent requests, producing a denial-of-service condition. The flaw is tracked under [CWE-772: Missing Release of Resource after Effective Lifetime].
Critical Impact
Attackers or ordinary traffic patterns can exhaust shared concurrency slots in Pydantic AI, blocking later streamed requests and causing a denial of service for all agents sharing the limiter.
Affected Products
- Pydantic AI 2.10.0 through 2.52.x
- Applications using ConcurrencyLimitedModel
- Applications using limit_model_concurrency with streamed requests
Discovery Timeline
- 2026-10-08 - CVE-2026-107286 published to NVD
- 2026-10-13 - Last updated in NVD database
Technical Details for CVE-2026-107286
Vulnerability Analysis
The defect lives in Pydantic AI's model-level concurrency control for streamed inference requests. When an agent streams a response through ConcurrencyLimitedModel, the framework acquires a slot from an anyio.CapacityLimiter. The limiter binds that slot to the borrowing task identity. Streaming cleanup, however, may execute inside a different task because async generators and context exits can be scheduled onto separate task scopes. The release call therefore does not match the acquiring task, and the slot remains occupied for the lifetime of the limiter.
Trigger patterns include early stream termination, task cancellation, exceptions raised by the consumer, and complete consumption of stream_text() with debounce_by=0.1. Over time, every slot in a long-lived limiter is leaked. Later requests sharing that limiter wait indefinitely for capacity. Agent-level max_concurrency and non-streaming model requests are not affected because they do not rely on the mismatched task-release path.
Root Cause
The root cause is a lifecycle mismatch between resource acquisition and release across async task boundaries. anyio.CapacityLimiter enforces that the task that acquired a slot must release it. Pydantic AI's streaming path routed cleanup through a task that did not match the acquirer, so the release raised RuntimeError or silently failed to free the slot. This classifies as [CWE-772] Missing Release of Resource after Effective Lifetime.
Attack Vector
The vulnerability is reachable over the network through any interface that drives a Pydantic AI agent using a shared ConcurrencyLimitedModel. No authentication or user interaction is required when the agent endpoint is exposed. An attacker opens streamed requests and cancels them, aborts early, or triggers consumer-side exceptions. Each failed stream leaks one slot. Repeating the pattern until the limiter is saturated denies service to all legitimate traffic sharing the limiter.
# Patch excerpt from pydantic_ai_slim/pydantic_ai/agent/__init__.py
# Introduces a ContextVar to track active agent limiters across task boundaries
_ACTIVE_AGENT_LIMITERS: ContextVar[tuple[tuple[int, _concurrency.ConcurrencyLimiter], ...]] = ContextVar(
'pydantic_ai.active_agent_limiters', default=()
)
# Patch excerpt from pydantic_ai_slim/pydantic_ai/_agent_graph.py
# Ensures count_tokens runs inside the correct run context so cleanup
# executes in the same task that acquired the limiter slot
with set_current_run_context(run_context):
counted_usage = await model.count_tokens(messages, model_settings, model_request_parameters)
Source: GitHub Commit 453f19fe
Detection Methods for CVE-2026-107286
Indicators of Compromise
- Pydantic AI logs showing RuntimeError raised from anyio.CapacityLimiter.release during streamed inference cleanup.
- Growing wait queues on ConcurrencyLimitedModel with stable or declining request throughput.
- Streamed agent requests hanging indefinitely while non-streaming requests continue to succeed.
Detection Strategies
- Inventory Python dependencies and flag any Pydantic AI version from 2.10.0 up to but not including 2.53.0.
- Instrument application metrics around limit_model_concurrency to track slot acquire and release counts; a monotonic gap indicates a leak.
- Correlate client-side stream cancellations with server-side limiter saturation events in application logs.
Monitoring Recommendations
- Alert when streamed request latency climbs while CPU and model-provider latency remain flat, which signals limiter starvation.
- Monitor process-level counts of active async tasks tied to Pydantic AI agent runs for unbounded growth.
- Capture tracebacks for every RuntimeError originating in anyio capacity-limiter release paths and forward them to centralized logging.
How to Mitigate CVE-2026-107286
Immediate Actions Required
- Upgrade Pydantic AI to version 2.53.0 or later across all environments that run streamed agent workloads.
- Restart worker processes after upgrading so stale limiters holding leaked slots are discarded.
- Audit application code paths that call stream_text() with debounce_by values to confirm they run against the patched release.
Patch Information
The fix is included in Pydantic AI 2.53.0. The maintainers introduced a ContextVar named pydantic_ai.active_agent_limiters to track active limiters across task boundaries and wrapped token-counting calls in set_current_run_context(run_context) so acquisition and release occur in the same task. See the GitHub Security Advisory GHSA-6fqq-452j-qhrp, the Pull Request #9478, and the v2.53.0 Release Notes.
Workarounds
- Replace ConcurrencyLimitedModel and limit_model_concurrency with agent-level max_concurrency, which is not affected by the leak.
- Switch streamed inference calls to non-streaming equivalents where product requirements allow, since non-streaming requests do not trigger the defect.
- Recreate the CapacityLimiter on a short cadence so leaked slots are reclaimed when the limiter is garbage collected.
# Upgrade Pydantic AI to the patched release
pip install --upgrade 'pydantic-ai>=2.53.0'
# Verify the 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

