VAITP Dataset

← Back to the dataset

CVE-2023-0297

Code injection vulnerability in pyload/pyload < 0.5.0b3.dev31

  • CVSS 9.8
  • CWE-94 Improper Control of Generation of Code ('Code Injection')
  • Input Validation and Sanitization
  • Remote

Code Injection in GitHub repository pyload/pyload prior to 0.5.0b3.dev31.

CVSS base score
9.8
Published
2023-01-14
OWASP
A03 Injection
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
pyload
Fixed by upgrading
Yes

Solution

Update pyload to version 0.5.0b3.dev31 or higher.

Vulnerable code sample

import subprocess

def execute_command(command):
    # Directly using user input in a shell command, which is vulnerable to injection
    result = subprocess.run(command, shell=True, capture_output=True, text=True)
    return result.stdout

# Example of using the execute_command function
user_input = "ls; rm -rf /"  # Example of malicious input
output = execute_command(user_input)
print(output)

Patched code sample

import subprocess

def safe_execute(command):
    # Use a list to avoid shell injection vulnerabilities
    command_list = command.split()
    result = subprocess.run(command_list, capture_output=True, text=True)
    return result.stdout

# Example of using the safe_execute function
user_input = "ls"  # Replace with user input safely
output = safe_execute(user_input)
print(output)

Published fix

Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.

Cite this entry

@misc{vaitp:cve20230297,
  title        = {{Code injection vulnerability in pyload/pyload < 0.5.0b3.dev31}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2023},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2023-0297},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2023-0297/}}
}

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.