CVE-2024-3851
📋 TL;DR
A stored XSS vulnerability in the imartinez/privategpt repository allows attackers to upload malicious HTML files containing JavaScript payloads. When victims access these files, the JavaScript executes in their browser session, potentially enabling phishing attacks or session hijacking. All users running the latest version of PrivateGPT are affected.
💻 Affected Systems
- imartinez/privategpt
📦 What is this software?
⚠️ Risk & Real-World Impact
Worst Case
Attackers could steal session cookies, perform account takeover, redirect users to malicious sites, or execute actions on behalf of authenticated users.
Likely Case
Attackers would upload malicious files and trick users into accessing them, leading to session hijacking or credential theft.
If Mitigated
With proper input validation and content security policies, the risk reduces to minimal as malicious uploads would be blocked or sanitized.
🎯 Exploit Status
Exploitation requires file upload access but is straightforward once that access is obtained.
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: Check repository for latest patched version
Vendor Advisory: https://huntr.com/bounties/cae1a492-4e09-4d56-8e11-17703bdfe653
Restart Required: Yes
Instructions:
1. Update to the latest version of PrivateGPT from the official repository
2. Restart the PrivateGPT service
3. Verify that file upload validation is properly implemented
🔧 Temporary Workarounds
Disable file uploads
allTemporarily disable file upload functionality in PrivateGPT configuration
Modify configuration to disable file upload endpoints
Implement WAF rules
allAdd web application firewall rules to block malicious file uploads
Configure WAF to block HTML/JS file uploads to PrivateGPT endpoints
🧯 If You Can't Patch
- Implement strict content-type validation for all file uploads
- Add Content Security Policy headers to restrict script execution
🔍 How to Verify
Check if Vulnerable:
Test by uploading an HTML file with JavaScript payload and checking if it executes when accessed
Check Version:
Check PrivateGPT version in application interface or configuration files
Verify Fix Applied:
Attempt to upload malicious HTML files and verify they are either blocked or sanitized
📡 Detection & Monitoring
Log Indicators:
- Unusual file uploads with .html/.htm extensions
- Multiple failed upload attempts
- Uploads from unexpected IP addresses
Network Indicators:
- HTTP POST requests to upload endpoints with HTML content
- Subsequent requests to access uploaded HTML files
SIEM Query:
source="privategpt" AND (event="file_upload" AND file_extension IN ("html", "htm"))