T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/monitor.py:17
- Finding
- Server-Side Request Forgery Through an Unrestricted Target URL<![CDATA[ ## Vulnerability Details **File Location**: `scripts/monitor.py:17` and `scripts/monitor.py:69` **Vulnerability Type**: Server-Side Request Forgery (SSRF) **Risk Level**: High ### Vulnerable Code ```python r = requests.get(url, headers=headers, timeout=15) ``` The requested URL comes directly from a positional command-line argument: ```python p_check.add_argument('url') ``` ### Technical Analysis The skill sends an HTTP request to a caller-controlled URL without validating its scheme, hostname, resolved IP address, port, or redirect destination. Python Requests follows redirects by default, so validating only the initial URL would also be insufficient. An attacker can provide URLs that resolve to loopback, private, link-local, or otherwise restricted network destinations, including: - Services bound to `127.0.0.1` or `localhost` - Private network services reachable from the agent host - Link-local cloud metadata services - Internal administrative HTTP endpoints - Public hosts that redirect to internal destinations The response body is not directly returned to the caller, which limits direct data extraction. However, the script exposes success or failure, HTTP status information, and error behavior. It also computes a hash of successful response content and stores it in the state file. These behaviors can support internal service discovery and blind interaction with internal GET endpoints. ### Attack Path 1. An attacker asks the agent to check a crafted URL, such as an address on the loopback, private, or link-local network. 2. The URL is accepted as the unrestricted `url` positional argument. 3. `requests.get()` sends the request from the agent host and its trusted network context. 4. The attacker observes the reported HTTP status, success message, error, or process result. 5. The attacker repeats the operation against different hosts, ports, and paths to identify reachable services or trigger internal endpoints. 6. Alternatively, the attack ...[truncated 664 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Accept only explicitly supported schemes, normally `http` and `https`. - Resolve the hostname before connecting and reject loopback, private, link-local, multicast, unspecified, and reserved IPv4 and IPv6 addresses. - Disable automatic redirects or validate the destination after every redirect. - Prevent DNS rebinding by ensuring the validated address is the address used for the connection. - Prefer an explicit hostname allowlist when the expected monitoring targets are known. - Restrict ports to an approved set, such as 80 and 443, where operationally appropriate. - Apply outbound firewall or proxy controls so the process cannot reach metadata services or sensitive internal networks. - Return only minimal, normalized errors to avoid exposing internal network details. ]]>
