T09 · Insecure Skill Coding Practices
- Location
scripts/visla_cli.py:764- Finding
Blind Server-Side Request Forgery Through Unrestricted URL Validation
- Content
View full analysis
Vulnerability Details
File Location:
scripts/visla_cli.py:764-785
Vulnerability Type: Blind server-side request forgery (SSRF)
Risk Level: HighVulnerable Code
python def validate_url(self, url): """Check if URL is accessible (follows redirects; falls back to GET on HEAD block). Sends a browser-like User-Agent: many sites (e.g. Wikipedia) block the default Python-urllib / python-requests UA strings with 403. """ ua = ( "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) " "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0 Safari/537.36" ) response = self._http_request( "HEAD", url, headers={"User-Agent": ua}, timeout=10, allow_redirects=True, ) if response.error is None and response.status < 400: return True # Some sites block HEAD requests, retry with a lightweight ranged GET. if response.status in (403, 405): response = self._http_request( "GET", url, headers={"Range": "bytes=0-0", "User-Agent": ua}, timeout=10, allow_redirects=True, ) return response.error is None and response.status < 400 return FalseTechnical Analysis
The URL supplied to the
urlcommand is passed directly to the local HTTP client. The validation routine does not:- Restrict the URL scheme to HTTP or HTTPS.
- Reject loopback, private, link-local, multicast, reserved, or unspecified IP addresses.
- Block cloud metadata endpoints such as link-local metadata services.
- Resolve and validate the destination address before connecting.
- Revalidate each destination reached through an HTTP redirect.
- Protect against DNS rebinding or hostnames that resolve to internal addresses.
The method first sends a
HEADrequest. If the server responds with HTTP 403 or 405, it sends a rangedGETrequest. Redirect following is enabled in both cases. Cons ...[truncated 2191 chars]- Remediation
View remediation
Remediation Suggestions
- Permit only explicit
httpandhttpsschemes and reject URLs containing embedded credentials. - Resolve the hostname before connecting and reject every address classified as loopback, private, link-local, multicast, reserved, or unspecified.
- Explicitly block known metadata destinations and relevant IPv4 and IPv6 ranges.
- Disable automatic redirect following. If redirects are required, process them manually and repeat full scheme, hostname, DNS, and IP validation for every redirect target.
- Protect against DNS rebinding by ensuring the validated address is the address used for the connection, or enforce destination controls through a trusted outbound proxy.
- Consider removing local reachability validation entirely. The URL can instead be submitted to the intended Visla API after basic syntactic validation.
- Add tests for loopback addresses, IPv6 loopback, private ranges, decimal or encoded IP representations, link-local addresses, metadata endpoints, and public-to-private redirect chains.
- Permit only explicit
