VAITP Dataset

← Back to the dataset

CVE-2019-17664

Untrusted search path in Ghidra 9.0.4 allows code execution via cmd.exe

  • CVSS 7.8
  • CWE-426 Untrusted Search Path
  • Input Validation and Sanitization
  • Local

NSA Ghidra through 9.0.4 uses a potentially untrusted search path. When executing Ghidra from a given path, the Java process working directory is set to this path. Then, when launching the Python interpreter via the "Ghidra Codebrowser > Window > Python" option, Ghidra will try to execute the cmd.exe program from this working directory.

CVSS base score
7.8
Published
2019-10-16
OWASP
A05 Security Misconfiguration
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
Ghidra
Fixed by upgrading
Yes

Solution

Update Ghidra to version 9.2 or higher.

Vulnerable code sample

import os
import subprocess

def launch_python_interpreter():
    # Get the current working directory (potentially untrusted)
    current_dir = os.getcwd()

    # Attempt to execute cmd.exe from the current working directory
    try:
        subprocess.run([os.path.join(current_dir, 'cmd.exe')], check=True)
    except subprocess.CalledProcessError as e:
        print(f"Error executing cmd.exe: {e}")

# Call the function to launch the interpreter
launch_python_interpreter()

Patched code sample

import os
import subprocess
import sys

def secure_launch_python_interpreter():
    # Get the current working directory
    current_dir = os.getcwd()
    
    # Define a safe path for executing commands
    safe_path = os.path.abspath("/path/to/safe/directory")

    # Change the working directory to a safe path
    os.chdir(safe_path)

    # Launch the Python interpreter securely
    try:
        subprocess.run([sys.executable, '-i'], check=True)
    except subprocess.CalledProcessError as e:
        print(f"Error launching Python interpreter: {e}")

# Call the secure function to launch the interpreter
secure_launch_python_interpreter()

Cite this entry

@misc{vaitp:cve201917664,
  title        = {{Untrusted search path in Ghidra 9.0.4 allows code execution via cmd.exe}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2019},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2019-17664},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2019-17664/}}
}

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.