CVE-2025-22153: RestrictedPython Try/except* Clauses Could Allow Bypass Vulnerability

HIGH
Advisory Identifier: GHSA-gmj9-h825-chq2
CVSS 7.9
CWE-843
Published
Advisory Summary

CVE-2025-22153 is a HIGH (CVSS 7.9) try/except* clauses could allow bypass vulnerability (CWE-843: Access of Resource Using Incompatible Type ('Type Confusion')) affecting RestrictedPython libraries in the PyPI ecosystem. The issue involves try/except* clauses could allow bypass restrictedpython via type confusion bug in the cpython interpreter. Remediation is available by upgrading affected packages to version 8.0.

CVE-2025-22153 at a Glance

CVE Identifier CVE-2025-22153
GHSA Identifier GHSA-gmj9-h825-chq2
Severity HIGH
CVSS v3.1 Base Score 7.9
CWE Classification CWE-843: Access of Resource Using Incompatible Type ('Type Confusion')
Affected Product RestrictedPython
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 7.9

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:C/C:H/I:H/A:L).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required High (PR:H)
User Interaction None (UI:N)
Scope Changed (S:C)
Confidentiality High (C:H)
Integrity High (I:H)
Availability Low (A:L)

How to Fix CVE-2025-22153

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

RestrictedPython fixed: 8.0
pip install RestrictedPython>=8.0
Verify Direct and Transitive Dependencies

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

pip show RestrictedPython

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2025-22153, inspect your installed packages using pip:

pip show RestrictedPython

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

Note: The pip show RestrictedPython command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-843: Access of Resource Using Incompatible Type ('Type Confusion'), where the product allocates or initializes a resource such as a pointer, object, or variable using one type, but it later accesses that resource using a type that is incompatible with the original type. In RestrictedPython, 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

### Impact Via a type confusion bug in the CPython interpreter when using `try/except*` RestrictedPython could be bypassed. We believe this should be fixed upstream in Python itself until that we remove support for `try/except*` from RestrictedPython. (It has been fixed for some Python versions.) ### Patches Patched in version 8.0 by removing support for `try/except*` clauses ### Workarounds There is no workaround. ### References none

CVE-2025-22153 Affected RestrictedPython Versions

1 component(s)
Fixed Versions:
8.0
Product / Package Ecosystem Affected Versions Fixed Version
RestrictedPython
PyPI
≥ 6.0
< 8.0
8.0

References

Frequently Asked Questions

What is CVE-2025-22153?
CVE-2025-22153 is a security vulnerability in RestrictedPython involving try/except* clauses could allow bypass RestrictedPython via type confusion bug in the CPython interpreter under CWE-843: Access of Resource Using Incompatible Type ('Type Confusion').
Which RestrictedPython versions are affected?
Affected versions include releases prior to 8.0 across affected packages: RestrictedPython.
What version fixes CVE-2025-22153?
Upgrading to 8.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is RestrictedPython affected?
Yes, RestrictedPython is affected in releases prior to 8.0. Upgrade your dependency to 8.0 or later.
What is the CVSS score of CVE-2025-22153?
CVE-2025-22153 has a CVSS v3.1 base score of 7.9 (HIGH) with vector string CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:C/C:H/I:H/A:L.
What CWE is associated with CVE-2025-22153?
CVE-2025-22153 is classified under CWE-843: Access of Resource Using Incompatible Type ('Type Confusion') (The product allocates or initializes a resource such as a pointer, object, or variable using one type, but it later accesses that resource using a type that is incompatible with the original type.).
How can I check PyPI dependencies for CVE-2025-22153?
Run the dependency tree command: 'pip show RestrictedPython'. 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-gmj9-h825-chq2",
  "modified" : "2025-01-23T23:17:21Z",
  "published" : "2025-01-23T17:19:34Z",
  "aliases" : [ "CVE-2025-22153" ],
  "summary" : "try/except* clauses could allow bypass RestrictedPython via type confusion bug in the CPython interpreter",
  "details" : "### Impact\nVia a type confusion bug in the CPython interpreter when using `try/except*` RestrictedPython could be bypassed.\n\nWe believe this should be fixed upstream in Python itself until that we remove support for `try/except*` from RestrictedPython.\n(It has been fixed for some Python versions.)\n\n### Patches\nPatched in version 8.0 by removing support for `try/except*` clauses\n\n### Workarounds\nThere is no workaround.\n\n### References\nnone\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:C/C:H/I:H/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "RestrictedPython"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "6.0"
      }, {
        "fixed" : "8.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/zopefoundation/RestrictedPython/security/advisories/GHSA-gmj9-h825-chq2"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-22153"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/zopefoundation/RestrictedPython/commit/48a92c5bb617a647cffd0dadd4d5cfe626bcdb2f"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/zopefoundation/RestrictedPython"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-843" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2025-01-23T17:19:34Z",
    "nvd_published_at" : "2025-01-23T18:15:33Z"
  }
}