VAITP Dataset

← Back to the dataset

CVE-2009-3894

Untrusted search path vuln in dstat < 0.7.0 lets local users gain privileges via a malicious Python module in current/subdirectory

  • CVSS 4.4
  • CWE-427: Uncontrolled Search Path Element
  • Authentication, Authorization, and Session Management
  • Local

Multiple untrusted search path vulnerabilities in dstat before 0.7.0 allow local users to gain privileges via a Trojan horse Python module in (1) the current working directory or (2) a certain subdirectory of the current working directory.

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 0.7.0 or higher.

Vulnerable code sample

import os

# Vulnerable code that can import modules from the current working directory
def unsafe_import(module_name):
    # This will import the module from the current working directory or any subdirectory
    module = __import__(module_name)
    return module

# Usage example
if __name__ == "__main__":
    # Example of importing a potentially malicious module
    my_module = unsafe_import('my_module')

Patched code sample

import os
import sys

# Ensure the script only uses the standard library paths
def secure_import(module_name):
    # Get the standard library paths
    std_lib_paths = [p for p in sys.path if os.path.isdir(p) and p != os.getcwd()]
    
    # Check if the module exists in standard library paths
    for path in std_lib_paths:
        try:
            module = __import__(module_name, fromlist=[''])
            return module
        except ImportError:
            continue
    raise ImportError(f"Module {module_name} not found in secure paths.")

# Usage example
if __name__ == "__main__":
    # Example of importing a module securely
    my_module = secure_import('my_module')

Cite this entry

@misc{vaitp:cve20093894,
  title        = {{Untrusted search path vuln in dstat < 0.7.0 lets local users gain privileges via a malicious Python module in current/subdirectory}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2009},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2009-3894},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2009-3894/}}
}

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.