CVE-2021-32807
JSON

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 packageVersionsReported by
zopefoundation AccessControl>= 4.0, < 4.3, >= 5.0, < 5.2CVE List
accesscontrol (PyPI)from 4.0 before 4.3, from 5.0 before 5.2, before b42dd4badf803bb9fb71ac34cd9cb0c249262f2cGitHub Advisory Database, PyPA Advisory Database
zope (PyPI)from 4.0 before 4.3, from 5.0 before 5.2, before b42dd4badf803bb9fb71ac34cd9cb0c249262f2cGitHub Advisory Database, PyPA Advisory Database
zope accesscontrolfrom 4.0 before 4.3, from 5.0 before 5.2NVD

All scores

GitHub_M4.4medium CVSS:3.1CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:U/C:N/I:H/A:N
GitHub4.4medium CVSS:3.1CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:U/C:N/I:H/A:N
GitHubmedium CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:P/PR:H/UI:N/VC:N/VI:H/VA:N/SC:N/SI:N/SA:N
NVD7.2high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H
NVD6.5medium CVSS:2.0AV: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:

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

https://github.com/zopefoundation/AccessControl/security/advisories/GHSA-qcx9-j53g-ccgfadvisory, third-party-advisory, web
https://github.com/zopefoundation/AccessControl/commit/b42dd4badf803bb9fb71ac34cd9cb0c249262f2cfix, patch, third-party-advisory, web
https://github.com/zopefoundation/AccessControl/blob/master/CHANGES.rst#51-2021-07-30release-notes, third-party-advisory, web
https://github.com/zopefoundation/Zope/security/advisories/GHSA-g4gq-j4p2-j8frweb
https://nvd.nist.gov/vuln/detail/CVE-2021-32807advisory
https://github.com/zopefoundation/AccessControl/commit/ae2dab0cc34e6dd1561c5b12d4a56cd140f87e1dweb
https://github.com/zopefoundation/Zope/commit/869f947e586517566509e0ccdd4d99b60704cc02web
https://github.com/zopefoundation/Zope/commit/f72a18dda8e9bf2aedb46168761668464a4be988web
https://github.com/pypa/advisory-database/tree/main/vulns/accesscontrol/PYSEC-2021-335.yamlweb
https://github.com/pypa/advisory-database/tree/main/vulns/accesscontrol/PYSEC-2021-370.yamlweb
https://github.com/pypa/advisory-database/tree/main/vulns/zope/PYSEC-2021-368.yamlweb
https://github.com/pypa/advisory-database/tree/main/vulns/zope/PYSEC-2021-875.yamlweb

Related

Sources

SourceRecordLicence
CVE ListCVE-2021-32807 changed 2024-08-03CVE Terms of Use
GitHub Advisory DatabaseGHSA-qcx9-j53g-ccgf changed 2026-07-09CC-BY-4.0
NVDCVE-2021-32807 changed 2026-06-17Public domain
PyPA Advisory DatabasePYSEC-2021-335 changed 2026-07-09CC-BY-4.0
PyPA Advisory DatabasePYSEC-2021-875 changed 2026-07-09CC-BY-4.0