CVE-2024-32880
Authenticated user can upload malicious templates, leading to RCE.
- CVSS 7.2
- CWE-434
- Input Validation and Sanitization
- Remote
pyload is an open-source Download Manager written in pure Python. An authenticated user can change the download folder and upload a crafted template to the specified folder lead to remote code execution. There is no fix available at the time of publication.
- CWE
- CWE-434
- CVSS base score
- 7.2
- Published
- 2024-04-26
- OWASP
- A01 Injection
- Orthogonal defect classification
- Function
- Code defect classification
- Incorrect Functionality
- Category
- Input Validation and Sanitization
- Subcategory
- Path Traversal
- Accessibility scope
- Remote
- Impact
- Arbitrary Code Execution
- Affected component
- pyload
Solution
Upgrade to the latest version of pyload once a patch is released, and implement strict input validation and sanitization for uploaded templates.
Vulnerable code sample
import os
def upload_template(user, template_path, upload_folder):
print(f"Uploading template from {template_path} to {upload_folder}")
upload_template('authenticated_user', 'template.py', '/some//directory')Patched code sample
import os
import re
def check_path(base, path):
abs_base = os.path.abspath(base)
abs_path = os.path.abspath(path)
return os.path.commonpath([abs_base]) == os.path.commonpath([abs_base, abs_path])
def upload_template(user, template_path, upload_folder):
if not check_path('/allowed/upload/directory', upload_folder):
raise ValueError("Invalid upload directory")
if not re.match(r'^[\w\-. ]+$', os.path.basename(template_path)):
raise ValueError("Invalid template filename")
print(f"Uploading template from {template_path} to {upload_folder}")
try:
upload_template('authenticated_user', 'template.py', '/some//directory')
except ValueError as e:
print(e)Payload
# This is an example of a crafted template that could be uploaded to achieve remote code execution.
# payload.py
import os
def execute():
os.system('echo Vulnerability exploited! > /tmp/exploit.txt')
execute()
Cite this entry
@misc{vaitp:cve202432880,
title = {{Authenticated user can upload malicious templates, leading to RCE.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2024},
note = {VAITP Python Vulnerability Dataset, entry CVE-2024-32880},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2024-32880/}}
}
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 ::
