{"id":"GHSA-chgr-c6px-7xpp","aliases":["RUSTSEC-2026-0177"],"status":"published","title":"PyO3 has a missing `Sync` bound on `PyCFunction::new_closure` closures","description":"`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.\n\nThe 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.\n\nPyO3 0.29.0 added a `Sync` bound to close this thread-safety bug.","severity":{"version":"4.0","score":6.3,"vector":"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","level":"medium","from":"ghsa"},"facts":{"in_kev":false,"known_exploited":false,"public_exploit":false,"fix_available":true},"cwes":["CWE-362"],"published":"2026-06-11T12:00:00Z","modified":"2026-09-10T03:51:08Z","fixes":[{"ecosystem":"crates.io","package":"pyo3","fixed_in":["0.29.0"],"sources":["ghsa","osv"]}],"affected":[{"source":"ghsa","ecosystem":"crates.io","package":"pyo3","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"0.29.0"}]}]},{"source":"osv","ecosystem":"crates.io","package":"pyo3","ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"0.29.0"}]}]},{"source":"osv","ecosystem":"crates.io","package":"pyo3","ranges":[{"type":"SEMVER","events":[{"introduced":"0.0.0-0"},{"fixed":"0.29.0"}]}]}],"references":[{"url":"https://github.com/PyO3/pyo3/pull/6096","tags":["web"]},{"url":"https://github.com/PyO3/pyo3/releases/tag/v0.29.0","tags":["web"]},{"url":"https://rustsec.org/advisories/RUSTSEC-2026-0177.html","tags":["web","advisory"]},{"url":"https://github.com/advisories/GHSA-chgr-c6px-7xpp"},{"url":"https://github.com/PyO3/pyo3","tags":["package"]},{"url":"https://crates.io/crates/pyo3","tags":["package"]}],"sources":{"ghsa":[{"id":"GHSA-chgr-c6px-7xpp","title":"PyO3 has a missing `Sync` bound on `PyCFunction::new_closure` closures","description":"`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.\n\nThe 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.\n\nPyO3 0.29.0 added a `Sync` bound to close this thread-safety bug.","status":"published","published":"2026-06-12T20:09:05Z","modified":"2026-06-12T20:09:09Z","cvss":[{"version":"4.0","score":6.3,"vector":"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","level":"medium"}],"cwes":["CWE-362"],"updated_at":"2026-11-02T14:40:27.329706Z"}],"osv":[{"id":"GHSA-chgr-c6px-7xpp","title":"PyO3 has a missing `Sync` bound on `PyCFunction::new_closure` closures","description":"`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.\n\nThe 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.\n\nPyO3 0.29.0 added a `Sync` bound to close this thread-safety bug.","status":"published","published":"2026-06-12T20:09:05Z","modified":"2026-09-10T03:51:08.468075809Z","cvss":[{"version":"4.0","score":6.3,"vector":"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","level":"medium"}],"cwes":["CWE-362"],"updated_at":"2026-11-02T15:46:45.28161Z"},{"id":"RUSTSEC-2026-0177","title":"Missing `Sync` bound on `PyCFunction::new_closure` closures","description":"`PyCFunction::new_closure` (and the temporary `new_closure_bound` complement in\nthe 0.21–0.22 series) required the supplied closure to be `Send + 'static` but\nnot `Sync`. The resulting `PyCFunction` is a Python callable that can be\ninvoked from any Python thread, which means the closure may be called\nconcurrently from multiple threads, and needs a `Sync` bound to prevent\npossible data races.\n\nThe problem exists under all Python versions but is particularly vulnerable under\nthe newer free-threaded Python variant, which do not have serial execution\nimposed by the Global Interpreter Lock. Under releases protected by the GIL,\nthe ability to \"detach\" from the Python interpreter temporarily inside the closure\n(e.g. by `Python::detach`) makes it possible for interleaved and/or concurrent\nexecution of various portions of the closure.\n\nPyO3 0.29.0 added a `Sync` bound to close this thread-safety bug.","status":"published","published":"2026-06-11T12:00:00Z","modified":"2026-06-13T06:30:04.499559191Z","updated_at":"2026-11-02T15:53:40.430679Z"}]}}
