T09 · Insecure Skill Coding Practices
- Location
scripts/fetch_url.py:22- Finding
Server-Side Request Forgery Through Insufficient URL Validation
- Content
View full analysis
Vulnerability Details
File Location:
scripts/fetch_url.py:22-32
Vulnerability Type: Server-Side Request Forgery (SSRF) / unrestricted private-network access
Risk Level: HighVulnerable Code
python parsed = urlparse(args.url) if parsed.scheme not in ("http", "https"): print("Only http/https URLs are allowed.") sys.exit(1) req = Request( args.url, headers={"User-Agent": "Mozilla/5.0 (compatible; FetchSkill/1.0.0)"} ) with urlopen(req, timeout=20) as resp:Technical Analysis
The URL validation only verifies that the supplied scheme is HTTP or HTTPS. It does not verify that the destination is genuinely public, despite the public-only security boundary documented by the skill.
The implementation does not reject:
- Loopback destinations such as
127.0.0.1or::1 - RFC1918 private IPv4 networks
- IPv6 unique-local addresses
- Link-local and cloud metadata addresses
- Reserved, unspecified, multicast, or otherwise non-public addresses
- Public hostnames that resolve to non-public IP addresses
- Redirects from an initially public URL to a prohibited destination
- DNS-rebinding scenarios
- URLs containing embedded user-information components
urlopen()performs the request from the agent host and follows HTTP redirects. An attacker who controls the--urlvalue can therefore direct the skill to HTTP services that are inaccessible from the attacker's own network position.The fetched response is read and subsequently written to local raw and cleaned output files. Job metadata records the source URL and output locations, allowing the retrieved information to be accessed through the skill's normal workflow.
Attack Path
- The attacker identifies or guesses an internal HTTP endpoint reachable from the agent host.
- The attacker supplies a URL targeting a loopback, private-network, link-local, or metadata address. Alternatively, the attacker su ...[truncated 1329 chars]
- Loopback destinations such as
- Remediation
View remediation
Remediation Suggestions
Implement centralized URL validation and controlled redirect handling:
- Permit only explicitly supported schemes, normally HTTP and HTTPS.
- Reject URLs containing embedded credentials or malformed host components.
- Resolve the hostname before connecting and inspect every resulting IPv4 and IPv6 address.
- Reject loopback, private, link-local, multicast, unspecified, reserved, unique-local, and other non-global address ranges.
- Explicitly block cloud metadata destinations and deployment-specific internal ranges.
- Disable automatic redirects or validate every redirect target using the same policy before following it.
- Mitigate DNS rebinding and time-of-check/time-of-use issues by ensuring the connection is made to a previously validated address while preserving correct HTTP
Hostand TLS SNI behavior. - Prefer an outbound proxy or egress firewall that independently enforces public-destination restrictions.
- Where practical, use an explicit hostname allowlist rather than attempting to deny every sensitive destination.
- Add tests covering IPv4, IPv6, alternate address representations, internal DNS results, redirect chains, and DNS-rebinding behavior.
