T09 · Insecure Skill Coding Practices
- Location
scripts/query.js:18- Finding
Unrestricted Redirects and Untrusted API Content in Trusted Agent Output
- Content
View full analysis
{ let parsedUrl; try { parsedUrl = new URL(urlStr); } catch (e) { return reject(new Error('无效的 URL: ' + urlStr)); } const client = parsedUrl.protocol === 'https:' ? https : http; const req = client.get(urlStr, { timeout }, (res) => { // 处理重定向 if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) { return httpGet(res.headers.location, timeout).then(resolve).catch(reject); } let data = ''; res.on('data', chunk => data += chunk); res.on('end', () => { try { const json = JSON.parse(data); if (res.statusCode >= 400) { reject(new Error('API 返回错误 ' + res.statusCode + ': ' + (json.message || data.substring(0, 200)))); } else { resolve(json); } } catch (e) { reject(new Error('JSON 解析失败: ' + e.message)); } }); }); req.on('error', reject); req.on('timeout', () => { req.destroy(); reject(new Error('请求超时 (' + timeout + 'ms)')); }); }); } ``` From `scripts/query.js:65-83`: ```js async function fetchCompact(options = {}) { const apiUrl = options.compactApiUrl || config.COMPACT_API_URL; try { const response = await httpGet(apiUrl); // 验证核心字段 if (response && response.landing && response.landing.url) { return { success: true, compact: { channel: response.channel || 'skill_compact', date: response.date | ...[truncated 4513 chars]- Remediation
View remediation
