RestrictedPython vulnerable to arbitrary code execution via stack frame sandbox escape
Key facts
- Attack vector
- Network
- Privileges required
- Low
- User interaction
- None
- Attack complexity
- Low
- Impact type
- —
- Confidentiality · integrity · availability
- High · High · High
- Fix status
- Fixed
Attack profile from CVSS 3.1 · NVD. Fix status from CNA and GitHub.
Summary
RestrictedPython is a tool that helps to define a subset of the Python language which allows users to provide a program input into a trusted environment. RestrictedPython does not check access to stack frames and their attributes. Stack frames are accessible within at least generators and generator expressions, which are allowed inside RestrictedPython. Prior to versions 6.1 and 5.3, an attacker with access to a RestrictedPython environment can write code that gets the current stack frame in a generator and then walk the stack all the way beyond the RestrictedPython invocation boundary, thus breaking out of the restricted sandbox and potentially allowing arbitrary code execution in the Python interpreter. All RestrictedPython deployments that allow untrusted users to write Python code in the RestrictedPython environment are at risk. In terms of Zope and Plone, this would mean deployments where the administrator allows untrusted users to create and/or edit objects of type `Script (Python)`, `DTML Method`, `DTML Document` or `Zope Page Template`. This is a non-default configuration and likely to be extremely rare. The problem has been fixed in versions 6.1 and 5.3.
Why it matters now
SSVC decision points
CISA ADP · SSVC 2.0.3
- Exploitation
- None
- Automatable
- No
- Technical impact
- Total
The decision (Track, Attend, Act) also depends on your mission and well-being impact; see CISA's SSVC guide.
Affected products
| Vendor | Product | Affected versions | Fixed in | Status | Source |
|---|---|---|---|---|---|
| zopefoundation | RestrictedPython | 6.0a1.dev0 to before 6.1; before 5.3 | 6.1, 5.3 | Patch available | CNA |
| — | RestrictedPython (PyPI) | before 5.3 | 5.3 | Patch available | GHSA-wqc8-x2pr-7jqh |
| — | RestrictedPython (PyPI) | 6.0a1.dev0 to before 6.1 | 6.1 | Patch available | GHSA-wqc8-x2pr-7jqh |
| — | restrictedpython (PyPI) | before 5.3 | 5.3 | Patch available | GHSA-wqc8-x2pr-7jqh |
- RestrictedPython Vendorzopefoundation Affected 6.0a1.dev0 to before 6.1; before 5.3 Fixed in 6.1, 5.3 Patch available CNA
- RestrictedPython (PyPI) Vendor— Affected before 5.3 Fixed in 5.3 Patch available GHSA-wqc8-x2pr-7jqh
- RestrictedPython (PyPI) Vendor— Affected 6.0a1.dev0 to before 6.1 Fixed in 6.1 Patch available GHSA-wqc8-x2pr-7jqh
- restrictedpython (PyPI) Vendor— Affected before 5.3 Fixed in 5.3 Patch available GHSA-wqc8-x2pr-7jqh
CPE configurations NVD · 3
| CPE | Versions | Role | Vendor |
|---|---|---|---|
| cpe:2.3:a:zope:restrictedpython:*:*:*:*:*:*:*:* | before 5.3 | Vulnerable | zopefoundation |
| cpe:2.3:a:zope:restrictedpython:6.0:-:*:*:*:*:*:* | 6.0 | Vulnerable | zopefoundation |
| cpe:2.3:a:zope:restrictedpython:6.0:a1.dev0:*:*:*:*:*:* | 6.0 a1.dev0 | Vulnerable | zopefoundation |
- cpe:2.3:a:zope:restrictedpython:*:*:*:*:*:*:*:* Versions before 5.3 Vulnerable ·zopefoundation
- cpe:2.3:a:zope:restrictedpython:6.0:-:*:*:*:*:*:* Versions 6.0 Vulnerable ·zopefoundation
- cpe:2.3:a:zope:restrictedpython:6.0:a1.dev0:*:*:*:*:*:* Versions 6.0 a1.dev0 Vulnerable ·zopefoundation
Remediation
- Fix · CNA RestrictedPython (zopefoundation) Fixed in 6.1, 5.3
- Fix · GHSA-wqc8-x2pr-7jqh RestrictedPython (PyPI) Fixed in 5.3 Advisory →
- Fix · GHSA-wqc8-x2pr-7jqh RestrictedPython (PyPI) Fixed in 6.1 Advisory →
- Fix · GHSA-wqc8-x2pr-7jqh restrictedpython (PyPI) Fixed in 5.3 Advisory →
Timeline
- 2026-10-02 Threatist record created from CVE-2023-37271
- 2026-10-03 Alias added: GHSA-wqc8-x2pr-7jqh
References
Patch 1
Advisory 2
More zopefoundation Restrictedpython vulnerabilities
- TI-2024-31821 RestrictedPython information leakage via `AttributeError.obj` and the `string` module CVSS 4.0HIGH 8.7
- TI-2023-21665 Sandbox escape via various forms of "format" in RestrictedPython CVSS 3.1HIGH 8.3
Sources
- CVE-2023-37271 · CVE Program
- CVE-2023-37271 · NVD
- FIRST EPSS
- GHSA-wqc8-x2pr-7jqh · GitHub Advisory Database · CC BY 4.0
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences