T09 · Insecure Skill Coding Practices
- Location
scripts/analyze.js:42- Finding
Unrestricted URL Fetching Enables Server-Side Request Forgery
- Content
View full analysis
{ const lib = url.startsWith('https') ? https : http; const reqOptions = { headers: { 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8', ...options.headers, }, timeout: 15000, }; const req = lib.get(url, reqOptions, (res) => { // 处理重定向 if ([301, 302, 303, 307, 308].includes(res.statusCode) && res.headers.location) { return fetch(res.headers.location, options).then(resolve).catch(reject); } const chunks = []; res.on('data', chunk => chunks.push(chunk)); res.on('end', () => resolve(Buffer.concat(chunks).toString('utf8'))); }); req.on('error', reject); req.on('timeout', () => { req.destroy(); reject(new Error('请求超时')); }); }); } ``` The URL reaches the vulnerable request function from caller-controlled command-line input: ```javascript for (const input of inputs) { if (input.startsWith('http://') || input.startsWith('https://')) { // URL 直接抓取 const result = await crawlCompetitor(input); competitors.push({ name: input.replace(/^https?:\/\//, '').split('/')[0], ...result, }); ``` ### Technical Analysis The script accepts arbitrary HTTP and HTTPS URLs and requests them from the network context of the host running the Skill. It does not validate hostnames, resolved IP addresses, destination ports, or network ranges. Consequently, a caller can direct the crawler to loopback interfaces, private networks, link-local addr ...[truncated 2057 chars]- Remediation
View remediation
