T09 · Insecure Skill Coding Practices
- Location
kb-builder.js:108- Finding
Unrestricted URL Fetching Enables Server-Side Request Forgery
- Content
View full analysis
{ const client = url.startsWith('https') ? https : http; client.get(url, (res) => { let data = ''; res.on('data', chunk => data += chunk); res.on('end', () => { // Simple HTML text extraction const text = data .replace(/]*>[\s\S]*?<\/script>/gi, '') .replace(/]*>[\s\S]*?<\/style>/gi, '') .replace(/<[^>]+>/g, ' ') .replace(/ /g, ' ') .replace(/\s+/g, ' ') .trim(); resolve(text); }); }).on('error', reject); }); } ``` The user-controlled URL reaches this function through the `scrape` command: ```javascript const url = getArg('--url'); const outputPath = getArg('--output') || './kb.json'; if (!url) { console.error('Error: --url is required'); process.exit(1); } console.log(`Scraping FAQ from ${url}...`); const text = await scrapeFromURL(url); const entries = parseFAQ(text); ``` ### Technical Analysis The application performs an outbound HTTP or HTTPS request to a URL supplied through the `--url` argument. It does not validate the destination hostname, port, or resolved IP address and does not reject loopback, private, link-local, or other reserved address ranges. Consequently, the process can be instructed to connect to resources that are inaccessible to the external attacker but accessible from the host running the Skill. Potential targets include: - Services bound to `127.0.0.1` or `::1` - Services on private network ranges - Container or orchestration control endpoints - Link-local cloud metadata services - Unauthenticated internal administration interfaces The response is converted to text, parsed as FAQ conte ...[truncated 1375 chars]- Remediation
View remediation
