RestrictedPython Type Confusion Vulnerability Allowing Bypass of Sandbox Restrictions

Vulnerability

A vulnerability in RestrictedPython versions 6.0 through 8.0 allows for sandbox escape by exploiting a type confusion bug in the CPython interpreter. This issue arises when using 'try/except*' clauses, creating a potential bypass of the restrictions that RestrictedPython is designed to enforce. The vulnerability is present in CPython versions 3.11 and prior to 3.13.2.

Impact

Exploitation of this vulnerability could lead to unauthorized bypass of the sandboxing restrictions that RestrictedPython is intended to enforce, allowing potentially malicious code to be executed in an unrestricted manner.

Reproduction

The vulnerability can be reproduced by using RestrictedPython in a Python environment with CPython versions 3.11 to prior 3.13.2. Introduce 'try/except*' clauses in the code, which will trigger the type confusion bug in the CPython interpreter. This can be done by creating a script that uses RestrictedPython to execute code containing 'try/except*' statements, effectively bypassing the intended restrictions.

Remediation

Users can upgrade to RestrictedPython version 8.0, which removes support for 'try/except*' clauses, addressing the vulnerability by preventing the exploitation method.

Added: Jun 9, 2025, 7:46 PM
Updated: Jun 9, 2025, 7:46 PM

Vulnerability Rating

Custom Algorithm
spread
0.0
impact
5.0
exploitability
5.8
remediation
7.7
relevance
0.0
threat
4.8
urgency
2.9
incentive
1.7

Our algorithm analyzes dozens of metrics to generate these 8 key vulnerability categories, which are then combined to calculate the overall risk score.