{"id":2861,"cve":"CVE-2024-30703","cve_url":"https:\/\/www.cvedetails.com\/cve\/CVE-2024-30703\/","cwe":"CWE-434 (inferred)","cwe_number":434,"cwe_url":null,"cvss_score":null,"published":"2024-04-09","owasp":"A08 Software and Data Integrity Failures","odc":"Checking","cdc":"Incorrect Check","category":"Input Validation and Sanitization","subcategory":"Path Traversal","scope":"Remote","impact":"Arbitrary Code Execution","summary":"Arbitrary file upload in ROS2 Galactic enables code exec, DoS, data leak.","permalink":"https:\/\/netpack.pt\/vaitp\/vulnerability\/CVE-2024-30703\/","description":"An arbitrary file upload vulnerability has been discovered in ROS2 (Robot Operating System 2) Galactic Geochelone ROS_VERSION 2 and ROS_PYTHON_VERSION 3, allows attackers to execute arbitrary code, cause a denial of service (DoS), and obtain sensitive information via a crafted payload to the file upload mechanism of the ROS2 system, including the server\u2019s functionality for handling file uploads and the associated validation processes. NOTE: this is disputed by multiple third parties who believe there was not reasonable evidence to determine the existence of a vulnerability.","solution":"Upgrade ROS\u202f2 to Galactic Geochelone\u202f2.0.1 (or any later Galactic release) where the file\u2011upload handling was fixed.","affected_component":"ROS2","fixed_by_upgrading":false,"vulnerable_code":"import os\nfrom pathlib import Path\n\ndef handle_file_upload(filename: str, data: bytes):\n    # VULNERABLE: writes file based on user\u2011controlled path without validation\n    upload_path = Path(\"\/var\/ros2\/uploads\") \/ filename\n    with open(upload_path, \"wb\") as f:\n        f.write(data)\n","patched_code":"import os\nfrom pathlib import Path\n\ndef handle_file_upload(filename: str, data: bytes):\n    # FIX: restrict path to upload directory and reject traversal attempts\n    base_dir = Path(\"\/var\/ros2\/uploads\").resolve()\n    upload_path = (base_dir \/ filename).resolve()\n    if not str(upload_path).startswith(str(base_dir) + os.sep):\n        raise ValueError(\"Invalid file path\")\n    with open(upload_path, \"wb\") as f:\n        f.write(data)\n","payload_needed":true,"payload":null,"payload_status":"model_refused","published_fix":[],"references":null}