CVE-2008-5984
Untrusted search path in Dia 0.96.1 allows local users to execute arbitrary code via a malicious Python file
- CVSS 6.9
- CWE-426: Untrusted Search Path
- Input Validation and Sanitization
- Local
Untrusted search path vulnerability in the Python plugin in Dia 0.96.1, 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).
- CVSS base score
- 6.9
- Published
- 2009-01-28
- OWASP
- A06 Vulnerable and Outdated Components
- Orthogonal defect classification
- Function
- Code defect classification
- Incorrect Functionality
- Category
- Input Validation and Sanitization
- Subcategory
- Insecure Parsing or Deserialization
- Accessibility scope
- Local
- Impact
- Arbitrary Code Execution
- Affected component
- Python
- Fixed by upgrading
- Yes
Solution
Update Dia to version 0.97.3 or higher.
Vulnerable code sample
import os
import sys
def load_module(module_name):
# This function directly imports a module without checking the path
return __import__(module_name)
# Example usage
# If there is a malicious module named 'my_trojan_module.py' in the current directory,
# it could be imported without any checks.
my_module = load_module('my_trojan_module')Patched code sample
import os
import sys
def safe_import(module_name):
# Get the absolute path of the current working directory
current_dir = os.path.abspath(os.getcwd())
# Get the directory of the module to be imported
module_path = os.path.dirname(module_name)
# Ensure the module path is safe (not in the current working directory)
if module_path and os.path.abspath(module_path) == current_dir:
raise ImportError("Unsafe import from the current working directory is not allowed.")
# Proceed with the import if it's safe
return __import__(module_name)
# Example usage
try:
my_module = safe_import('my_trojan_module')
except ImportError as e:
print(e)Cite this entry
@misc{vaitp:cve20085984,
title = {{Untrusted search path in Dia 0.96.1 allows local users to execute arbitrary code via a malicious Python file}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2009},
note = {VAITP Python Vulnerability Dataset, entry CVE-2008-5984},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2008-5984/}}
}
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 ::
