CVE-2023-41039Sandbox escape via various forms of "format" in RestrictedPython
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.
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-41039 |
| Ubuntu 20.04 | restrictedpython | Fix pending | 4.0~b3-2ubuntu0.1~esm1 (Ubuntu Pro) | UBUNTU-CVE-2023-41039 |
| 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-41039 |
| Debian 13 | restrictedpython | Fixed | 6.2-1 | DEBIAN-CVE-2023-41039 |
| Debian 12 | restrictedpython | Fix pending | DEBIAN-CVE-2023-41039 | |
| PyPI library | restrictedpython | Fixed | 5.4 | PYSEC-2023-159 |
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: < 5.4, >= 6.0, < 6.1
References
- https://github.com/zopefoundation/RestrictedPython/security/advisories/GHSA-xjw2-6jm9-rf67
- https://github.com/zopefoundation/RestrictedPython/commit/4134aedcff17c977da7717693ed89ce56d54c120
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.