Read the docs
TI-2023-18901 Aliases CVE-2023-37271GHSA-wqc8-x2pr-7jqh

RestrictedPython vulnerable to arbitrary code execution via stack frame sandbox escape

Priority MEDIUM 44CWE-913Published · Updated

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

Exploitation None reported CISA SSVC · not in CISA KEV
EPSS 0.00847 58th percentileScored 2026-11-07
Fix Fixed RestrictedPython (zopefoundation): 6.1, 5.3RestrictedPython (PyPI): 5.3, 6.1+1 more product

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

VendorProductAffected versionsFixed inStatusSource
zopefoundationRestrictedPython6.0a1.dev0 to before 6.1; before 5.36.1, 5.3Patch availableCNA
—RestrictedPython (PyPI)before 5.35.3Patch availableGHSA-wqc8-x2pr-7jqh
—RestrictedPython (PyPI)6.0a1.dev0 to before 6.16.1Patch availableGHSA-wqc8-x2pr-7jqh
—restrictedpython (PyPI)before 5.35.3Patch availableGHSA-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

CPEVersionsRoleVendor
cpe:2.3:a:zope:restrictedpython:*:*:*:*:*:*:*:*before 5.3Vulnerablezopefoundation
cpe:2.3:a:zope:restrictedpython:6.0:-:*:*:*:*:*:*6.0Vulnerablezopefoundation
cpe:2.3:a:zope:restrictedpython:6.0:a1.dev0:*:*:*:*:*:*6.0 a1.dev0Vulnerablezopefoundation
  • 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

  1. 2026-10-02 Threatist record created from CVE-2023-37271
  2. 2026-10-03 Alias added: GHSA-wqc8-x2pr-7jqh

References

  • 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