T09 · Insecure Skill Coding Practices
Error
- Location
seo-analyzer.js:26- Finding
Unrestricted Server-Side URL Fetching Enables SSRF
- Content
View full analysis
{ const parsedUrl = new URL(url); const client = parsedUrl.protocol === 'https:' ? https : http; const options = { hostname: parsedUrl.hostname, path: parsedUrl.pathname + parsedUrl.search, method: 'GET', headers: { 'User-Agent': 'Mozilla/5.0 (compatible; SEO-Analyzer/1.0)' }, timeout: 10000 }; const req = client.request(options, (res) => { let data = ''; res.on('data', chunk => data += chunk); res.on('end', () => resolve(data)); }); req.on('error', reject); req.on('timeout', () => reject(new Error('Request timeout'))); req.end(); }); } ``` The request target originates directly from the command-line argument: ```js async function main() { const url = process.argv[2]; if (!url) { console.log('Usage: node seo-analyzer.js '); console.log('Example: node seo-analyzer.js https://example.com'); process.exit(1); } // Add protocol if missing const fullUrl = url.match(/^https?:\/\//) ? url : `https://${url}`; try { log(colors.blue, `🔍 Analyzing ${fullUrl}...`); const html = await fetchPage(fullUrl); const results = analyzeHTML(html, fullUrl); printResults(results); } catch (error) { log(colors.red, `Error: ${error.message}`); process.exit(1); } } ``` ### Technical Analysis The command-line argument controls the hostname, port through the parsed URL, request path, query string, and whether the request uses HTTP or HTTPS. The application performs the request from its own network context without applying: - An approved-host allowlist. - Public-address validation. - DNS resolution and resolve ...[truncated 2624 chars]- Remediation
View remediation
