{"id":506,"cve":"CVE-2008-5987","cve_url":"https:\/\/www.cvedetails.com\/cve\/CVE-2008-5987","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":"Design Defects","subcategory":"Security Misconfigurations","scope":"Local","impact":"Arbitrary Code Execution","summary":"Untrusted search path vulnerability in Eye of GNOME (eog) 2.22.3 allows local users to execute arbitrary code via a Trojan horse Python file in the current working directory","permalink":"https:\/\/netpack.pt\/vaitp\/vulnerability\/CVE-2008-5987\/","description":"Untrusted search path vulnerability in the Python interface in Eye of GNOME (eog) 2.22.3, and possibly other versions, 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 Eye of GNOME (eog) to version 2.22.4 or higher.","affected_component":"Python","fixed_by_upgrading":true,"vulnerable_code":"import sys\n\n# This code simulates the untrusted search path vulnerability\n# where a malicious Python file in the current directory can be imported.\n\n# Assume a malicious file named 'malicious.py' exists in the current directory\n# and is intended to execute arbitrary code when imported.\n\n# This import could potentially load the malicious file instead of the intended module\nmodule_name = 'malicious'  # The name of the module to import\ntry:\n    imported_module = __import__(module_name)\nexcept ImportError as e:\n    print(f\"Error importing module: {e}\")","patched_code":"import sys\nimport os\n\ndef safe_import(module_name):\n    # Ensure that the module is imported from a trusted location\n    if os.path.dirname(module_name) not in sys.path:\n        raise ImportError(f\"Untrusted import attempt from {module_name}\")\n    return __import__(module_name)\n\n# Example usage\ntry:\n    my_module = safe_import('my_trusted_module')\nexcept ImportError as e:\n    print(e)","payload_needed":false,"payload":null,"payload_status":"none","published_fix":[],"references":null}