Skip to content
Fencer Vulns
high 8.4

CVE-2023-37271 json

RestrictedPython vulnerable to arbitrary code execution via stack frame sandbox escape

published 2023-07-10 3 y ago modified 2026-09-10 1 mo ago also GHSA-wqc8-x2pr-7jqh , PYSEC-2023-118 , EUVD-2023-0228

cvss
8.4
version 3.1, CNA
cisa kev
Not listed
not in CISA's catalog
epss
0.8%
EPSS 0.8% chance of exploitation in 30 days, percentile 58%
public exploits
0
none known

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.

Patch / fix

  • pypi restrictedpython 5.3, 6.1
  • zope restrictedpython 5.3
  • restrictedpython Debian 14, Debian 13 6.2-1

debian advisories DEBIAN-CVE-2023-37271

  • restrictedpython Ubuntu Pro 20.04 LTS 4.0~b3-2ubuntu0.1~esm1
  • restrictedpython Ubuntu Pro 22.04 LTS 4.0~b3-3ubuntu0.1~esm1

ubuntu advisories UBUNTU-CVE-2023-37271

Ubuntu security data © Canonical Ltd., from https://github.com/canonical/ubuntu-security-notices via OSV; changed: normalised to fixed package versions per release. CC BY-SA 4.0

CISA SSVC

Exploitation
none
Automatable
no
Technical impact
total
Assessed
2 y ago

Exploit prediction

0.85% chance of exploitation in the next 30 days, higher than 58% of all scored CVEs (FIRST EPSS, 2026-11-08).

CVSS scores

assigned by version score vector
CNA 3.1 8.4 CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:L
NVD 3.1 9.9 CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H
GitHub 3.1 8.4 CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:L

Affected packages

ecosystem package affected fixed in
pypi restrictedpython
<5.3
>=6.0a1.dev0, <6.1
5.3
6.1

Affected products

  • zopefoundation RestrictedPython

Classification

Weakness
  • CWE-913 Improper Control of Dynamically-Managed Code Resources

References

Sources

Fencer Vulns keeps one entry per vulnerability: the CVE id wins, then GHSA, and records that alias each other are merged, except that two CVEs always keep separate entries. The same data is available as JSON.