CVE-2025-3248
Langflow < 1.3.0: Unauth. code injection via /api/v1/validate/code.
- CVSS 9.8
- CWE-94
- Input Validation and Sanitization
- Remote
Langflow versions prior to 1.3.0 are susceptible to code injection in the /api/v1/validate/code endpoint. A remote and unauthenticated attacker can send crafted HTTP requests to execute arbitrary code.
- CWE
- CWE-94
- CVSS base score
- 9.8
- Published
- 2025-04-07
- OWASP
- A03 Injection
- Orthogonal defect classification
- Interface
- 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 to version 1.3.0 or later.
Vulnerable code sample
from flask import Flask, request, jsonify
import subprocess
import os
app = Flask(__name__)
@app.route('/api/v1/validate/code', methods=['POST'])
def validate_code():
try:
data = request.get_json()
code = data['code']
# Vulnerable code: Directly executing user-provided code with subprocess
# This is extremely dangerous and allows for arbitrary code execution.
result = subprocess.run(code, shell=True, capture_output=True, text=True)
if result.returncode == 0:
return jsonify({'message': 'Code validated successfully', 'output': result.stdout}), 200
else:
return jsonify({'message': 'Code validation failed', 'error': result.stderr}), 400
except Exception as e:
return jsonify({'message': 'An error occurred', 'error': str(e)}), 500
if __name__ == '__main__':
app.run(debug=True)Patched code sample
import subprocess
import json
from flask import Flask, request, jsonify
from flask_cors import CORS
app = Flask(__name__)
CORS(app)
def safe_code_validation(code):
"""
Safely validates Python code using a restricted environment.
Args:
code: The Python code to validate (string).
Returns:
A tuple: (bool, str). The bool indicates validation success,
the string contains output or error messages.
"""
try:
# Create a restricted execution environment. This is a placeholder;
# a real solution would use a sandboxing library like PySandbox or similar.
# The key is to NOT allow arbitrary execution of the provided code.
# Instead of actual execution, perform static analysis
# 1. Check for potentially dangerous imports.
dangerous_imports = ["os", "subprocess", "sys", "shutil", "pickle"] # Extend as necessary
for imp in dangerous_imports:
if imp in code:
return False, f"Error: Code contains potentially dangerous import: {imp}"
# 2. Check for function calls that could lead to code execution
dangerous_functions = ["eval", "exec", "compile", "getattr", "__import__"] # Extend as necessary
for func in dangerous_functions:
if func in code:
return False, f"Error: Code contains potentially dangerous function: {func}"
# 3. Simple syntax check (can be improved with ast module if needed)
try:
compile(code, '<string>', 'exec') # Check if the code is syntactically correct.
except SyntaxError as e:
return False, f"Syntax Error: {e}"
# If all checks pass, consider it valid (for this simplified example).
return True, "Code validated successfully (static analysis only)."
except Exception as e:
return False, f"Error during validation: {e}"
@app.route('/api/v1/validate/code', methods=['POST'])
def validate_code():
"""
Endpoint to validate Python code. This is the fixed version.
"""
try:
data = request.get_json()
code = data['code']
except (KeyError, TypeError):
return jsonify({"valid": False, "message": "Invalid request format. Provide 'code' key."}), 400
is_valid, message = safe_code_validation(code)
return jsonify({"valid": is_valid, "message": message})
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0', port=5000)Payload
import subprocess
subprocess.run(["touch", "/tmp/pwned"])
Cite this entry
@misc{vaitp:cve20253248,
title = {{Langflow < 1.3.0: Unauth. code injection via /api/v1/validate/code.
}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2025},
note = {VAITP Python Vulnerability Dataset, entry CVE-2025-3248},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2025-3248/}}
}
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 ::
