Skip to main content
CVE Vulnerability Database

CVE-2024-8613: Chuanhuchatgpt Auth Bypass Vulnerability

CVE-2024-8613 is an authentication bypass flaw in Gaizhenbiao Chuanhuchatgpt that allows attackers to access, copy, and delete other users' chat histories. This article covers technical details, affected versions, and mitigation.

Updated:

CVE-2024-8613 Overview

CVE-2024-8613 is a broken access control vulnerability affecting gaizhenbiao/chuanhuchatgpt version 20240802. The flaw allows authenticated attackers to access, copy, and delete chat histories belonging to other users. The root cause is improper handling of session data combined with missing authorization checks on history file operations. The vulnerability maps to CWE-639: Authorization Bypass Through User-Controlled Key.

Critical Impact

An authenticated attacker on the network can read, exfiltrate, and destroy other users' conversation histories, resulting in confidentiality, integrity, and availability loss on affected ChuanhuChatGPT deployments.

Affected Products

  • gaizhenbiao/chuanhuchatgpt version 20240802
  • Deployments using ChuanhuChatGPT with user access control enabled
  • Self-hosted multi-user ChuanhuChatGPT instances exposing chat history storage

Discovery Timeline

  • 2025-03-20 - CVE-2024-8613 published to NVD
  • 2026-06-17 - Last updated in NVD database

Technical Details for CVE-2024-8613

Vulnerability Analysis

ChuanhuChatGPT stores per-user chat histories in filesystem directories keyed by user_name. The save_file and history deletion routines in modules/utils.py and modules/models/base_model.py constructed history file paths from client-controlled input without validating that the resulting path belonged to the authenticated user. An attacker who supplied a crafted filename value could traverse into another user's history directory. The application then performed read, write, or delete operations on files owned by that user. The result was full cross-tenant access to conversation data on multi-user deployments.

Root Cause

The vulnerable code paths concatenated a user-controlled filename argument into a history path without asserting that os.path.dirname(history_file_path) matched the caller's session-bound user_name. Because the authorization decision relied only on the identifier embedded in the request path rather than the server-side session, an attacker could reference arbitrary user directories.

Attack Vector

Exploitation requires network access to the ChuanhuChatGPT web interface and a low-privileged authenticated account. The attacker submits requests to history save, load, or delete endpoints, substituting another user's identifier or a relative path within the filename parameter. No user interaction from the victim is required, and successful requests yield the target's chat history JSON or remove it entirely.

python
# Security patch in modules/models/base_model.py
         else:
             history_file_path = filename
         md_history_file_path = history_file_path[:-5] + ".md"
+        # check if history file path matches user_name
+        # if user access control is not enabled, user_name is empty, don't check
+        assert os.path.dirname(history_file_path) == self.user_name or self.user_name == ""
+        assert os.path.dirname(md_history_file_path) == self.user_name or self.user_name == ""
         try:
             os.remove(history_file_path)
             os.remove(md_history_file_path)

# Security patch in modules/utils.py
     else:
         history_file_path = os.path.join(HISTORY_DIR, user_name, filename)
 
+    # check if history file path matches user_name
+    # if user access control is not enabled, user_name is empty, don't check
+    assert os.path.dirname(history_file_path) == model.user_name or model.user_name == ""
     with open(history_file_path, "w", encoding="utf-8") as f:
         json.dump(json_s, f, ensure_ascii=False, indent=4)

Source: GitHub commit 526c615c

Detection Methods for CVE-2024-8613

Indicators of Compromise

  • Requests to history endpoints containing filename values with path separators, .., or another account's user_name
  • Access log entries where the authenticated session user differs from the user_name segment of the history path being read or written
  • Unexpected os.remove activity within the history/ directory tree targeting files not owned by the acting user
  • Missing or truncated .json and .md history files reported by legitimate users

Detection Strategies

  • Correlate web application logs with filesystem audit events on the HISTORY_DIR path to flag cross-user file access
  • Alert on any HTTP request where the request-supplied filename contains /, \, or .. sequences before the patch is applied
  • Baseline per-user history directory activity and flag deviations, particularly deletions performed shortly after login from a new IP

Monitoring Recommendations

  • Enable verbose access logging on the ChuanhuChatGPT reverse proxy and retain session-to-user mappings
  • Monitor the HISTORY_DIR filesystem with an EDR or file integrity monitoring agent for unauthorized reads and deletes
  • Track authentication events and pair them with subsequent history operations to identify anomalous account behavior

How to Mitigate CVE-2024-8613

Immediate Actions Required

  • Update ChuanhuChatGPT to a build that includes commit 526c615c, which adds authorization assertions to history operations
  • Audit the HISTORY_DIR directory for unauthorized modifications and restore user histories from backup where tampering is confirmed
  • Rotate credentials for any accounts suspected of being used to access other users' data
  • Restrict network exposure of the ChuanhuChatGPT instance to trusted users pending remediation

Patch Information

The upstream fix is available in the ChuanhuChatGPT repository via commit 526c615c437377ee9c71f866fd0f19011910f705. The patch introduces assert os.path.dirname(history_file_path) == self.user_name guards in modules/models/base_model.py and modules/utils.py, ensuring that history save and delete operations only target files under the authenticated user's directory. Additional context is available in the Huntr bounty report.

Workarounds

  • Disable multi-user mode and run single-user instances until the patch can be deployed
  • Place the application behind an authenticating reverse proxy that enforces per-user path scoping on history endpoints
  • Apply filesystem ACLs so the application process cannot cross user history directories, limiting blast radius
bash
# Pull the fixed revision and restart the service
cd /opt/chuanhuchatgpt
git fetch origin
git checkout 526c615c437377ee9c71f866fd0f19011910f705
pip install -r requirements.txt
systemctl restart chuanhuchatgpt

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Default Legacy - Prefooter | Experience the World’s Most Advanced Cybersecurity Platform

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.