8.3high
Sandbox escape via various forms of "format" in RestrictedPython
- Severity
- 8.3high CVSS:3.1 by GitHub_M
- Exploit likelihood
- 0.68% (higher than 53% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-xjw2-6jm9-rf67PYSEC-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.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| zopefoundation RestrictedPython | < 5.4, >= 6.0, < 6.1 | CVE List |
| restrictedpython (PyPI) | before 5.4, from 6.0 before 6.2, before 4134aedcff17c977da7717693ed89ce56d54c120 | GitHub Advisory Database, PyPA Advisory Database |
| zope restrictedpython | before 5.4, from 6.0 before 6.2 | NVD |
All scores
| GitHub_M | 8.3high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:L |
| GitHub | 8.3high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:L |
| NVD | 7.7high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:N/A:N |
| PyPA Advisory Database | 7.7high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:N/A:N |
Classification
SSVC (CISA-ADP): exploitation none, automatable no, technical impact total.
What each source says
CVE List
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.
GitHub Advisory Database
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 security@plone.org
Credits
Thanks for analysing and reporting the go to:
- Abhishek Govindarasu
- Ankush Menat
- Ward Theunisse
NVD (es)
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.
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2023-41039 changed 2024-10-01 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-xjw2-6jm9-rf67 changed 2024-02-16 | CC-BY-4.0 |
| NVD | CVE-2023-41039 changed 2026-06-17 | Public domain |
| PyPA Advisory Database | PYSEC-2023-159 changed 2023-11-08 | CC-BY-4.0 |