{"id":"CVE-2023-41039","aliases":["CVE-2023-41039","GHSA-xjw2-6jm9-rf67","PYSEC-2023-159"],"related":[],"kind":"vulnerability","state":"published","title":"Sandbox escape via various forms of \"format\" in RestrictedPython","summary":"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.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"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.","source":"cvelist"},{"lang":"en","text":"### 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","format":"markdown","source":"ghsa"},{"lang":"es","text":"RestrictedPython es un entorno de ejecución restringido para que Python ejecute código no confiable. La funcionalidad 'format' de Python permite a alguien que controla la cadena de formato 'leer' todos los objetos accesibles a través de la búsqueda recursiva de atributos y la suscripción desde objetos a los que puede acceder. Esto puede llevar a una crítica revelación de información. Con 'RestrictedPython', la funcionalidad de formato está disponible a través de los métodos 'format' y 'format_map' de 'str' (y 'unicode') (accesibles ya sea a través de la clase o de sus instancias) y a través de 'string.Formatter'. Todas las versiones conocidas de 'RestrictedPython' son vulnerables. Este problema ha sido abordado en el commit '4134aedcff1', el cual ha sido incluido en las versiones 5.4 y 6.2. Se aconseja a los usuarios que actualicen. No se conocen soluciones alternativas para esta vulnerabilidad.","source":"nvd"}],"published":"2023-08-30T17:18:56.168Z","modified":"2026-06-17T06:20:13.893Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:L","score":8.3,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:L","score":8.3,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:L","score":8.3,"rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:N/A:N","score":7.7,"rating":"HIGH"},{"scorer":"PyPA Advisory Database","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:N/A:N","score":7.7,"rating":"HIGH"}],"cwes":["CWE-74"],"affected":[{"ranges":[{"version":"< 5.4","status":"affected"},{"version":">= 6.0, < 6.1","status":"affected"}],"vendor":"zopefoundation","product":"RestrictedPython","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"5.4"}],"ecosystem":"PyPI","package":"restrictedpython","purl":"pkg:pypi/restrictedpython","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"6.0","status":"affected","fixed":"6.2"}],"ecosystem":"PyPI","package":"restrictedpython","purl":"pkg:pypi/restrictedpython","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"5.4"},{"status":"affected","introduced":"6.0","fixed":"6.2"}],"vendor":"zope","product":"restrictedpython","cpe":"cpe:2.3:a:zope:restrictedpython:*:*:*:*:*:*:*:*","source":"nvd"},{"ranges":[{"type":"git","introduced":"0","status":"affected","fixed":"4134aedcff17c977da7717693ed89ce56d54c120"},{"type":"ecosystem","introduced":"6.0","status":"affected","fixed":"6.2"},{"type":"ecosystem","introduced":"0","status":"affected","fixed":"5.4"}],"ecosystem":"PyPI","package":"restrictedpython","purl":"pkg:pypi/restrictedpython","repo":"https://github.com/zopefoundation/RestrictedPython","source":"pysec"}],"references":[{"url":"https://github.com/zopefoundation/RestrictedPython/security/advisories/GHSA-xjw2-6jm9-rf67","tags":["advisory","vendor-advisory","web","x-refsource-confirm","x-transferred"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/zopefoundation/RestrictedPython/commit/4134aedcff17c977da7717693ed89ce56d54c120","tags":["fix","patch","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2023-41039","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/zopefoundation/RestrictedPython","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"total","date":"2024-10-01T18:16:29.862Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2023-41039","url":"https://www.cve.org/CVERecord?id=CVE-2023-41039","licence":"CVE Terms of Use","modified":"2024-10-01T18:16:40.852Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-xjw2-6jm9-rf67","url":"https://github.com/advisories/GHSA-xjw2-6jm9-rf67","licence":"CC-BY-4.0","modified":"2024-02-16T08:18:58.766Z"},{"source":"nvd","name":"NVD","id":"CVE-2023-41039","url":"https://nvd.nist.gov/vuln/detail/CVE-2023-41039","licence":"Public domain","modified":"2026-06-17T06:20:13.893Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2023-159","url":"https://osv.dev/vulnerability/PYSEC-2023-159","licence":"CC-BY-4.0","modified":"2023-11-08T04:13:23.394Z"}],"updatedAt":"2026-11-25T22:58:27.453Z","epss":{"score":0.00683,"percentile":0.53781,"date":"2026-12-01T12:00:22.000Z"}}