VAITP Dataset

← Back to the dataset

CVE-2009-0317

Nautilus-python Malicious Python file in current directory can execute local code

  • CVSS 6.9
  • CWE-426: Untrusted Search Path
  • Design Defects
  • Local

Untrusted search path vulnerability in the Python language bindings for Nautilus (nautilus-python) 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
A05 Security Misconfiguration
Orthogonal defect classification
Function
Code defect classification
Incorrect Functionality
Category
Design Defects
Subcategory
Security Misconfigurations
Accessibility scope
Local
Impact
Arbitrary Code Execution
Affected component
Python
Fixed by upgrading
Yes

Solution

Update nautilus-python to a version that fixes CVE-2008-5983.

Vulnerable code sample

import os
import sys

def vulnerable_import(module_name):
    # This will import the module from the current working directory
    __import__(module_name)

# Usage example
if __name__ == "__main__":
    # This could allow a Trojan horse file to be executed
    vulnerable_import('malicious_module')

Patched code sample

import os
import sys

def safe_import(module_name):
    # Get the absolute path of the current script
    current_dir = os.path.dirname(os.path.abspath(__file__))
    
    # Construct the expected path for the module
    expected_path = os.path.join(current_dir, module_name + '.py')

    # Check if the module exists in the current directory
    if os.path.isfile(expected_path):
        # Import the module safely
        __import__(module_name)
    else:
        raise ImportError(f"{module_name} not found in the expected path.")

# Usage example
if __name__ == "__main__":
    # Ensure the current working directory is safe
    safe_import('my_module')

Cite this entry

@misc{vaitp:cve20090317,
  title        = {{Nautilus-python Malicious Python file in current directory can execute local code}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2009},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2009-0317},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2009-0317/}}
}

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.