Sandbox escape via various forms of "format" in RestrictedPython
Key facts
- Attack vector
- Network
- Privileges required
- High
- User interaction
- Required
- Attack complexity
- Low
- Impact type
- —
- Confidentiality · integrity · availability
- High · High · Low
- Fix status
- Fixed
Attack profile from CVSS 3.1 · CNA. Fix status from CNA and GitHub.
Summary
RestrictedPython is a restricted execution environment for Python to run untrusted code. Python's "format" functionality allows someone controlling the format string to "read" all objects accessible through recursive attribute lookup and subscription from objects he can access. This can lead to critical information disclosure. With `RestrictedPython`, the format functionality is available via the `format` and `format_map` methods of `str` (and `unicode`) (accessed either via the class or its instances) and via `string.Formatter`. All known versions of `RestrictedPython` are vulnerable. This issue has been addressed in commit `4134aedcff1` which has been included in the 5.4 and 6.2 releases. Users are advised to upgrade. There are no known workarounds for this vulnerability.
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 | before 5.4; 6.0 to before 6.1 | 5.4, 6.1 | Patch available | CNA |
| — | RestrictedPython (PyPI) | before 5.4 | 5.4 | Patch available | GHSA-xjw2-6jm9-rf67 |
| — | RestrictedPython (PyPI) | 6.0 to before 6.2 | 6.2 | Patch available | GHSA-xjw2-6jm9-rf67 |
- RestrictedPython Vendorzopefoundation Affected before 5.4; 6.0 to before 6.1 Fixed in 5.4, 6.1 Patch available CNA
- RestrictedPython (PyPI) Vendor— Affected before 5.4 Fixed in 5.4 Patch available GHSA-xjw2-6jm9-rf67
- RestrictedPython (PyPI) Vendor— Affected 6.0 to before 6.2 Fixed in 6.2 Patch available GHSA-xjw2-6jm9-rf67
CPE configurations NVD · 1
| CPE | Versions | Role | Vendor |
|---|---|---|---|
| cpe:2.3:a:zope:restrictedpython:*:*:*:*:*:*:*:* | before 5.4; 6.0 to before 6.2 | Vulnerable | zopefoundation |
- cpe:2.3:a:zope:restrictedpython:*:*:*:*:*:*:*:* Versions before 5.4; 6.0 to before 6.2 Vulnerable ·zopefoundation
Remediation
- Fix · CNA RestrictedPython (zopefoundation) Fixed in 5.4, 6.1
- Fix · GHSA-xjw2-6jm9-rf67 RestrictedPython (PyPI) Fixed in 5.4 Advisory →
- Fix · GHSA-xjw2-6jm9-rf67 RestrictedPython (PyPI) Fixed in 6.2 Advisory →
Timeline
- 2026-10-02 Threatist record created from CVE-2023-41039
- 2026-10-03 Alias added: GHSA-xjw2-6jm9-rf67
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-18901 RestrictedPython vulnerable to arbitrary code execution via stack frame sandbox escape CVSS 3.1CRITICAL 9.9
Sources
- CVE-2023-41039 · CVE Program
- CVE-2023-41039 · NVD
- FIRST EPSS
- GHSA-xjw2-6jm9-rf67 · 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