CVE-2023-37271RestrictedPython vulnerable to arbitrary code execution via stack frame sandbox escape
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.
What to do
Fixed builds are available from Debian, PyPI: see the table below for the fixed version per release.
Debian, Ubuntu have not shipped a fix for every release yet.
Is your server affected? One read-only command checks every installed package against this CVE and all others, using each vendor's fixed versions. Get started or get a free API key.
curl -sS "https://api.cvefocus.com/v1/check?format=text" -H "Authorization: Bearer $CVEFOCUS_KEY" \ -H "Content-Type: text/plain" --data-binary @inventory.txt
Vendor status at a glance
Status by vendor and release
From each vendor's own security data and VEX statements. "Fixed" means a fixed build is published for that release.
| Release | Package | Status | Fixed version | Advisory |
|---|---|---|---|---|
| Ubuntu 26.04 | restrictedpython | Not affected vulnerable_code_not_present | ||
| Ubuntu 25.10 | restrictedpython | Not affected vulnerable_code_not_present | ||
| Ubuntu 22.04 | restrictedpython | Fix pending | 4.0~b3-3ubuntu0.1~esm1 (Ubuntu Pro) | UBUNTU-CVE-2023-37271 |
| Ubuntu 20.04 | restrictedpython | Fix pending | 4.0~b3-2ubuntu0.1~esm1 (Ubuntu Pro) | UBUNTU-CVE-2023-37271 |
| Ubuntu 18.04 | restrictedpython | Fix pending | ||
| Ubuntu 16.04 | restrictedpython | Fix pending | ||
| Ubuntu 14.04 | restrictedpython | Fix pending | ||
| Debian 14 | restrictedpython | Fixed | 6.2-1 | DEBIAN-CVE-2023-37271 |
| Debian 13 | restrictedpython | Fixed | 6.2-1 | DEBIAN-CVE-2023-37271 |
| Debian 12 | restrictedpython | Fix pending | DEBIAN-CVE-2023-37271 | |
| PyPI library | restrictedpython | Fixed | 5.3 | PYSEC-2023-118 |
What the vendor says
As published in the CVE record by GitHub_M, the CVE's assigner (usually the vendor). Check the vendor's advisory before acting.
- zopefoundation RestrictedPython: affected: >= 6.0a1.dev0, < 6.1, < 5.3
References
- https://github.com/zopefoundation/RestrictedPython/security/advisories/GHSA-wqc8-x2pr-7jqh
- https://github.com/zopefoundation/RestrictedPython/commit/c8eca66ae49081f0016d2e1f094c3d72095ef531
About this page
Compiled by CVEfocus from the CVE List, the security data and VEX statements of Ubuntu, Debian, Red Hat, AlmaLinux, Rocky Linux and Microsoft, CISA's Known Exploited Vulnerabilities catalog and FIRST EPSS, refreshed several times a day (data status). Information only; see the disclaimer. Official record: cve.org · NVD.