T09 · Insecure Skill Coding Practices
- Location
scripts/download_image.sh:19- Finding
JavaScript Injection Through Downloader Arguments
- Content
View full analysis
{ if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) { console.log('Redirected to:', res.headers.location); return; } const chunks = []; res.on('data', c => chunks.push(c)); res.on('end', () => { const buf = Buffer.concat(chunks); fs.writeFileSync('$OUTPUT', buf); console.log('Download complete:', (buf.length / 1024).toFixed(1), 'KB'); }); ``` ### Technical Analysis The first and second shell arguments are interpolated directly into JavaScript source passed to `node -e`. Neither value is encoded or passed through a separate argument channel. A URL or output path containing a single quote can terminate the JavaScript string literal. Additional JavaScript can then be inserted into the generated program. Node.js code executed in this context has access to the filesystem, network, environment variables, and process-spawning APIs available to the current user. The output path is also unrestricted. Even without JavaScript injection, the script can write downloaded bytes to any path writable by the invoking user. The script does not constrain output to a dedicated directory or validate the downloaded content as an image. ### Attack Path ...[truncated 1092 chars]- Remediation
View remediation
