CVE-2015-5652
Untrusted search path vulnerability in python.exe
- CVSS 7.2
- CWE-426: Untrusted Search Path
- Configuration Issues
- Local
Untrusted search path vulnerability in python.exe in Python through 3.5.0 on Windows allows local users to gain privileges via a Trojan horse readline.pyd file in the current working directory. NOTE: the vendor says "It was determined that this is a longtime behavior of Python that cannot really be altered at this point."
- CVSS base score
- 7.2
- Published
- 2015-10-06
- OWASP
- A08 Software and Data Integrity Failures
- Orthogonal defect classification
- Build/Package/Merge
- Code defect classification
- Packaging Issues
- Category
- Configuration Issues
- Subcategory
- Local File Inclusion (LFI)
- Accessibility scope
- Local
- Impact
- Privilege Escalation
- Fixed by upgrading
- Yes
Solution
Upgrade Python to a version beyond 3.5.0.
Vulnerable code sample
import os
import readline
# VULNERABLE: Using os.system with untrusted input
# This allows command injection and path manipulation
os.system("whoami")Patched code sample
import os
import pwd
import sys
import importlib.util
def safe_get_user():
# SECURE: Use built-in pwd module instead of external commands
try:
return pwd.getpwuid(os.getuid()).pw_name
except (KeyError, OSError) as e:
return f"Error: {str(e)}"
def secure_module_import():
# SECURE: Validate import paths and use secure mechanisms
try:
# Validate Python installation path
python_dir = os.path.dirname(sys.executable)
if not os.path.isabs(python_dir):
raise ValueError("Invalid Python directory path")
# Use importlib for secure module checking
spec = importlib.util.find_spec('readline')
return spec is not None
except (ImportError, ValueError) as e:
return False
def validate_search_path():
# SECURE: Validate and sanitize Python search paths
safe_paths = []
for path in sys.path:
# Only include absolute paths within safe directories
if os.path.isabs(path) and not path.startswith('/tmp'):
safe_paths.append(path)
return safe_paths
# Example of secure usage - no external command execution
user = safe_get_user() # Uses pwd module instead of whoami command
has_readline = secure_module_import() # Secure module validation
safe_paths = validate_search_path() # Path validationCite this entry
@misc{vaitp:cve20155652,
title = {{Untrusted search path vulnerability in python.exe}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2015},
note = {VAITP Python Vulnerability Dataset, entry CVE-2015-5652},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2015-5652/}}
}
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 ::
