Every CVE Search/ Get API key

CVE-2023-41039

Sandbox escape via various forms of "format" in RestrictedPython

8.3 HighFix available

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

0.68%Up 0.6 points since Aug 31, 2023
90%50%10%1%

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 HighCVSS: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 HighCVSS: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

For more information

If you have any questions or comments about this advisory:

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 HighCVSS: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 HighCVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:L
CVSS 3.1
7.7 HighCVSS: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 HighCVSS: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 HighCVSS: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

For more information

If you have any questions or comments about this advisory:

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 HighCVSS: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 HighCVSS: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 HighCVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:L
CVSS 3.1
7.7 HighCVSS: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

Affected packages
PackageAffectedFixed
restrictedpython
PyPI
through 5.3
5.4
restrictedpython
PyPI
6.0 to 6.1
6.2
restrictedpython
Debian:12
All versions, plus listed versions
4.0~b3-36.2-18.0-18.1-18.4-1
None known
restrictedpython
Debian:13
before 6.2-1
6.2-1
restrictedpython
Debian:14
before 6.2-1
6.2-1
restrictedpython
PyPI
before 5.4, plus listed versions
3.4.23.4.33.5.03.5.13.5.2
Show 20 moreShow less
3.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
restrictedpython
PyPI
6.0 up to 6.2, plus listed versions
6.1
6.2
restrictedpython
PyPI
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 less
3.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
restrictedpython
Ubuntu:Pro:20.04:LTS
before 4.0~b3-2ubuntu0.1~esm1, plus listed versions
4.0~b3-2
4.0~b3-2ubuntu0.1~esm1
restrictedpython
Ubuntu: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
restrictedpython
Ubuntu: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
restrictedpython
Ubuntu: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
restrictedpython
Ubuntu: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

History
RecordedChangedSources
affected, facts
aliases, publishedEUVD
first indexedCVE 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

Show 7 moreShow less
MoveEnter Open