T09 · Insecure Skill Coding Practices
- Location
research-assistant.js:145- Finding
Arbitrary URL Fetching Enables Server-Side Request Forgery
- Content
View full analysis
{ const isHttps = url.startsWith('https'); const client = isHttps ? https : http; const req = client.get(url, (res) => { if (res.statusCode !== 200) { reject(new Error(`HTTP ${res.statusCode}`)); return; } let data = ''; res.on('data', chunk => data += chunk); res.on('end', () => { // Strip HTML tags const text = data.replace(/<[^>]*>/g, ' ').replace(/\s+/g, ' ').trim(); const extracted = extractEntities(text); resolve({ source: url, summary: text.substring(0, 200), entities: extracted.entities, relations: extracted.relations, wordCount: text.split(/\s+/).length, extractedAt: getToday() }); }); }); req.on('error', reject); req.setTimeout(10000, () => { req.destroy(); reject(new Error('Timeout')); }); }); } ``` The URL is reached from the CLI without validation: ```javascript if (target.startsWith('http')) { entry = await extractFromUrl(target); } else { entry = extractFromFile(target); } addToKB(entry); ``` ### Technical Analysis The skill passes a user-controlled URL directly to Node.js `http.get()` or `https.get()` without validating the destination address. There is no protocol parser with a strict scheme check, hostname allowlist, DNS resolution check, or rejection of loopback, link-local, private, reserved, and IPv6-local address ranges. Consequently, a caller can make the process issue GET requests to services reachable from the host even when those services are not externally accessible. Relevant destinations can include: - Loopback services such as `127.0.0.1` or `[::1 ...[truncated 2750 chars]- Remediation
View remediation
