CVE-2023-41039
JSON

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 packageVersionsReported by
zopefoundation RestrictedPython< 5.4, >= 6.0, < 6.1CVE List
restrictedpython (PyPI)before 5.4, from 6.0 before 6.2, before 4134aedcff17c977da7717693ed89ce56d54c120GitHub Advisory Database, PyPA Advisory Database
zope restrictedpythonbefore 5.4, from 6.0 before 6.2NVD

All scores

GitHub_M8.3high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:L
GitHub8.3high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:L
NVD7.7high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:N/A:N
PyPA Advisory Database7.7high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:N/A:N

Classification

CWE-74

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

SourceRecordLicence
CVE ListCVE-2023-41039 changed 2024-10-01CVE Terms of Use
GitHub Advisory DatabaseGHSA-xjw2-6jm9-rf67 changed 2024-02-16CC-BY-4.0
NVDCVE-2023-41039 changed 2026-06-17Public domain
PyPA Advisory DatabasePYSEC-2023-159 changed 2023-11-08CC-BY-4.0