T09 · Insecure Skill Coding Practices
Error
- Location
- webpage_reader.py:124
- Finding
- Unrestricted URL Fetching Enables Server-Side Request Forgery<![CDATA[ ## Vulnerability Details **File Location**: `webpage_reader.py:124-135` **Vulnerability Type**: Server-Side Request Forgery through unrestricted browser navigation **Risk Level**: High ### Vulnerable Code ```python # Build the Chrome command chrome_cmd = [ 'google-chrome' if platform.system() != 'Windows' else 'chrome', '--headless=new', '--no-sandbox', '--disable-gpu', '--disable-dev-shm-usage', '--virtual-time-budget=8000', '--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36', '--hide-scrollbars', '--blink-settings=imagesEnabled=true', '--dump-dom', url ] ``` The unvalidated value reaches this function from `main` at `webpage_reader.py:232`: ```python if not download_webpage(url, output_file): result['message'] = "Failed to download webpage" return result ``` ### Technical Analysis The caller-provided `url` is passed directly to headless Chrome without validation of its scheme, hostname, resolved IP address, destination port, or redirect targets. Using a subprocess argument array prevents direct shell metacharacter injection, but it does not prevent server-side request forgery. An attacker can request resources that are accessible from the machine running the skill but are not normally accessible to the attacker. Potential targets include: - Loopback services such as `127.0.0.1` and `::1` - Private network ranges - Link-local services - Cloud instance metadata endpoints - Internal administration interfaces - Services exposed only inside the host or container network Validating only the initial hostname would not be sufficient because an attacker-controlled server could redirect Chrome to an internal address. DNS rebinding could also undermine checks that do not bind navigation to a previously validated address. ### Attack Path 1. An attacker invokes the skill with a URL targeting an internal service, localhost reso ...[truncated 1277 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Permit only explicitly supported schemes, normally `https` and, if necessary, `http`. 2. Reject URLs containing credentials, ambiguous host syntax, or unsupported ports. 3. Resolve the destination hostname before navigation and reject every address in loopback, private, link-local, multicast, unspecified, reserved, and other non-public ranges for both IPv4 and IPv6. 4. Explicitly block cloud metadata destinations and hostnames. 5. Validate every redirect destination using the same rules. Do not rely only on validation of the initial URL. 6. Mitigate DNS rebinding by ensuring navigation uses an approved resolution or by enforcing the policy through a controlled outbound proxy. 7. Prefer a strict hostname allowlist when the business use case permits it. 8. Enforce outbound firewall or container-network rules so the browser cannot reach internal networks or metadata services even if application validation is bypassed. 9. Apply response-size and navigation limits to reduce denial-of-service risk from attacker-controlled pages. ]]>
