GHSA-chgr-c6px-7xpp: Pyo3 :new_closure` Closures Vulnerability

MODERATE
CWE-362
Published
Advisory Summary

GHSA-chgr-c6px-7xpp is a MODERATE :new_closure` closures vulnerability (CWE-362: Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')) affecting Pyo3 libraries in the crates.io ecosystem. The issue involves :new_closure` closures. Remediation is available by upgrading affected packages to version 0.29.0.

GHSA-chgr-c6px-7xpp at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-chgr-c6px-7xpp
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification CWE-362: Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')
Affected Product Pyo3
Package Ecosystem crates.io
Published Date
Last Updated

How to Fix GHSA-chgr-c6px-7xpp

To remediate this vulnerability, upgrade all affected Pyo3 dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

pyo3 fixed: 0.29.0
Upgrade pyo3 to 0.29.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for pyo3

How to Check if You Are Affected

To determine whether your application is affected by GHSA-chgr-c6px-7xpp, inspect your project dependencies for Pyo3:

inspect dependencies for pyo3

Analyze the terminal output to locate any version of Pyo3 in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.29.0), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-362: Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition'), where the product contains a concurrent code sequence that requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence operating concurrently. In Pyo3, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

`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.

GHSA-chgr-c6px-7xpp Affected Pyo3 Versions

1 component(s)
Fixed Versions:
0.29.0
Product / Package Ecosystem Affected Versions Fixed Version
pyo3
crates.io
< 0.29.0
0.29.0

References

Frequently Asked Questions

What is GHSA-chgr-c6px-7xpp?
GHSA-chgr-c6px-7xpp is a security vulnerability in Pyo3 involving :new_closure` closures under CWE-362: Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition').
Which Pyo3 versions are affected?
Affected versions include releases prior to 0.29.0 across affected packages: pyo3.
What version fixes GHSA-chgr-c6px-7xpp?
Upgrading to 0.29.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is pyo3 affected?
Yes, pyo3 is affected in releases prior to 0.29.0. Upgrade your dependency to 0.29.0 or later.
What CWE is associated with GHSA-chgr-c6px-7xpp?
GHSA-chgr-c6px-7xpp is classified under CWE-362: Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition') (The product contains a concurrent code sequence that requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence operating concurrently.).
How can I check crates.io dependencies for GHSA-chgr-c6px-7xpp?
Run the dependency tree command: 'inspect dependencies for pyo3'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-chgr-c6px-7xpp",
  "modified" : "2026-06-12T20:09:05Z",
  "published" : "2026-06-12T20:09:05Z",
  "aliases" : [ ],
  "summary" : "PyO3 has a missing `Sync` bound on `PyCFunction::new_closure` closures",
  "details" : "`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" : [ {
    "type" : "CVSS_V4",
    "score" : "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"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "pyo3"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.29.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/PyO3/pyo3/pull/6096"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/PyO3/pyo3"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/PyO3/pyo3/releases/tag/v0.29.0"
  }, {
    "type" : "WEB",
    "url" : "https://rustsec.org/advisories/RUSTSEC-2026-0177.html"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-362" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-06-12T20:09:05Z",
    "nvd_published_at" : null
  }
}