CVE-2021-32674
TAL expression traversal vulnerabilities in Zope
- CVSS 8.8
- CWE-22 Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
- Input Validation and Sanitization
- Remote
Zope is an open-source web application server. This advisory extends the previous advisory at https://github.com/zopefoundation/Zope/security/advisories/GHSA-5pr9-v234-jw36 with additional cases of TAL expression traversal vulnerabilities. Most Python modules are not available for using in TAL expressions that you can add through-the-web, for example in Zope Page Templates. This restriction avoids file system access, for example via the 'os' module. But some of the untrusted modules are available indirectly through Python modules that are available for direct use. By default, you need to have the Manager role to add or edit Zope Page Templates through the web. Only sites that allow untrusted users to add/edit Zope Page Templates through the web are at risk. The problem has been fixed in Zope 5.2.1 and 4.6.1. The workaround is the same as for https://github.com/zopefoundation/Zope/security/advisories/GHSA-5pr9-v234-jw36: A site administrator can restrict adding/editing Zope Page Templates through the web using the standard Zope user/role permission mechanisms. Untrusted users should not be assigned the Zope Manager role and adding/editing Zope Page Templates through the web should be restricted to trusted users only.
- CVSS base score
- 8.8
- Published
- 2021-06-08
- OWASP
- A01 Broken Access Control
- Orthogonal defect classification
- Function
- Code defect classification
- Missing Functionality
- Category
- Input Validation and Sanitization
- Subcategory
- Path Traversal
- Accessibility scope
- Remote
- Impact
- Arbitrary Code Execution
- Fixed by upgrading
- Yes
Solution
Update Zope to version 5.2.1 or 4.6.1.
Vulnerable code sample
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
class ModifiedPageTemplate(PageTemplateFile):
def __init__(self, id, text, **kwargs):
super().__init__(id, text, **kwargs)
def render(self, *args, **kwargs):
return super().render(*args, **kwargs)Patched code sample
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
import os
class ModifiedPageTemplate(PageTemplateFile):
def __init__(self, filename, dir_path, **kwargs):
full_path = os.path.abspath(os.path.join(dir_path, filename))
if not full_path.startswith(os.path.abspath(dir_path)):
raise ValueError("Invalid template path.")
if not os.path.isfile(full_path):
raise FileNotFoundError("Template file does not exist.")
super().__init__(filename, dir_path, **kwargs)
def render(self, *args, **kwargs):
return super().render(*args, **kwargs)Cite this entry
@misc{vaitp:cve202132674,
title = {{TAL expression traversal vulnerabilities in Zope}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2021},
note = {VAITP Python Vulnerability Dataset, entry CVE-2021-32674},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2021-32674/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.
The supreme art of war is to subdue the enemy without fighting.
Sun Tzu – “The Art of War”
:: Shaping the future through research and ingenuity ::
