T09 · Insecure Skill Coding Practices
- Location
scripts/kline.js:13- Finding
API Key Disclosure Through an Arbitrary Plaintext API Endpoint
- Content
View full analysis
{ const protocol = url.protocol === 'https:' ? https : http; const req = protocol.request(url, { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-API-Key': API_KEY, }, }, (res) => { let data = ''; res.on('data', chunk => data += chunk); res.on('end', () => { try { const json = JSON.parse(data); if (json.code !== 0) { reject(new Error(`API error [${json.code}]: ${json.msg}`)); } else { resolve(json.data); } } catch (e) { reject(new Error(`Response parsing failed: ${e.message}`)); } }); }); ``` ### Technical Analysis The script reads its destination from the undocumented `JRJ_API_URL` environment variable without validating the protocol or hostname. It then attaches the sensitive `JRJ_API_KEY` to every request through the `X-API-Key` header. If `JRJ_API_URL` specifies an HTTP URL, the script deliberately selects Node.js's plaintext `http` client. If it specifies an a ...[truncated 2307 chars]- Remediation
View remediation
