GHSA-6fqq-452j-qhrp

Suggest an improvement
Source
https://github.com/advisories/GHSA-6fqq-452j-qhrp
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/10/GHSA-6fqq-452j-qhrp/GHSA-6fqq-452j-qhrp.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-6fqq-452j-qhrp
Aliases
Published
2026-10-08T19:42:55Z
Modified
2026-10-08T20:00:05Z
Severity
  • 7.5 (High) CVSS_V3 - CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H CVSS Calculator
Summary
Pydantic AI: Concurrency-limited models can keep their slot when a streamed request ends early
Details

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.

Database specific
{
    "cwe_ids": [
        "CWE-772"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2026-10-08T19:42:55Z",
    "nvd_published_at": "2026-10-08T15:17:40Z",
    "severity": "HIGH"
}
References

Affected packages

PyPI / pydantic-ai

Package

Name
pydantic-ai
View open source insights on deps.dev
Purl
pkg:pypi/pydantic-ai

Affected ranges

Type
ECOSYSTEM
Events
Introduced
2.10.0
Fixed
2.53.0

Affected versions

2.*
2.10.0
2.11.0
2.12.0
2.13.0
2.14.0
2.14.1
2.15.0
2.16.0
2.17.0
2.18.0
2.19.0
2.20.0
2.21.0
2.22.0
2.23.0
2.24.0
2.25.0
2.26.0
2.27.0
2.27.1
2.28.0
2.29.0
2.30.0
2.31.0
2.31.1
2.32.0
2.32.1
2.32.2
2.33.0
2.34.0
2.35.0
2.35.1
2.35.3
2.36.0
2.37.0
2.38.0
2.39.0
2.40.0
2.41.0
2.42.0
2.43.0
2.44.0
2.45.0
2.46.0
2.47.0
2.48.0
2.49.0
2.50.0
2.51.0
2.52.0

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/10/GHSA-6fqq-452j-qhrp/GHSA-6fqq-452j-qhrp.json"

PyPI / pydantic-ai-slim

Package

Name
pydantic-ai-slim
View open source insights on deps.dev
Purl
pkg:pypi/pydantic-ai-slim

Affected ranges

Type
ECOSYSTEM
Events
Introduced
2.10.0
Fixed
2.53.0

Affected versions

2.*
2.10.0
2.11.0
2.12.0
2.13.0
2.14.0
2.14.1
2.15.0
2.16.0
2.17.0
2.18.0
2.19.0
2.20.0
2.21.0
2.22.0
2.23.0
2.24.0
2.25.0
2.26.0
2.27.0
2.27.1
2.28.0
2.29.0
2.30.0
2.31.0
2.31.1
2.32.0
2.32.1
2.32.2
2.33.0
2.34.0
2.35.0
2.35.1
2.35.3
2.36.0
2.37.0
2.38.0
2.39.0
2.40.0
2.41.0
2.42.0
2.43.0
2.44.0
2.45.0
2.46.0
2.47.0
2.48.0
2.49.0
2.50.0
2.51.0
2.52.0

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/10/GHSA-6fqq-452j-qhrp/GHSA-6fqq-452j-qhrp.json"