4.4medium
Remote Code Execution via unsafe classes in otherwise permitted modules
- Severity
- 4.4medium CVSS:3.1 by GitHub_M
- Exploit likelihood
- 2.11% (higher than 82% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-qcx9-j53g-ccgfPYSEC-2021-335PYSEC-2021-875
Description
The module `AccessControl` defines security policies for Python code used in restricted code within Zope applications. Restricted code is any code that resides in Zope's object database, such as the contents of `Script (Python)` objects. The policies defined in `AccessControl` severely restrict access to Python modules and only exempt a few that are deemed safe, such as Python's `string` module. However, full access to the `string` module also allows access to the class `Formatter`, which can be overridden and extended within `Script (Python)` in a way that provides access to other unsafe Python libraries. Those unsafe Python libraries can be used for remote code execution. By default, you need to have the admin-level Zope "Manager" role to add or edit `Script (Python)` objects through the web. Only sites that allow untrusted users to add/edit these scripts through the web - which would be a very unusual configuration to begin with - are at risk. The problem has been fixed in AccessControl 4.3 and 5.2. Only AccessControl versions 4 and 5 are vulnerable, and only on Python 3, not Python 2.7. As a workaround, a site administrator can restrict adding/editing `Script (Python)` objects through the web using the standard Zope user/role permission mechanisms. Untrusted users should not be assigned the Zope Manager role and adding/editing these scripts through the web should be restricted to trusted users only. This is the default configuration in Zope.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| zopefoundation AccessControl | >= 4.0, < 4.3, >= 5.0, < 5.2 | CVE List |
| accesscontrol (PyPI) | from 4.0 before 4.3, from 5.0 before 5.2, before b42dd4badf803bb9fb71ac34cd9cb0c249262f2c | GitHub Advisory Database, PyPA Advisory Database |
| zope (PyPI) | from 4.0 before 4.3, from 5.0 before 5.2, before b42dd4badf803bb9fb71ac34cd9cb0c249262f2c | GitHub Advisory Database, PyPA Advisory Database |
| zope accesscontrol | from 4.0 before 4.3, from 5.0 before 5.2 | NVD |
All scores
| GitHub_M | 4.4medium CVSS:3.1 | CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:U/C:N/I:H/A:N |
| GitHub | 4.4medium CVSS:3.1 | CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:U/C:N/I:H/A:N |
| GitHub | medium CVSS:4.0 | CVSS:4.0/AV:N/AC:L/AT:P/PR:H/UI:N/VC:N/VI:H/VA:N/SC:N/SI:N/SA:N |
| NVD | 7.2high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H |
| NVD | 6.5medium CVSS:2.0 | AV:N/AC:L/Au:S/C:P/I:P/A:P |
Classification
What each source says
CVE List
The module `AccessControl` defines security policies for Python code used in restricted code within Zope applications. Restricted code is any code that resides in Zope's object database, such as the contents of `Script (Python)` objects. The policies defined in `AccessControl` severely restrict access to Python modules and only exempt a few that are deemed safe, such as Python's `string` module. However, full access to the `string` module also allows access to the class `Formatter`, which can be overridden and extended within `Script (Python)` in a way that provides access to other unsafe Python libraries. Those unsafe Python libraries can be used for remote code execution. By default, you need to have the admin-level Zope "Manager" role to add or edit `Script (Python)` objects through the web. Only sites that allow untrusted users to add/edit these scripts through the web - which would be a very unusual configuration to begin with - are at risk. The problem has been fixed in AccessControl 4.3 and 5.2. Only AccessControl versions 4 and 5 are vulnerable, and only on Python 3, not Python 2.7. As a workaround, a site administrator can restrict adding/editing `Script (Python)` objects through the web using the standard Zope user/role permission mechanisms. Untrusted users should not be assigned the Zope Manager role and adding/editing these scripts through the web should be restricted to trusted users only. This is the default configuration in Zope.
GitHub Advisory Database
Impact
The module AccessControl defines security policies for Python code used in restricted code within Zope applications. Restricted code is any code that resides in Zope's object database, such as the contents of Script (Python) objects.
The policies defined in AccessControl severely restrict access to Python modules and only exempt a few that are deemed safe, such as Python's string module. However, full access to the string module also allows access to the class Formatter, which can be overridden and extended within Script (Python) in a way that provides access to other unsafe Python libraries. Those unsafe Python libraries can be used for remote code execution.
By default, you need to have the admin-level Zope "Manager" role to add or edit Script (Python) objects through the web. Only sites that allow untrusted users to add/edit these scripts through the web - which would be a very unusual configuration to begin with - are at risk.
Patches
The problem has been fixed in AccessControl 4.3 and 5.2. Only AccessControl versions 4 and 5 are vulnerable, and only on Python 3, not Python 2.7.
Workarounds
A site administrator can restrict adding/editing Script (Python) objects through the web using the standard Zope user/role permission mechanisms. Untrusted users should not be assigned the Zope Manager role and adding/editing these scripts through the web should be restricted to trusted users only. This is the default configuration in Zope.
For more information
If you have any questions or comments about this advisory:
- Open an issue in the AccessControl issue tracker
- Email us at security@plone.org
NVD (es)
El módulo "AccessControl" define las políticas de seguridad para el código Python usado en el código restringido dentro de las aplicaciones de Zope. El código restringido es cualquier código que reside en la base de datos de objetos de Zope, como el contenido de los objetos "Script (Python)". Las políticas definidas en "AccessControl" restringen severamente el acceso a los módulos de Python y sólo eximen a unos pocos que se consideran seguros, como el módulo "string" de Python. Sin embargo, el acceso completo al módulo "string" también permite el acceso a la clase "Formatter", que puede ser sobrescrita y extendida dentro de "Script (Python)" de manera que proporciona acceso a otras bibliotecas no seguras de Python. Estas bibliotecas no seguras de Python pueden ser usadas para una ejecución de código remota . Por defecto, necesitas tener el rol de "Manager" de Zope a nivel de administrador para añadir o editar objetos "Script (Python)" mediante la web. Sólo los sitios que permiten a usuarios no confiables añadir/editar estos scripts a través de la web - lo que sería una configuración muy inusual para empezar - están en riesgo. El problema se ha corregido en AccessControl versiones 4.3 y 5.2. Sólo las versiones 4 y 5 de AccessControl son vulnerables, y sólo en Python 3, no en Python 2.7. Como solución, un administrador del sitio puede restringir la adición/edición de objetos "Script (Python)" mediante la web usando los mecanismos estándar de permisos de usuario/rol de Zope. A unos usuarios que no son de confianza no se les debería asignar el rol de Administrador de Zope y añadir/editar estos scripts mediante la web debería estar restringido sólo a usuarios de confianza. Esta es la configuración predeterminada en Zope
References
Related
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2021-32807 changed 2024-08-03 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-qcx9-j53g-ccgf changed 2026-07-09 | CC-BY-4.0 |
| NVD | CVE-2021-32807 changed 2026-06-17 | Public domain |
| PyPA Advisory Database | PYSEC-2021-335 changed 2026-07-09 | CC-BY-4.0 |
| PyPA Advisory Database | PYSEC-2021-875 changed 2026-07-09 | CC-BY-4.0 |