T09 · Insecure Skill Coding Practices
- Location
index.js:75- Finding
Server-Side Request Forgery Through Unrestricted Remote Image URLs
- Content
View full analysis
{ // Generate a unique temporary file path const tempFileName = `rmbg_${Date.now()}_${crypto.randomBytes(4).toString('hex')}`; const tempPath = path.join(os.tmpdir(), tempFileName); // Download the image const response = await axios({ url, method: 'GET', responseType: 'arraybuffer', timeout: 30000 }); const buffer = Buffer.from(response.data); // Write the response to a temporary file await fsPromises.writeFile(tempPath, buffer); ``` ### Technical Analysis The Skill accepts a user-controlled string as a remote image URL and passes it directly to Axios. The only preliminary check is whether the input begins with `http`. There is no canonical URL validation, hostname allowlist, IP-address filtering, redirect validation, or restriction against loopback, link-local, private, and reserved network ranges. Consequently, the HTTP request originates from the machine running the Skill and inherits that machine's network reachability. This enables an attacker to make requests to resources that may not be accessible from the attacker's own network location. Axios can also follow redirects. Even if an initially supplied hostname resolves to a public address, it may redirect to an internal address unless every redirect destination is independently validated. DNS rebinding creates an additional bypass risk if validation and connection do not use a safely pinned resolution. The fetched bytes are ...[truncated 2088 chars]- Remediation
View remediation
