VAITP Dataset

← Back to the dataset

CVE-2006-0151

Sudo Privilege escalation via PYTHONINSPECT

  • CVSS 7.2
  • CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
  • Authentication, Authorization, and Session Management
  • Local

sudo 1.6.8 and other versions does not clear the PYTHONINSPECT environment variable, which allows limited local users to gain privileges via a Python script, a variant of CVE-2005-4158.

CVSS base score
7.2
Published
2006-01-09
OWASP
A05 Security Misconfiguration
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
sudo
Fixed by upgrading
Yes

Solution

Update sudo to version 1.9.0 or higher.

Vulnerable code sample

import os
import subprocess

def vulnerable_sudo_command(command):
    # Do not clear the PYTHONINSPECT environment variable
    # This allows potential exploitation of the vulnerability
    subprocess.run(['sudo'] + command)

# Example usage
vulnerable_sudo_command(['ls', '/root'])

Patched code sample

import os
import subprocess

def secure_sudo_command(command):
    # Clear the PYTHONINSPECT environment variable to mitigate CVE-2006-0151
    env = os.environ.copy()
    env.pop('PYTHONINSPECT', None)
    
    # Execute the command with sudo
    subprocess.run(['sudo'] + command, env=env)

# Example usage
secure_sudo_command(['ls', '/root'])

Cite this entry

@misc{vaitp:cve20060151,
  title        = {{Sudo Privilege escalation via PYTHONINSPECT}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2006},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2006-0151},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2006-0151/}}
}

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.