RestrictedPython vulnerable to arbitrary code execution via stack frame sandbox escape
Impact
RestrictedPython does not check access to stack frames and their attributes. Stack frames are accessible within at least generators and generator expressions, which are allowed inside RestrictedPython. An attacker with access to a RestrictedPython environment can write code that gets the current stack frame in a generator and then walk the stack all the way beyond the RestrictedPython invocation boundary, thus breaking out of the restricted scope allowing the call of unrestricted Python code and therefore potentially allowing arbitrary code execution in the Python interpreter.
All RestrictedPython deployments that allow untrusted users to write Python code in the RestrictedPython environment are at risk. In terms of Zope and Plone, this would mean deployments where the administrator allows untrusted users to create and/or edit objects of type Script (Python), DTML Method, DTML Document or Zope Page Template. This is a non-default configuration and likely to be extremely rare.
Patches
The problem has been fixed in releases 5.3 and 6.1.
Workarounds
There is no workaround available. If you cannot upgrade to the latest release you should ensure the RestrictedPython environment is only available for trusted users.
References
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:
- Nakul Choudhary (Quasar0147 on GitHub)
- despawningbone on GitHub
- Robert Xiao (nneonneo on GitHub)
Software afectado
Haz clic en una tecnología para ver todas sus vulnerabilidades.
| Plataforma | Paquete | Versiones vulnerables | Corregida en |
|---|---|---|---|
| Python (PyPI) | restrictedpython | < 5.3, >= 6.0a1.dev0, < 6.1, < 5.3 | 5.3, 6.1 |
Referencias
- https://github.com/zopefoundation/RestrictedPython/security/advisories/GHSA-wqc8-x2pr-7jqh
- https://github.com/zopefoundation/RestrictedPython/commit/c8eca66ae49081f0016d2e1f094c3d72095ef531
- https://nvd.nist.gov/vuln/detail/CVE-2023-37271
- https://github.com/pypa/advisory-database/tree/main/vulns/restrictedpython/PYSEC-2023-118.yaml
- https://github.com/zopefoundation/RestrictedPython
- Vector CVSS
CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:L- Debilidad (CWE)
CWE-913- Plataforma
- Python (PyPI)
- Paquete
restrictedpython- Publicada
- 10.07.2023
- Actualizado
- 11.10.2026 15:17
Fuentes y licencias
OSV / GitHub Advisory Database - PYSEC-2023-118 - PyPA Advisory Database; CC BY 4.0
OSV / GitHub Advisory Database - GHSA-wqc8-x2pr-7jqh - CC BY 4.0
Historial de vulnerabilidades: restrictedpython
Todas las vulnerabilidades publicadas de este paquete (Python (PyPI)), de la más reciente a la más antigua. Muestra si es un fallo aislado o un paquete que hay que vigilar.
- Entradas en total
- 6
- Primera → última
- 07.2023 09.2026
- Sin corrección
- 0
- Explotada en ataques
- 0
Distribución por gravedad
- Alta 6
Divulgaciones por año
- 2023: 2
- 2024: 1
- 2025: 1
- 2026: 2
-
RestrictedPython vulnerable to arbitrary code execution via stack frame sandbox escape esta entrada
Identifica las vulnerabilidades de tu aplicación
Con la integración de DockRay y el inventario de software activado, DockRay compara las versiones notificadas de los componentes con las vulnerabilidades conocidas y avisa de las coincidencias confirmadas. La cobertura depende de la tecnología compatible y de los avisos disponibles.