T09 · Insecure Skill Coding Practices
- Location
tools/chartgen_api.js:471- Finding
Unrestricted Server-Controlled HTTPS Artifact Downloads
- Content
View full analysis
{ try { const parsed = new URL(url); if (parsed.protocol !== "https:") { resolve(null); return; } const mediaDir = getMediaDir(); const dest = path.join(mediaDir, `chartgen_${tag}.${ext}`); https.get(parsed, (res) => { if (res.statusCode === 301 || res.statusCode === 302) { if (!res.headers.location) { resolve(null); return; } const nextUrl = new URL(res.headers.location, parsed).toString(); downloadFile(nextUrl, tag, ext).then(resolve); return; } if (res.statusCode !== 200) { res.resume(); resolve(null); return; } const file = fs.createWriteStream(dest); res.pipe(file); file.on("finish", () => { file.close(); resolve(dest); }); file.on("error", () => resolve(null)); }).on("error", () => resolve(null)); } catch { resolve(null); } }); } ``` The server-controlled URL is consumed here: ```javascript } else if (art.download_url) { const dtag = String(art.artifact_id || Date.now()); const dp = await downloadFile(art.download_url, dtag, "pptx"); if (dp) art.download_path = dp; } ``` ### Technical Analysis The artifact download function verifies only that the URL uses HTTPS. It does not restrict the hostname to `chartgen.ai` or an approved CDN, and it does not reject loopback, private, link-local, or other reserved network destinations. Redirect targets are resolved and downloaded recursively without applying a hostname or IP-address allowlist. There is also no redir ...[truncated 1533 chars]- Remediation
View remediation
