CVE-2024-9216
Executive Summary
CVE-2024-9216 is an authentication bypass vulnerability in the gaizhenbiao/ChuanhuChatGPT project, as of commit 3856d4f. The flaw allows any unauthenticated attacker to read and delete other users' chat history by manipulating the username parameter in HTTP requests. The root cause is that the application trusts client-supplied usernames instead of deriving them from a secure session source (e.g., cookies or tokens). With a CVSS score of 8.1, this vulnerability poses a high risk to confidentiality and integrity of user data. No official patch has been released, and the EPSS score is 0.0%, indicating low exploitation likelihood at this time, but the attack vector is trivial.
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 the Python-based ChuanhuChatGPT project, which is distributed via GitHub. Users who deploy this application from the affected commit are at risk. There is no known PyPI package for this project, but if it were distributed via PyPI, the same trust boundary issue would apply. Organizations should verify their deployment version and apply any available patches or workarounds.
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 confined to the vulnerable component.
- Confidentiality (C): High (H) – Full read access to chat history.
- Integrity (I): High (H) – Ability to delete chat history.
- Availability (A): None (N) – No denial of service.
Threat Level: High. The vulnerability is easy to exploit and can lead to significant data breaches.
Deep Dive & Mechanics
The vulnerability resides in the get_model function, which accepts a username parameter directly from the HTTP request. The application does not validate that the provided username matches the authenticated session. An attacker can craft a request with any username to access or delete that user's chat history.
Attack Flow:
- The attacker sends a GET or POST request to an endpoint that calls
get_model, including ausernameparameter. - The server processes the request using the attacker-supplied username.
- The attacker gains unauthorized access to the victim's chat history or can delete it.
Example vulnerable code snippet (conceptual):
def get_model(username):
# No authentication check
user_data = load_user_data(username)
return user_data
Vulnerable vs. Patched Code
Vulnerable Code (commit 3856d4f):
def get_model(username):
# Directly uses client-supplied username
user_data = load_user_data(username)
return user_data
Patched Code (hypothetical):
def get_model(username):
# Derive username from session or token
session_username = get_authenticated_user()
if session_username != username:
raise PermissionError("Unauthorized")
user_data = load_user_data(session_username)
return user_data
Exploitation & Lab Setup
Red Team
Prerequisites:
- Target running ChuanhuChatGPT from commit 3856d4f.
- Network access to the application.
Exploit Steps:
- Identify the target endpoint (e.g.,
/api/chator/get_history). - Send a request with a manipulated
usernameparameter.
Example using curl:
curl -X GET "http://target.com/api/get_history?username=victim_user"
Example using Python:
import requests
target = "http://target.com/api/get_history"
params = {"username": "victim_user"}
response = requests.get(target, params=params)
print(response.text)
To delete chat history:
curl -X DELETE "http://target.com/api/delete_history?username=victim_user"
Blue Team
Detection:
- Monitor for requests with unusual
usernameparameters that do not match the authenticated session. - Log all access to chat history endpoints and correlate with session tokens.
Mitigation:
- Implement server-side session validation.
- Use secure cookies or tokens to identify users.
- Apply input validation and authorization checks.
Indicators of Compromise (IOCs)
- Network IOCs:
- HTTP requests to
/api/get_historyor/api/delete_historywith ausernameparameter. - Anomalous patterns of
usernamevalues not matching session tokens.
- HTTP requests to
- Log IOCs:
- Access logs showing multiple usernames from the same IP.
- Error logs indicating unauthorized access attempts.
- File IOCs:
- Unauthorized modifications to chat history files.
Detection Engineering
YARA Rule
rule CVE_2024_9216_ChuanhuChatGPT_AuthBypass {
meta:
description = "Detects exploitation attempts for CVE-2024-9216"
author = "Valters IT"
date = "2025-04-10"
reference = "https://nvd.nist.gov/vuln/detail/CVE-2024-9216"
strings:
$s1 = "username=" ascii wide nocase
$s2 = "/api/get_history" ascii wide nocase
$s3 = "/api/delete_history" ascii wide nocase
condition:
any of ($s1) and any of ($s2, $s3)
}
Sigma Rule
title: CVE-2024-9216 ChuanhuChatGPT Authentication Bypass
id: 8a9b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d
status: experimental
description: Detects attempts to exploit authentication bypass in ChuanhuChatGPT
author: Valters IT
date: 2025-04-10
logsource:
category: webserver
product: apache
service: access
detection:
selection:
cs-uri-query|contains:
- "username="
cs-uri-stem|contains:
- "/api/get_history"
- "/api/delete_history"
condition: selection
falsepositives:
- Legitimate admin operations
level: high
Suricata Rule
alert http any any -> any any (msg:"CVE-2024-9216 ChuanhuChatGPT Auth Bypass"; flow:to_server; content:"username="; http_uri; content:"/api/get_history"; http_uri; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Disable affected endpoints if possible, or restrict access via firewall rules.
- Implement session validation – Derive the username from a secure session token or cookie.
- Apply input validation – Ensure the username matches the authenticated user.
Long-term Fix:
- Update to a patched version once available.
- Conduct a security audit of the application's authentication logic.
Workaround:
- Use a reverse proxy to enforce authentication before requests reach the application.
Valters IT
Securing Digital Frontiers
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.