{"id":493,"cve":"CVE-2009-0318","cve_url":"https:\/\/www.cvedetails.com\/cve\/CVE-2009-0318","cwe":"CWE-426: Untrusted Search Path","cwe_number":426,"cwe_url":"https:\/\/cwe.mitre.org\/data\/definitions\/426","cvss_score":6.9,"published":"2009-01-28","owasp":"A06 Vulnerable and Outdated Components","odc":"Function","cdc":"Incorrect Functionality","category":"Authentication, Authorization, and Session Management","subcategory":"Privilege Escalation","scope":"Local","impact":"Arbitrary Code Execution","summary":"Untrusted search path vulnerability in Gnumeric's Python interpreter allows local code execution with a malicious Python file in the current directory","permalink":"https:\/\/netpack.pt\/vaitp\/vulnerability\/CVE-2009-0318\/","description":"Untrusted search path vulnerability in the GObject Python interpreter wrapper in Gnumeric allows local users to execute arbitrary code via a Trojan horse Python file in the current working directory, related to a vulnerability in the PySys_SetArgv function (CVE-2008-5983).","solution":"Update Gnumeric to a version that addresses CVE-2008-5983.","affected_component":"GObject","fixed_by_upgrading":true,"vulnerable_code":"import os\nimport sys\n\n# Vulnerable code demonstrating untrusted search path\n# The current working directory is included in sys.path\n\n# Print the current working directory\nprint(\"Current working directory:\", os.getcwd())\n\n# The current directory is included in sys.path, allowing for potential\n# execution of a Trojan horse Python file.\nsys.path.append(os.getcwd())\n\n# Attempt to import a module that may be present in the current directory\ntry:\n    import some_module  # This could be a Trojan horse if it exists in the cwd\nexcept ImportError as e:\n    print(\"Import failed:\", e)","patched_code":"import os\nimport sys\n\n# Fix for CVE-2009-0318: Set the Python module search path to a safe location\n# and avoid using the current working directory.\n\n# Define a safe directory for module imports\nsafe_directory = '\/usr\/lib\/python3\/dist-packages'  # Example safe path\n\n# Update sys.path to include only the safe directory\nsys.path = [safe_directory] + [p for p in sys.path if p != os.getcwd()]\n\n# Now you can safely import modules without the risk of executing\n# a Trojan horse Python file in the current working directory.","payload_needed":false,"payload":null,"payload_status":"none","published_fix":[],"references":null}