CVE-2024-39205
Arbitrary code execution in pyload-ng v0.5.0b3.dev85 via crafted HTTP request.
- CVSS 9.8
- CWE-94
- Input Validation and Sanitization
- Remote
An issue in pyload-ng v0.5.0b3.dev85 running under python3.11 or below allows attackers to execute arbitrary code via a crafted HTTP request.
- CWE
- CWE-94
- CVSS base score
- 9.8
- Published
- 2024-10-28
- 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
- pyload-ng
- Fixed by upgrading
- Yes
Solution
Upgrade to pyload-ng v0.5.0b4 or later.
Vulnerable code sample
from flask import Flask, request
import subprocess
app = Flask(__name__)
@app.route('/execute', methods=['POST'])
def execute():
"""Vulnerable function that demonstrates the security issue."""
data = request.get_json()
command = data.get('command')
result = subprocess.run(command, shell=True, capture_output=True, text=True)
return {'output': result.stdout, 'error': result.stderr}
if __name__ == '__main__':
app.run()Patched code sample
from flask import Flask, request, abort
import subprocess
import json
app = Flask(__name__)
@app.route('/execute', methods=['POST'])
def execute():
"""Secure function that fixes the vulnerability."""
# SECURE: This version prevents command injection
data = request.get_json()
if 'command' not in data or not isinstance(data['command'], str):
abort(400, 'Invalid command')
allowed_commands = ['command_1', 'command_2']
if data['command'] not in allowed_commands:
abort(403, 'Command not allowed')
result = run_command(data['command'])
return json.dumps({'result': result})
def run_command(command):
"""Secure function that fixes the vulnerability."""
result = subprocess.run(['echo', 'Command executed'], capture_output=True, text=True)
return result.stdout
if __name__ == '__main__':
app.run()Payload
{"command":"; ls -la; #"}
Cite this entry
@misc{vaitp:cve202439205,
title = {{Arbitrary code execution in pyload-ng v0.5.0b3.dev85 via crafted HTTP request.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2024},
note = {VAITP Python Vulnerability Dataset, entry CVE-2024-39205},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2024-39205/}}
}
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 ::
