VAITP Dataset

← Back to the dataset

CVE-2024-37014

Remote code execution via untrusted access to custom_component endpoint.

  • CVSS 9.8
  • CWE-94
  • Input Validation and Sanitization
  • Remote

Langflow through 0.6.19 allows remote code execution if untrusted users are able to reach the "POST /api/v1/custom_component" endpoint and provide a Python script.

CVSS base score
9.8
Published
2024-06-10
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
Langflow
Fixed by upgrading
Yes

Solution

Upgrade Langflow to version 0.6.20 or later and implement strict input validation to prevent untrusted code execution.

Vulnerable code sample

from flask import Flask, request, jsonify

app = Flask(__name__)

@app.route('/api/v1/custom_component', methods=['POST'])
def custom_component():
    data = request.json
    if 'script' not in data:
        return jsonify({'error': 'No script provided'}), 400

    exec(data['script'])

    return jsonify({'message': 'Script executed successfully'}), 200

if __name__ == '__main__':
    app.run()

Patched code sample

from flask import Flask, request, jsonify

app = Flask(__name__)

@app.route('/api/v1/custom_component', methods=['POST'])
def custom_component():
    data = request.json
    if 'action' not in data:
        return jsonify({'error': 'No action provided'}), 400

    action = data['action']

    allowed_actions = ['greet', 'sum_numbers']

    if action not in allowed_actions:
        return jsonify({'error': 'Invalid action'}), 400

    if action == 'greet':
        name = data.get('name', 'Guest')
        return jsonify({'message': f'Hello, {name}!'}), 200
    
    elif action == 'sum_numbers':
        numbers = data.get('numbers', [])
        if not all(isinstance(num, (int, float)) for num in numbers):
            return jsonify({'error': 'Invalid numbers provided'}), 400
        return jsonify({'result': sum(numbers)}), 200

    return jsonify({'error': 'Unknown action'}), 400

if __name__ == '__main__':
    app.run()

Payload

__import__('os').system('whoami')

Cite this entry

@misc{vaitp:cve202437014,
  title        = {{Remote code execution via untrusted access to custom_component endpoint.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2024},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2024-37014},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2024-37014/}}
}
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 ::