VAITP Dataset

← Back to the dataset

CVE-2009-4081

Untrusted search path vulnerability in dstat (before r3199) allows local privilege escalation via a malicious Python module in the current directory

  • CVSS 4.4
  • CWE-426: Untrusted Search Path (Score: 7.1)
  • Authentication, Authorization, and Session Management
  • Local

Untrusted search path vulnerability in dstat before r3199 allows local users to gain privileges via a Trojan horse Python module in the current working directory, a different vulnerability than CVE-2009-3894.

CVSS base score
4.4
Published
2009-11-29
OWASP
A06 Vulnerable and Outdated Components
Orthogonal defect classification
Function
Code defect classification
Incorrect Functionality
Category
Authentication, Authorization, and Session Management
Subcategory
Privilege Escalation
Accessibility scope
Local
Impact
Privilege Escalation
Affected component
dstat
Fixed by upgrading
Yes

Solution

Update dstat to version r3199 or higher.

Vulnerable code sample

import os

# Vulnerable code that allows untrusted modules from the current working directory to be imported

# This code does not filter out the current working directory from sys.path
# which can lead to loading a Trojan horse module if it exists in the current directory.

# Example of importing a module
try:
    import your_module  # This could be a Trojan horse module in the current directory
except ImportError:
    print("Module not found or import failed.")

Patched code sample

import sys
import os

# Fix for CVE-2009-4081: Ensure that the current working directory is not included in sys.path
# when importing modules. This prevents loading of untrusted modules.

# Save the original sys.path
original_sys_path = sys.path.copy()

# Remove the current working directory from sys.path
sys.path = [p for p in sys.path if p != os.getcwd()]

# Now, when you import modules, it won't include the current directory
# Example import (replace 'your_module' with the actual module name)
try:
    import your_module
except ImportError:
    print("Module not found or import failed.")

# Restore the original sys.path if needed
sys.path = original_sys_path

Cite this entry

@misc{vaitp:cve20094081,
  title        = {{Untrusted search path vulnerability in dstat (before r3199) allows local privilege escalation via a malicious Python module in the current directory}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2009},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2009-4081},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2009-4081/}}
}

Download this entry as JSON Download the whole dataset

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 ::

Before you use the VAITP AI models

Please read and accept the following disclaimer:

By choosing "I understand and accept", you acknowledge that you understand and agree to these terms.