CVE-2023-51208
Arbitrary file upload in ROS2 Foxy allowing code execution (disputed).
- CVSS 9.8
- CWE-434
- Input Validation and Sanitization
- Remote
An Arbitrary File Upload vulnerability in ROS2 Foxy Fitzroy ROS_VERSION=2 and ROS_PYTHON_VERSION=3 allows attackers to run arbitrary code and cause other impacts via upload of crafted file. NOTE: this is disputed by multiple third parties who believe there was not reasonable evidence to determine the existence of a vulnerability.
- CWE
- CWE-434
- CVSS base score
- 9.8
- Published
- 2024-01-23
- OWASP
- A08 Software and Data Integrity Failures
- Orthogonal defect classification
- Checking
- Code defect classification
- Missing Check
- Category
- Input Validation and Sanitization
- Subcategory
- Insecure Direct Object References (IDOR)
- Accessibility scope
- Remote
- Impact
- Arbitrary Code Execution
- Affected component
- ROS2
Solution
Upgrade ROS 2 to a newer LTS release (e.g., ROS 2 Humble Hawksbill 2.0 or later), which includes the fix for the arbitrary file‑upload issue.
Vulnerable code sample
import os
from rclpy.node import Node
from example_interfaces.srv import Trigger
class FileUploadService(Node):
def __init__(self):
super().__init__('file_upload_service')
self.srv = self.create_service(Trigger, 'upload_file', self.handle_upload)
# VULNERABLE: writes user‑provided filename without validation
def handle_upload(self, request, response):
# request.file_name and request.file_content are assumed
file_path = os.path.join('/var/tmp/uploads', request.file_name)
with open(file_path, 'wb') as f:
f.write(request.file_content)
response.success = True
response.message = f'Saved to {file_path}'
return responsePatched code sample
import os
from rclpy.node import Node
from example_interfaces.srv import Trigger
import pathlib
class FileUploadService(Node):
def __init__(self):
super().__init__('file_upload_service')
self.srv = self.create_service(Trigger, 'upload_file', self.handle_upload)
# FIX: sanitizes filename and restricts to upload directory
def handle_upload(self, request, response):
# request.file_name and request.file_content are assumed
safe_name = pathlib.Path(request.file_name).name # strip directories
upload_dir = pathlib.Path('/var/tmp/uploads')
file_path = upload_dir / safe_name
# ensure the final path is inside the intended directory
if upload_dir.resolve() not in file_path.resolve().parents:
response.success = False
response.message = 'Invalid filename'
return response
with open(file_path, 'wb') as f:
f.write(request.file_content)
response.success = True
response.message = f'Saved to {file_path}'
return responseCite this entry
@misc{vaitp:cve202351208,
title = {{Arbitrary file upload in ROS2 Foxy allowing code execution (disputed).}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2024},
note = {VAITP Python Vulnerability Dataset, entry CVE-2023-51208},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2023-51208/}}
}
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 ::
