CVE-2023-41039
Sandbox 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.
Attack profile
How easy it is to exploit
- Attack vector
- Network
- Complexity
- Low
- Privileges needed
- High
- User interaction
- Required
What an attacker can affect
- Confidentiality
- High
- Integrity
- High
- Availability
- Low
Exploit likelihood
What each source reports
CVE List Score used
8.3
Sandbox 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.
- Record
CVE-2023-41039- 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 - Weakness
- CWE-74
- Updated
- 2026-11-02
EUVDEUVD-2023-0229
8.3
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.
- Record
EUVD-2023-0229- 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 - Updated
- 2026-11-03
GitHub AdvisoriesGHSA-xjw2-6jm9-rf67
8.3
Sandbox escape via various forms of "format".
Impact
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.
Patches
The issue will be fixed in 5.4 and 6.2.
Workarounds
There are no workarounds to fix the issue without upgrading.
References
- https://docs.python.org/3/library/stdtypes.html#str.format_map
- http://lucumr.pocoo.org/2016/12/29/careful-with-str-format/
- https://www.exploit-db.com/exploits/51580
For more information
If you have any questions or comments about this advisory:
- Open an issue in the RestrictedPython issue tracker
- Email us at [email protected]
Credits
Thanks for analysing and reporting the go to:
- Abhishek Govindarasu
- Ankush Menat
- Ward Theunisse
- Record
GHSA-xjw2-6jm9-rf67- 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 - Weakness
- CWE-74
- Updated
- 2026-11-02
NVD
8.3
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.
- Record
CVE-2023-41039- 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 - 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 - Weakness
- CWE-74
- Updated
- 2026-11-02
OSV
8.3
Sandbox 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.
- Record
CVE-2023-41039- 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 - Weakness
- CWE-74
- Updated
- 2026-11-02
OSVDEBIAN-CVE-2023-41039
7.7
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.
- Record
DEBIAN-CVE-2023-41039- 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 - Updated
- 2026-11-02
Show 4 moreShow less
OSVGHSA-xjw2-6jm9-rf67
8.3
Sandbox escape via various forms of "format".
Impact
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.
Patches
The issue will be fixed in 5.4 and 6.2.
Workarounds
There are no workarounds to fix the issue without upgrading.
References
- https://docs.python.org/3/library/stdtypes.html#str.format_map
- http://lucumr.pocoo.org/2016/12/29/careful-with-str-format/
- https://www.exploit-db.com/exploits/51580
For more information
If you have any questions or comments about this advisory:
- Open an issue in the RestrictedPython issue tracker
- Email us at [email protected]
Credits
Thanks for analysing and reporting the go to:
- Abhishek Govindarasu
- Ankush Menat
- Ward Theunisse
- Record
GHSA-xjw2-6jm9-rf67- 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 - Weakness
- CWE-74
- Updated
- 2026-11-02
OSVPYSEC-2023-159
7.7
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.
- Record
PYSEC-2023-159- 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 - Updated
- 2026-11-02
OSVUBUNTU-CVE-2023-41039
8.3
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.
- Record
UBUNTU-CVE-2023-41039- 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 - 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 - Updated
- 2026-11-02
OSVUSN-7355-1 No score
restrictedpython vulnerabilities
Nakul Choudhary and Robert Xiao discovered that RestrictedPython did not properly sanitize certain inputs. An attacker could possibly use this issue to execute arbitrary code. This issue only affected Ubuntu 20.04 LTS and Ubuntu 22.04 LTS. (CVE-2023-37271)
Abhishek Govindarasu, Ankush Menat and Ward Theunisse discovered that RestrictedPython did not correctly handle certain format strings. An attacker could possibly use this issue to leak sensitive information. This issue only affected Ubuntu 20.04 LTS and Ubuntu 22.04 LTS. (CVE-2023-41039)
It was discovered that RestrictedPython did not correctly restrict access to certain fields. An attacker could possibly use this issue to leak sensitive information. (CVE-2024-47532)
It was discovered that RestrictedPython contained a type confusion vulnerability. An attacker could possibly use this issue to execute arbitrary code. This issue only affected Ubuntu 24.04 LTS and Ubuntu 24.10. (CVE-2025-22153)
- Record
USN-7355-1- Updated
- 2026-11-02
Affected products
Affected packages
| Package | Affected | Fixed |
|---|---|---|
restrictedpythonPyPI |
through 5.3 | 5.4 |
restrictedpythonPyPI |
6.0 to 6.1 | 6.2 |
restrictedpythonDebian:12 |
All versions, plus listed versions 4.0~b3-36.2-18.0-18.1-18.4-1 |
None known |
restrictedpythonDebian:13 |
before 6.2-1 | 6.2-1 |
restrictedpythonDebian:14 |
before 6.2-1 | 6.2-1 |
restrictedpythonPyPI |
before 5.4, plus listed versions 3.4.23.4.33.5.03.5.13.5.2 Show 20 moreShow less3.6.03.6.0a14.04.0a14.0a24.0a34.0b14.0b24.0b34.0b44.0b54.0b64.0b74.0b85.05.15.25.2a1.dev05.35.3a1.dev0 |
5.4 |
restrictedpythonPyPI |
6.0 up to 6.2, plus listed versions 6.1 |
6.2 |
restrictedpythonPyPI |
6.0 up to 6.2, before 5.4, plus listed versions 3.4.23.4.33.5.03.5.13.5.2 Show 21 moreShow less3.6.03.6.0a14.04.0a14.0a24.0a34.0b14.0b24.0b34.0b44.0b54.0b64.0b74.0b85.05.15.25.2a1.dev05.35.3a1.dev06.1 |
6.25.4 |
restrictedpythonUbuntu:Pro:20.04:LTS |
before 4.0~b3-2ubuntu0.1~esm1, plus listed versions 4.0~b3-2 |
4.0~b3-2ubuntu0.1~esm1 |
restrictedpythonUbuntu:Pro:22.04:LTS |
before 4.0~b3-3ubuntu0.1~esm1, plus listed versions 4.0~b3-24.0~b3-2ubuntu14.0~b3-3 |
4.0~b3-3ubuntu0.1~esm1 |
restrictedpythonUbuntu:Pro:20.04:LTS From an advisory covering 4 CVEs |
before 4.0~b3-2ubuntu0.1~esm1, plus listed versions 4.0~b3-2 |
4.0~b3-2ubuntu0.1~esm1 |
restrictedpythonUbuntu:Pro:22.04:LTS From an advisory covering 4 CVEs |
before 4.0~b3-3ubuntu0.1~esm1, plus listed versions 4.0~b3-24.0~b3-2ubuntu14.0~b3-3 |
4.0~b3-3ubuntu0.1~esm1 |
restrictedpythonUbuntu:Pro:24.04:LTS From an advisory covering 4 CVEs |
before 6.2-1ubuntu0.24.04.1~esm1, plus listed versions 4.0~b3-36.2-1 |
6.2-1ubuntu0.24.04.1~esm1 |
History
| Recorded | Changed | Sources |
|---|---|---|
| affected, facts | ||
| aliases, published | EUVD | |
| first indexed | CVE List, GitHub Advisories, NVD, OSV |
Dates are when Every CVE recorded each change. Upstream dates may differ.
In short
CVE-2023-41039 is a high vulnerability (CVSS 8.3) in Zope Restrictedpython, published August 30, 2023. No source lists public exploit code. EPSS puts the chance of exploitation in the next 30 days at 0.68%, the 52nd percentile. Fixed in restrictedpython 5.4.
References
github.com/zopefoundation/RestrictedPython/security/advisories/GHSA-xjw2-6jm9-rf67
github.com/zopefoundation/RestrictedPython/commit/4134aedcff17c977da7717693ed89ce56d54c120
nvd.nist.gov/vuln/detail/CVE-2023-41039
github.com/advisories/GHSA-xjw2-6jm9-rf67
github.com/CVEProject/cvelistV5/tree/main/cves/2023/41xxx/CVE-2023-41039.json
security-tracker.debian.org/tracker/CVE-2023-41039