PyO3 has a missing `Sync` bound on `PyCFunction::new_closure` closures

説明

PyCFunction::new_closure (and the temporary new_closure_bound complement in the 0.21–0.22 series) required the supplied closure to be Send + 'static but not Sync. The resulting PyCFunction is a Python callable that can be invoked from any Python thread, which means the closure may be called concurrently from multiple threads, and needs a Sync bound to prevent possible data races.

The problem exists under all Python versions but is particularly vulnerable under the newer free-threaded Python variant, which do not have serial execution imposed by the Global Interpreter Lock. Under releases protected by the GIL, the ability to "detach" from the Python interpreter temporarily inside the closure (e.g. by Python::detach) makes it possible for interleaved and/or concurrent execution of various portions of the closure.

PyO3 0.29.0 added a Sync bound to close this thread-safety bug.

基本情報

タイプ
reviewed
深刻度
medium
GitHub 上のアドバイザリ
アドバイザリを開く ↗
リポジトリのアドバイザリ
ソースコード
ソースを見る ↗
公開(アドバイザリ)
2026-06-12 20:09:05 UTC
更新
2026-06-12 20:09:09 UTC
GitHub レビュー済み
2026-06-12 20:09:05 UTC

CVSS Scores

Base score Version Severity Vector
6.3 4.0
CVSS:4.0/AV:N/AC:H/AT:P/PR:N/UI:N/VC:L/VI:L/VA:L/SC:N/SI:N/SA:N クリックして展開
攻撃ベクター (AV:N)
インターネットや社内 WAN など、ルーティングされたネットワーク越しに遠隔から踏み台にしうる。
攻撃の複雑さ (AC:H)
タイミング・負荷・周辺設定に左右され、安定して成功させにくい。
攻撃要件 (AT:P)
特定のミドルウェア状態やデータ配置など、追加前提が揃わないと成立しない。
必要な権限 (PR:N)
昇格やログインなしで踏み台にしうる。
ユーザーの関与 (UI:N)
被害者の操作なしでも攻撃が完結しうる。
脆弱システムの機密性への影響 (VC:L)
一部のデータや属性が漏えいしうるが、事業全体としては限定的。
脆弱システムの完全性への影響 (VI:L)
レコードや設定の一部が歪められうるが、システム全体の信頼は保たれやすい。
脆弱システムの可用性への影響 (VA:L)
遅延や断続的障害、一部機能の停止など、運用で吸収しうる範囲。
後続システムの機密性への影響 (SC:N)
脆弱点を経由して下流の機微情報が読まれうる余地はほとんどない。
後続システムの完全性への影響 (SI:N)
下流の記録や設定が歪められる局面はほとんど想定されない。
後続システムの可用性への影響 (SA:N)
下流サービスが止まるほどの影響は想定しにくい。

Identifiers

Type Value
GHSA GHSA-chgr-c6px-7xpp ↗

CWEs

CWE id Name
CWE-362 Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')

Affected packages (1)

Vulnerable version ranges and first patched releases as published by GitHub.

Ecosystem Package Vulnerable range First patched Vulnerable functions
rust pyo3 < 0.29.0 0.29.0

References

cvelogic Threat Intelligence