T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/crawl.py:69- Finding
Unrestricted URL Fetching Enables Server-Side Request Forgery
- Content
View full analysis
Vulnerability Details
File Location:
scripts/crawl.py:69-74, with attacker-controlled input accepted atscripts/crawl.py:130-134and propagated byscripts/run_pipeline.py:108-109,205-209
Vulnerability Type: Server-Side Request Forgery through unrestricted URL fetching
Risk Level: MediumVulnerable Code
python response = session.get( url, headers=headers, timeout=timeout, allow_redirects=True )The URL is accepted without restriction:
python parser.add_argument( "--url", default=os.getenv("TARGET_URL", DEFAULT_URL), help=f"Target URL (default: {DEFAULT_URL})" )The pipeline propagates the supplied value to the crawler:
python crawl_args = [] if url: crawl_args.extend(["--url", url]) returncode, output_file = run_script(CRAWL_SCRIPT, crawl_args)Technical Analysis
Although the Skill is declared as a crawler for
https://hn.aimaker.dev/, it accepts an arbitrary URL from either the--urlargument or theTARGET_URLenvironment variable. It does not validate:- The URL scheme
- The destination hostname
- The destination port
- The IP addresses produced by DNS resolution
- Whether the address is loopback, private, link-local, reserved, or a cloud metadata endpoint
- Redirect destinations
Because
allow_redirects=Trueis enabled, an initially acceptable endpoint could redirect the request to an internal service. The returned response body is subsequently written to disk and may be processed by later pipeline stages.This exceeds the minimum network privilege required for a Skill whose stated purpose is limited to crawling
hn.aimaker.dev.Attack Path
- An attacker or untrusted caller influences the
--urlargument orTARGET_URLenvironment variable. - The attacker supplies a loopback, private-network, link-local, metadata-service, or redirecting URL.
requests.Session.get()s ...[truncated 898 chars]
- Remediation
View remediation
Remediation Suggestions
- Restrict destinations to an explicit hostname allowlist, preferably only
hn.aimaker.dev. - Require HTTPS and reject unsupported schemes, embedded credentials, unexpected ports, and malformed URLs.
- Resolve the hostname before connecting and reject loopback, private, link-local, multicast, reserved, unspecified, and metadata-service IP ranges for both IPv4 and IPv6.
- Disable automatic redirects or validate every redirect destination using the same scheme, hostname, port, and resolved-address policy.
- Protect against DNS rebinding by verifying the address used for the connection, not only an earlier DNS lookup.
- Apply an outbound network policy at the container or host level so the process cannot reach internal networks or metadata services.
- Limit response size and redirect count to reduce denial-of-service exposure.
- If arbitrary crawling is intentionally supported, require explicit user confirmation and run the network stage in an isolated environment with restricted egress.
- Restrict destinations to an explicit hostname allowlist, preferably only
