CVE-2024-20286
Python interpreter vulnerability allows sandbox escape and OS access.
- CVSS 8.8
- CWE-693
- Input Validation and Sanitization
- Local
A vulnerability in the Python interpreter of Cisco NX-OS Software could allow an authenticated, low-privileged, local attacker to escape the Python sandbox and gain unauthorized access to the underlying operating system of the device. The vulnerability is due to insufficient validation of user-supplied input. An attacker could exploit this vulnerability by manipulating specific functions within the Python interpreter. A successful exploit could allow an attacker to escape the Python sandbox and execute arbitrary commands on the underlying operating system with the privileges of the authenticated user. Note: An attacker must be authenticated with Python execution privileges to exploit these vulnerabilities. For more information regarding Python execution privileges, see product-specific documentation, such as the section of the Cisco Nexus 9000 Series NX-OS Programmability Guide.
- CWE
- CWE-693
- CVSS base score
- 8.8
- Published
- 2024-08-28
- OWASP
- A01 Injection
- Orthogonal defect classification
- Function
- Code defect classification
- Incorrect Functionality
- Category
- Input Validation and Sanitization
- Subcategory
- Command Injection
- Accessibility scope
- Local
- Impact
- Arbitrary Code Execution
- Affected component
- Python
Solution
Upgrade to the latest version of Cisco NX-OS Software that addresses this vulnerability, as specified in the Cisco security advisory.
Vulnerable code sample
import os
def execute_command(command):
"""Vulnerable function that demonstrates the security issue."""
os.system(command)
print(execute_command('ls'))
print(execute_command('rm -rf /'))Patched code sample
import subprocess
def execute_command(command):
"""Secure function that fixes the vulnerability."""
blacklisted_commands = {'rm', 'mv', 'shutdown', 'reboot', 'dd', 'mkfs'}
if any(blacklisted_command in command for blacklisted_command in blacklisted_commands):
raise ValueError("Unauthorized command")
result = subprocess.run(command, shell=True, check=True, text=True, capture_output=True)
return result.stdout
try:
print(execute_command('ls'))
print(execute_command('rm -rf /'))
except ValueError as e:
print(e)
except subprocess.CalledProcessError as e:
print(f"Command execution failed: {e}")Payload
os.system("malicious_command")
Cite this entry
@misc{vaitp:cve202420286,
title = {{Python interpreter vulnerability allows sandbox escape and OS access.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2024},
note = {VAITP Python Vulnerability Dataset, entry CVE-2024-20286},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2024-20286/}}
}
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 ::
