CVE-2025-0868
DocsGPT RCE: Malicious JSON to /api/remote allows arbitrary code execution.
- CVSS 9.3
- CWE-95
- Input Validation and Sanitization
- Remote
A vulnerability, that could result in Remote Code Execution (RCE), has been found in DocsGPT. Due to improper parsing of JSON data using eval() an unauthorized attacker could send arbitrary Python code to be executed via /api/remote endpoint. This issue affects DocsGPT: from 0.8.1 through 0.12.0.
- CWE
- CWE-95
- CVSS base score
- 9.3
- Published
- 2025-02-20
- OWASP
- A03 Injection
- Orthogonal defect classification
- Interface
- Code defect classification
- Incorrect Functionality
- Category
- Input Validation and Sanitization
- Subcategory
- Insecure Parsing or Deserialization
- Accessibility scope
- Remote
- Impact
- Arbitrary Code Execution
- Affected component
- DocsGPT
- Fixed by upgrading
- Yes
Solution
Upgrade to version 0.12.1 or later.
Vulnerable code sample
from flask import Flask, request, jsonify
import json
app = Flask(__name__)
@app.route('/api/remote', methods=['POST'])
def remote_endpoint():
try:
data = request.get_data().decode('utf-8')
json_data = json.loads(data)
result = eval(json_data['code'])
return jsonify({'result': result})
except Exception as e:
return jsonify({'error': str(e)})
if __name__ == '__main__':
app.run()Patched code sample
import json
from flask import Flask, request, jsonify
app = Flask(__name__)
def json_loads(data):
try:
return json.loads(data)
except json.JSONDecodeError:
return None
@app.route('/api/remote', methods=['POST'])
def remote_endpoint():
try:
data = request.get_data(as_text=True)
parsed_data = json_loads(data)
if parsed_data is None:
return jsonify({"error": "Invalid JSON"}), 400
if isinstance(parsed_data, dict) and "action" in parsed_data:
action = parsed_data["action"]
if action == "summarize":
result = "Summarization complete."
elif action == "translate":
result = "Translation complete."
else:
return jsonify({"error": "Invalid action"}), 400
return jsonify({"result": result})
else:
return jsonify({"error": "Invalid request format"}), 400
except Exception as e:
print(f"Error processing request: {e}")
return jsonify({"error": "Internal Server Error"}), 500
if __name__ == '__main__':
app.run()Payload
{"query": "';import os; os.system('whoami > /tmp/output.txt');'"}
Cite this entry
@misc{vaitp:cve20250868,
title = {{DocsGPT RCE: Malicious JSON to /api/remote allows arbitrary code execution.
}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2025},
note = {VAITP Python Vulnerability Dataset, entry CVE-2025-0868},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2025-0868/}}
}
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 ::
