CVE-2024-8374
Code injection vulnerability in Cura's 3MF file handling allows arbitrary code execution.
- CVSS 7.8
- CWE-94
- Input Validation and Sanitization
- Remote
UltiMaker Cura slicer versions 5.7.0-beta.1 through 5.7.2 are vulnerable to code injection via the 3MF format reader (/plugins/ThreeMFReader.py). The vulnerability arises from improper handling of the drop_to_buildplate property within 3MF files, which are ZIP archives containing the model data. When a 3MF file is loaded in Cura, the value of the drop_to_buildplate property is passed to the Python eval() function without proper sanitization, allowing an attacker to execute arbitrary code by crafting a malicious 3MF file. This vulnerability poses a significant risk as 3MF files are commonly shared via 3D model databases.
- CWE
- CWE-94
- CVSS base score
- 7.8
- Published
- 2024-09-03
- OWASP
- A01 Broken Access Control
- Orthogonal defect classification
- Algorithm
- Code defect classification
- Incorrect Functionality
- Category
- Input Validation and Sanitization
- Subcategory
- Command Injection
- Accessibility scope
- Remote
- Impact
- Arbitrary Code Execution
- Affected component
- Python
Solution
Upgrade to UltiMaker Cura version 5.7.3 or later, which includes a patch for this vulnerability.
Vulnerable code sample
import zipfile
import xml.etree.ElementTree as ET
def read_3mf(file_path):
"""Vulnerable function that demonstrates the security issue."""
with zipfile.ZipFile(file_path, 'r') as z:
with z.open('3D/3DModel.model') as model_file:
tree = ET.parse(model_file)
root = tree.getroot()
drop_to_buildplate = root.find('.//drop_to_buildplate').text
eval_value = eval(drop_to_buildplate)
print("Drop to buildplate value:", eval_value)Patched code sample
import zipfile
import xml.etree.ElementTree as ET
import ast
def read_3mf(file_path):
"""Secure function that fixes the vulnerability."""
# SECURE: This version prevents command injection
with zipfile.ZipFile(file_path, 'r') as z:
with z.open('3D/3DModel.model') as model_file:
tree = ET.parse(model_file)
root = tree.getroot()
drop_to_buildplate = root.find('.//drop_to_buildplate').text
eval_value = ast.literal_eval(drop_to_buildplate)
print("Drop to buildplate value:", eval_value)Payload
__import__('os').system('echo vulnerable > /tmp/vulnerable.txt')
Cite this entry
@misc{vaitp:cve20248374,
title = {{Code injection vulnerability in Cura's 3MF file handling allows arbitrary code execution.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2024},
note = {VAITP Python Vulnerability Dataset, entry CVE-2024-8374},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2024-8374/}}
}
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 ::
