{"id":"CVE-2023-41039","aliases":["DEBIAN-CVE-2023-41039","EUVD-2023-0229","GHSA-xjw2-6jm9-rf67","PYSEC-2023-159","UBUNTU-CVE-2023-41039","USN-7355-1"],"status":"published","title":"Sandbox escape via various forms of \"format\" in RestrictedPython","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.","severity":{"version":"3.1","score":8.3,"vector":"CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:L","level":"high","assessor":"cna","from":"cve"},"epss":{"day":"2026-11-12","score":0.00683,"percentile":0.53006,"model":"v2026.06.15"},"facts":{"in_kev":false,"known_exploited":false,"public_exploit":false,"fix_available":true},"cwes":["CWE-74"],"published":"2023-08-30T17:18:56Z","modified":"2026-10-28T02:30:47Z","fixes":[{"ecosystem":"PyPI","package":"restrictedpython","fixed_in":["5.4","6.2"],"sources":["ghsa","osv"]},{"ecosystem":"Debian:13","package":"restrictedpython","fixed_in":["6.2-1"],"sources":["osv"]},{"ecosystem":"Debian:14","package":"restrictedpython","fixed_in":["6.2-1"],"sources":["osv"]},{"ecosystem":"Ubuntu:Pro:20.04:LTS","package":"restrictedpython","fixed_in":["4.0~b3-2ubuntu0.1~esm1"],"sources":["osv"]},{"ecosystem":"Ubuntu:Pro:22.04:LTS","package":"restrictedpython","fixed_in":["4.0~b3-3ubuntu0.1~esm1"],"sources":["osv"]}],"affected":[{"source":"ghsa","ecosystem":"PyPI","package":"restrictedpython","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"last_affected":"5.3"},{"fixed":"5.4"}]}]},{"source":"ghsa","ecosystem":"PyPI","package":"restrictedpython","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"6.0"},{"last_affected":"6.1"},{"fixed":"6.2"}]}]},{"source":"osv","ecosystem":"Debian:12","package":"restrictedpython","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"}]}],"versions":["4.0~b3-3","6.2-1","8.0-1","8.1-1","8.4-1"]},{"source":"osv","ecosystem":"Debian:13","package":"restrictedpython","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"6.2-1"}]}]},{"source":"osv","ecosystem":"Debian:14","package":"restrictedpython","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"6.2-1"}]}]},{"source":"osv","ecosystem":"PyPI","package":"restrictedpython","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"5.4"}]}],"versions":["3.4.2","3.4.3","3.5.0","3.5.1","3.5.2","3.6.0","3.6.0a1","4.0","4.0a1","4.0a2","4.0a3","4.0b1","4.0b2","4.0b3","4.0b4","4.0b5","4.0b6","4.0b7","4.0b8","5.0","5.1","5.2","5.2a1.dev0","5.3","5.3a1.dev0"]},{"source":"osv","ecosystem":"PyPI","package":"restrictedpython","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"6.0"},{"fixed":"6.2"}]}],"versions":["6.0","6.1"]},{"source":"osv","ecosystem":"PyPI","package":"restrictedpython","ranges":[{"type":"GIT","events":[{"introduced":"0"},{"fixed":"4134aedcff17c977da7717693ed89ce56d54c120"}]},{"type":"ECOSYSTEM","events":[{"introduced":"6.0"},{"fixed":"6.2"},{"introduced":"0"},{"fixed":"5.4"}]}],"versions":["3.4.2","3.4.3","3.5.0","3.5.1","3.5.2","3.6.0","3.6.0a1","4.0","4.0a1","4.0a2","4.0a3","4.0b1","4.0b2","4.0b3","4.0b4","4.0b5","4.0b6","4.0b7","4.0b8","5.0","5.1","5.2","5.2a1.dev0","5.3","5.3a1.dev0","6.0","6.1"]},{"source":"osv","ecosystem":"Ubuntu:Pro:20.04:LTS","package":"restrictedpython","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"4.0~b3-2ubuntu0.1~esm1"}]}],"versions":["4.0~b3-2"]},{"source":"osv","ecosystem":"Ubuntu:Pro:22.04:LTS","package":"restrictedpython","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"4.0~b3-3ubuntu0.1~esm1"}]}],"versions":["4.0~b3-2","4.0~b3-2ubuntu1","4.0~b3-3"]},{"source":"osv","ecosystem":"Ubuntu:Pro:20.04:LTS","package":"restrictedpython","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"4.0~b3-2ubuntu0.1~esm1"}]}],"versions":["4.0~b3-2"],"bundled":4},{"source":"osv","ecosystem":"Ubuntu:Pro:22.04:LTS","package":"restrictedpython","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"4.0~b3-3ubuntu0.1~esm1"}]}],"versions":["4.0~b3-2","4.0~b3-2ubuntu1","4.0~b3-3"],"bundled":4},{"source":"osv","ecosystem":"Ubuntu:Pro:24.04:LTS","package":"restrictedpython","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"6.2-1ubuntu0.24.04.1~esm1"}]}],"versions":["4.0~b3-3","6.2-1"],"bundled":4}],"products":[{"vendor":"zope","product":"restrictedpython"},{"vendor":"zopefoundation","product":"restrictedpython"}],"references":[{"url":"https://github.com/zopefoundation/RestrictedPython/security/advisories/GHSA-xjw2-6jm9-rf67","tags":["x_refsource_CONFIRM","x_transferred","Vendor Advisory","advisory","web","report"]},{"url":"https://github.com/zopefoundation/RestrictedPython/commit/4134aedcff17c977da7717693ed89ce56d54c120","tags":["x_refsource_MISC","x_transferred","Patch","fix","web","report"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2023-41039","tags":["advisory"]},{"url":"https://github.com/advisories/GHSA-xjw2-6jm9-rf67"},{"url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2023/41xxx/CVE-2023-41039.json","tags":["advisory"]},{"url":"https://security-tracker.debian.org/tracker/CVE-2023-41039","tags":["advisory"]},{"url":"https://github.com/zopefoundation/RestrictedPython","tags":["package"]},{"url":"https://ubuntu.com/security/CVE-2023-41039","tags":["report"]},{"url":"https://www.cve.org/CVERecord?id=CVE-2023-41039","tags":["report"]},{"url":"https://ubuntu.com/security/notices/USN-7355-1","tags":["advisory"]},{"url":"https://ubuntu.com/security/CVE-2023-37271","tags":["report"]},{"url":"https://ubuntu.com/security/CVE-2024-47532","tags":["report"]},{"url":"https://ubuntu.com/security/CVE-2025-22153","tags":["report"]}],"sources":{"cve":[{"id":"CVE-2023-41039","title":"Sandbox escape via various forms of \"format\" in RestrictedPython","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.\n\n","status":"published","published":"2023-08-30T17:18:56.168Z","modified":"2024-10-01T18:16:40.852Z","cvss":[{"version":"3.1","score":8.3,"vector":"CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:L","level":"high","assessor":"cna"}],"cwes":["CWE-74"],"updated_at":"2026-11-02T14:35:19.217111Z"}],"euvd":[{"id":"EUVD-2023-0229","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.\n\n","status":"published","published":"2023-08-30T17:18:56Z","modified":"2024-10-01T18:16:40Z","cvss":[{"version":"3.1","score":8.3,"vector":"CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:L","level":"high"}],"updated_at":"2026-11-03T00:27:59.918435Z"}],"ghsa":[{"id":"GHSA-xjw2-6jm9-rf67","title":"Sandbox escape via various forms of \"format\".","description":"### Impact\nPython'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.\nWith `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`.\nAll known versions of `RestrictedPython` are vulnerable. \n\n### Patches\nThe issue will be fixed in 5.4 and 6.2.\n\n### Workarounds\nThere are no workarounds to fix the issue without upgrading.\n\n### References\n* https://docs.python.org/3/library/stdtypes.html#str.format_map\n* http://lucumr.pocoo.org/2016/12/29/careful-with-str-format/\n* https://www.exploit-db.com/exploits/51580\n\n### For more information\n\nIf you have any questions or comments about this advisory:\n\n* Open an issue in the [RestrictedPython issue tracker](https://github.com/zopefoundation/RestrictedPython/issues)\n* Email us at [security@plone.org](mailto:security@plone.org)\n\n### Credits\n\nThanks for analysing and reporting the go to:\n\n* Abhishek Govindarasu\n* Ankush Menat\n* Ward Theunisse\n\n","status":"published","published":"2023-08-30T20:47:58Z","modified":"2023-11-07T05:00:56Z","cvss":[{"version":"3.1","score":8.3,"vector":"CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:L","level":"high"}],"cwes":["CWE-74"],"updated_at":"2026-11-02T14:37:15.055009Z"}],"nvd":[{"id":"CVE-2023-41039","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.\n\n","status":"published","published":"2023-08-30T18:15:09.88Z","modified":"2026-06-17T06:20:13.893Z","cvss":[{"version":"3.1","score":8.3,"vector":"CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:L","level":"high","assessor":"secondary"},{"version":"3.1","score":7.7,"vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:N/A:N","level":"high","assessor":"primary"}],"cwes":["CWE-74"],"updated_at":"2026-11-02T14:08:25.025396Z"}],"osv":[{"id":"CVE-2023-41039","title":"Sandbox escape via various forms of \"format\" in RestrictedPython","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.\n\n","status":"published","published":"2023-08-30T17:18:56.168Z","modified":"2026-10-28T02:30:47.466224233Z","cvss":[{"version":"3.1","score":8.3,"vector":"CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:L","level":"high"}],"cwes":["CWE-74"],"updated_at":"2026-11-02T15:44:33.244128Z"},{"id":"DEBIAN-CVE-2023-41039","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.","status":"published","published":"2023-08-30T18:15:09.88Z","modified":"2026-10-26T18:02:33.131677267Z","cvss":[{"version":"3.1","score":7.7,"vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:N/A:N","level":"high"}],"updated_at":"2026-11-02T15:45:39.980321Z"},{"id":"GHSA-xjw2-6jm9-rf67","title":"Sandbox escape via various forms of \"format\".","description":"### Impact\nPython'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.\nWith `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`.\nAll known versions of `RestrictedPython` are vulnerable. \n\n### Patches\nThe issue will be fixed in 5.4 and 6.2.\n\n### Workarounds\nThere are no workarounds to fix the issue without upgrading.\n\n### References\n* https://docs.python.org/3/library/stdtypes.html#str.format_map\n* http://lucumr.pocoo.org/2016/12/29/careful-with-str-format/\n* https://www.exploit-db.com/exploits/51580\n\n### For more information\n\nIf you have any questions or comments about this advisory:\n\n* Open an issue in the [RestrictedPython issue tracker](https://github.com/zopefoundation/RestrictedPython/issues)\n* Email us at [security@plone.org](mailto:security@plone.org)\n\n### Credits\n\nThanks for analysing and reporting the go to:\n\n* Abhishek Govindarasu\n* Ankush Menat\n* Ward Theunisse\n\n","status":"published","published":"2023-08-30T20:47:58Z","modified":"2024-02-16T08:18:58.766349Z","cvss":[{"version":"3.1","score":8.3,"vector":"CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:L","level":"high"}],"cwes":["CWE-74"],"updated_at":"2026-11-02T15:47:00.198893Z"},{"id":"PYSEC-2023-159","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.\n\n","status":"published","published":"2023-08-30T18:15:00Z","modified":"2023-11-08T04:13:23.394567Z","cvss":[{"version":"3.1","score":7.7,"vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:N/A:N","level":"high"}],"updated_at":"2026-11-02T15:52:53.837392Z"},{"id":"UBUNTU-CVE-2023-41039","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.","status":"published","published":"2023-08-30T18:15:00Z","modified":"2026-02-04T04:04:16.998664Z","cvss":[{"version":"3.1","score":8.3,"vector":"CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:L","level":"high"},{"version":"3.1","score":7.7,"vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:N/A:N","level":"high"}],"updated_at":"2026-11-02T16:54:22.741943Z"},{"id":"USN-7355-1","title":"restrictedpython vulnerabilities","description":"Nakul Choudhary and Robert Xiao discovered that RestrictedPython did not\nproperly sanitize certain inputs. An attacker could possibly use this\nissue to execute arbitrary code. This issue only affected\nUbuntu 20.04 LTS and Ubuntu 22.04 LTS. (CVE-2023-37271)\n\nAbhishek Govindarasu, Ankush Menat and Ward Theunisse discovered that\nRestrictedPython did not correctly handle certain format strings. An\nattacker could possibly use this issue to leak sensitive information.\nThis issue only affected Ubuntu 20.04 LTS and Ubuntu 22.04 LTS.\n(CVE-2023-41039)\n\nIt was discovered that RestrictedPython did not correctly restrict access\nto certain fields. An attacker could possibly use this issue to leak\nsensitive information. (CVE-2024-47532)\n\nIt was discovered that RestrictedPython contained a type confusion\nvulnerability. An attacker could possibly use this issue to execute\narbitrary code. This issue only affected Ubuntu 24.04 LTS and\nUbuntu 24.10. (CVE-2025-22153)\n","status":"published","published":"2025-03-18T23:59:57Z","modified":"2026-04-27T17:48:50.897198Z","updated_at":"2026-11-02T16:58:19.988474Z"}]}}
