NewApp Monitoring is liveSign up free
AgentbeamBeta
AI agent vulnerability · Pydantic AI

CVE-2026-107286: Pydantic AI: Concurrency-limited models can keep their slot when a streamed request ends early

highCVSS 3.1 7.5GHSA-6fqq-452j-qhrp

In Pydantic AI 2.10.0 through 2.52.x, models wrapped with `ConcurrencyLimitedModel` or `limit_model_concurrency` can permanently lose a concurrency slot when a streamed request releases it from a different task than the one that acquired it. A client that repeatedly starts a stream and disconnects can starve the shared limiter and block later requests. Fixed in `pydantic-ai` and `pydantic-ai-slim` 2.53.0.

Published Oct 8, 2026 · Analysis Oct 21, 2026

What an attacker can do

The built-in limiter uses anyio.CapacityLimiter, which ties each slot to the task that borrowed it. Pydantic AI's streaming path can acquire the slot on the task consuming the stream and run cleanup on another internal task. The limiter refuses that release, so the slot stays occupied after the request ends. Cleanup can raise RuntimeError, and a later request on the borrowing task can fail because it still holds a slot.

Early termination triggers it: stopping iteration, a consumer exception, or cancellation. Fully consuming stream_text() with the default debounce_by=0.1 can also reach the cross-task release, so a completed stream is not safe.

The attacker needs a streaming endpoint exposed to network clients, backed by a long-lived limiter shared across requests. They open streams and disconnect until all slots are gone. The app then stops answering model calls until restart: a denial of service with no data exposure. Agent-level max_concurrency and non-streaming requests are not affected.

Who is affected

Affected: pydantic-ai and pydantic-ai-slim from 2.10.0 up to, but not including, 2.53.0, when a model is wrapped with ConcurrencyLimitedModel or limit_model_concurrency and used for streamed runs.

pip show pydantic-ai pydantic-ai-slim

Search your code for ConcurrencyLimitedModel and limit_model_concurrency.

pydantic-ai

Ecosystem
PyPI
Affected
>= 2.10.0, < 2.53.0
Fixed in
2.53.0
Check
pip show pydantic-ai

pydantic-ai-slim

Ecosystem
PyPI
Affected
>= 2.10.0, < 2.53.0
Fixed in
2.53.0
Check
pip show pydantic-ai-slim

How to fix it

Upgrade to 2.53.0 or later:

pip install --upgrade pydantic-ai

Use pydantic-ai-slim instead if that is what you install. If you cannot upgrade, use the agent-level max_concurrency setting instead of a concurrency-limited model, or avoid streaming runs through a concurrency-limited model.

How to tell if you were hit

Look for RuntimeError raised during stream cleanup, requests that hang waiting for the limiter, and throughput that drops to zero after clients disconnect mid-stream. Concurrency stays pinned at the limit while few requests are active. Restarting the process restores capacity.

Original advisory

From the GitHub Advisory Database (CC BY 4.0).

This issue was posted by Codex Desktop using gpt-6.1-sol on behalf of David.

Summary

Applications that wrap a model with ConcurrencyLimitedModel or limit_model_concurrency can permanently lose shared concurrency capacity when a streamed request releases its slot from a different task than the one that acquired it. This can happen when a stream ends early, and also when a stream is fully consumed using the default stream_text() debouncing.

In an application that exposes an affected streaming endpoint to network clients and shares a long-lived model limiter across requests, a client can repeatedly start a stream and disconnect. The completed requests retain their slots, eventually preventing subsequent requests that share the limiter from proceeding.

Agent-level max_concurrency and non-streaming model requests are not affected by this defect.

Details

The built-in limiter uses anyio.CapacityLimiter, which associates each acquired slot with its borrowing task. Pydantic AI's streaming lifecycle can acquire the slot on the task consuming the stream and run cleanup on another internal task. The limiter rejects that release, so the slot remains occupied even after the request has ended. Cleanup can raise a RuntimeError; a later request on the borrowing task can also fail because that task still holds a slot.

Early termination includes stopping iteration, a consumer exception, and cancellation. Fully consuming stream_text() with its default debounce_by=0.1 can also reach the cross-task release path. Fully consumed streams must therefore not be assumed safe.

Mitigation

Upgrade to a patched release of pydantic-ai or pydantic-ai-slim. If you cannot upgrade yet, use the agent-level max_concurrency setting instead of a concurrency-limited model, or avoid streaming runs through a concurrency-limited model.

Credited to lche511.

Questions

Is a fully consumed stream safe?

Not necessarily. Fully consuming stream_text() with the default debounce_by=0.1 can reach the cross-task release path too.

Does agent-level max_concurrency have this bug?

No. The advisory says agent-level max_concurrency and non-streaming model requests are not affected, which makes it the suggested workaround.

Can this be triggered remotely?

Yes, if your streaming endpoint is reachable by clients and shares a model limiter across requests. No credentials are required by the CVSS vector.

References

How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology

More Pydantic AI vulnerabilities

All Pydantic AI entries