CVE-2025-22153: RestrictedPython Try/except* Clauses Could Allow Bypass Vulnerability
HIGHCVE-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
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).
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.
pip install RestrictedPython>=8.0
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
CVE-2025-22153 Affected RestrictedPython Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
RestrictedPython
|
PyPI |
≥ 6.0
< 8.0
|
8.0
|
References
Frequently Asked Questions
What is CVE-2025-22153?
Which RestrictedPython versions are affected?
What version fixes CVE-2025-22153?
Is RestrictedPython affected?
What is the CVSS score of CVE-2025-22153?
What CWE is associated with CVE-2025-22153?
How can I check PyPI dependencies for CVE-2025-22153?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"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"
}
}