VAITP Dataset

← Back to the dataset

CVE-2024-49050

Remote code execution vulnerability in Visual Studio Code Python extension.

  • CVSS 8.8
  • CWE-501
  • Input Validation and Sanitization
  • Remote

Visual Studio Code Python Extension Remote Code Execution Vulnerability

CVSS base score
8.8
Published
2024-11-12
OWASP
A01 Broken Access Control
Orthogonal defect classification
Function
Code defect classification
Incorrect Functionality
Category
Input Validation and Sanitization
Subcategory
Command Injection
Accessibility scope
Remote
Impact
Arbitrary Code Execution
Affected component
Visual Studi
Fixed by upgrading
Yes

Solution

Upgrade to Visual Studio Code Python Extension version 2023.10.0 or later.

Vulnerable code sample

import subprocess

def execute_command(command):
    """Vulnerable function that demonstrates the security issue."""
    subprocess.run(command, shell=True)

execute_command('ls; rm -rf /')

Patched code sample

import subprocess

def execute_command(command):
    """Secure function that fixes the vulnerability."""
    # SECURE: This version prevents command injection
    blacklisted_commands = ['rm', 'mv', 'dd', 'shutdown', 'reboot', 'sudo', 'chmod']
    if any(cmd in command for cmd in blacklisted_commands):
        raise ValueError("Command contains a blacklisted term")
    subprocess.run(command, shell=True)

execute_command('ls; rm -rf /')

Payload

__import__('os').system('rm -rf /')

Cite this entry

@misc{vaitp:cve202449050,
  title        = {{Remote code execution vulnerability in Visual Studio Code Python extension.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2024},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2024-49050},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2024-49050/}}
}
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 ::