T09 · Insecure Skill Coding Practices
- Location
src/markdown-parser.js:39- Finding
Unrestricted Remote Image Retrieval Enables Server-Side Request Forgery and Resource Exhaustion
- Content
View full analysis
{ if (response.statusCode === 200) { const fileStream = fs.createWriteStream(localPath); response.pipe(fileStream); fileStream.on('finish', () => { fileStream.close(); resolve(localPath); }); fileStream.on('error', (err) => { fs.unlink(localPath, () => {}); reject(err); }); } else { reject(new Error(`下载图片失败: ${url} (状态码: ${response.statusCode})`)); } }).on('error', (err) => { reject(new Error(`下载图片失败: ${url} (${err.message})`)); }); ``` ```js if (imagePath.startsWith('http://') || imagePath.startsWith('https://')) { try { console.log(` 下载远程图片: ${imagePath}`); absolutePath = await downloadImage(imagePath); ``` ### Technical Analysis Remote image URLs are taken directly from Markdown and passed to Node.js HTTP clients. The implementation does not restrict destination hosts, resolve and reject private IP ranges, validate redirects, impose a response-size limit, or configure an effective request timeout. Consequently, a Markdown document can cause the host to send HTTP GET requests to arbitrary destinations accessible from the execution environment. Relevant targets include: - Loopback interfaces such as `127.0.0.1` and `::1` - Private network ranges - Link-local services - Cloud instance metadata endpoints - Internal administrative interfaces - Attacker-controlled tracking servers The response body is streamed directly to disk. A server that returns an extremely large or indefinitely streaming response can consume disk space, network bandwidth, and process resources. ### Attack Path 1. An attacker supplies or influences a Markdown docu ...[truncated 1143 chars]- Remediation
View remediation
