# CVE-2023-41039: Sandbox escape via various forms of "format" in RestrictedPython

- Severity: High 8.3 (CVSS:3.1, scored by GitHub_M) `CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:L`
- Known to be exploited: not in CISA's catalogue, which lists only what CISA has confirmed
- Likelihood of exploitation in the next 30 days (EPSS): 0.68%, higher than 53% of CVEs (2026-12-01)
- Published: 2023-08-30T17:18:56.168Z
- Modified: 2026-06-17T06:20:13.893Z
- Also known as: GHSA-xjw2-6jm9-rf67, PYSEC-2023-159
- Weaknesses: CWE-74
- SSVC (CISA-ADP): exploitation none, automatable no, technical impact total
- Assigned by: GitHub_M

## Description

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.

(As written by CVE List.)

## Affected

- zopefoundation RestrictedPython: < 5.4; >= 6.0, < 6.1
- restrictedpython (PyPI): before 5.4; from 6.0 before 6.2; before 4134aedcff17c977da7717693ed89ce56d54c120
- zope restrictedpython: before 5.4; from 6.0 before 6.2

## Every score

- GitHub_M: CVSS:3.1 8.3 High `CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:L`
- GitHub: CVSS:3.1 8.3 High `CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:L`
- NVD: CVSS:3.1 7.7 High `CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:N/A:N`
- PyPA Advisory Database: CVSS:3.1 7.7 High `CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:N/A:N`

## References

- <https://github.com/zopefoundation/RestrictedPython/security/advisories/GHSA-xjw2-6jm9-rf67> (advisory, vendor-advisory, web)
- <https://github.com/zopefoundation/RestrictedPython/commit/4134aedcff17c977da7717693ed89ce56d54c120> (fix, patch, web)
- <https://nvd.nist.gov/vuln/detail/CVE-2023-41039> (advisory)
- <https://github.com/zopefoundation/RestrictedPython> (package)

## Sources

- CVE List: [CVE-2023-41039](https://www.cve.org/CVERecord?id=CVE-2023-41039), CVE Terms of Use, modified 2024-10-01
- GitHub Advisory Database: [GHSA-xjw2-6jm9-rf67](https://github.com/advisories/GHSA-xjw2-6jm9-rf67), CC-BY-4.0, modified 2024-02-16
- NVD: [CVE-2023-41039](https://nvd.nist.gov/vuln/detail/CVE-2023-41039), Public domain, modified 2026-06-17
- PyPA Advisory Database: [PYSEC-2023-159](https://osv.dev/vulnerability/PYSEC-2023-159), CC-BY-4.0, modified 2023-11-08

---

Page: https://cve.day/CVE-2023-41039 · Whole record: https://cve.day/CVE-2023-41039.json · Rebuilt by cve.day 2026-11-25T22:58:27.453Z
