T09 · Insecure Skill Coding Practices
- Location
tool.js:15- Finding
Unrestricted Remote URL Fetching Enables Server-Side Request Forgery
- Content
View full analysis
Vulnerability Details
File Location:
tool.js:15-19
Vulnerability Type: Server-Side Request Forgery (SSRF)
Risk Level: HighVulnerable Code:
js if (imagePathOrUrl.startsWith("http://") || imagePathOrUrl.startsWith("https://")) { const res = await fetch(imagePathOrUrl); if (!res.ok) throw new Error(`Failed to fetch image: ${res.statusText}`); const buffer = await res.arrayBuffer(); imageBase64 = Buffer.from(buffer).toString("base64"); }Technical Analysis
The skill performs a server-side HTTP request to a completely user-controlled URL. Although input is limited to strings beginning with
http://orhttps://, there is no validation of the destination hostname or resolved IP address.The implementation does not reject loopback, private, link-local, multicast, or otherwise reserved address ranges. It also does not validate redirect destinations, allowing an initially acceptable URL to redirect to an internal address. No request timeout, response-size limit, content-type restriction, or image-signature validation is applied.
As a result, an attacker able to invoke the skill can use the host's network position to request internal services, loopback interfaces, or cloud instance metadata endpoints. The response bytes are Base64-encoded and included in a request to the local LLaVA service. Depending on how the model interprets the content, information obtained from the targeted service may appear in the model's response.
Attack Path
- The attacker supplies an internal or metadata-service URL through the
--imageargument, such as a loopback, private-network, or link-local destination. index.jspasses the URL tovision_analyzewithout destination validation.tool.jscallsfetch()using the attacker-controlled URL from the host environment.- The request reaches a service that may be inaccessible directly to the attacker but accessible to the skill host.
...[truncated 1245 chars]
- The attacker supplies an internal or metadata-service URL through the
- Remediation
View remediation
Remediation Suggestions
- Prefer removing remote URL support unless it is essential to the skill.
- If remote retrieval is required, enforce an explicit allowlist of trusted schemes, hostnames, and ports.
- Resolve the hostname before connecting and reject all loopback, private, link-local, multicast, unspecified, and reserved IPv4 and IPv6 ranges.
- Protect against DNS rebinding by ensuring that the validated address is the address used for the connection.
- Disable automatic redirects or validate the hostname and resolved address at every redirect hop.
- Apply an
AbortControllertimeout and a strict maximum response size while streaming the body. - Require an approved image MIME type and verify the file's magic bytes rather than trusting headers or extensions.
- Reject credentials embedded in URLs and unnecessary nonstandard ports.
- Run the skill in a sandbox with outbound network restrictions that block metadata endpoints and internal network ranges.
- Avoid returning raw upstream response bodies or other sensitive diagnostics to untrusted callers.
