T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/check.sh:9
- Finding
- Unrestricted Outbound Requests Enable Server-Side Request Forgery<![CDATA[ ## Vulnerability Details **File Location**: `scripts/check.sh:9, 24-27`; `scripts/alert.sh:5, 37-42` **Vulnerability Type**: Server-Side Request Forgery through unvalidated curl destinations **Risk Level**: High ### Vulnerable Code ```bash # scripts/check.sh URL="${1:?Usage: $0 <url>}" CURL_OUTPUT=$(curl --silent --show-error --max-time 10 \ --write-out "%{http_code}|%{time_total}" \ --output /dev/null \ "$URL" 2>&1) ``` ```bash # scripts/alert.sh WEBHOOK_URL="${ALERT_WEBHOOK_URL:-}" if [ -n "$WEBHOOK_URL" ]; then payload=$(build_webhook_payload) response=$(curl --silent --max-time 10 \ -H "Content-Type: application/json" \ -d "$payload" \ "$WEBHOOK_URL" 2>&1) if [ $? -eq 0 ]; then echo "Alert sent to webhook for $url" else echo "Failed to send webhook alert: $response" >&2 fi fi ``` ### Technical Analysis Both scripts pass externally configurable destinations directly to `curl`. The monitoring URL is accepted as a positional argument, while the webhook destination is read from `ALERT_WEBHOOK_URL`. Neither path validates the URL scheme, hostname, resolved address, port, or destination network. Consequently, a party able to influence script arguments or environment configuration can direct requests toward resources reachable from the agent host, including: - Loopback services such as `127.0.0.1` or `[::1]`. - Private network services. - Link-local addresses and cloud metadata endpoints. - Internal administrative interfaces. - Unexpected protocols supported by the installed curl build. The health-check response body is discarded, which limits direct content disclosure, but HTTP status, timing, and success or failure can still reveal service availability. Requests may also trigger state-changing behavior if an internal endpoint performs actions on a GET request. The webhook path is more dangerous because it sends an attacker-influenced HTTP POST body. ### Attack Path 1. An attacker causes the skill to check ...[truncated 1152 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Parse and validate every destination before invoking `curl`. 2. Permit only the required schemes, normally HTTPS: ```bash curl --proto '=https' --proto-redir '=https' ... ``` 3. Maintain an explicit allowlist of approved monitoring and webhook hostnames. 4. Resolve destination hostnames and reject loopback, private, link-local, multicast, reserved, and cloud metadata address ranges for both IPv4 and IPv6. 5. Revalidate the resolved destination immediately before connecting to reduce DNS rebinding risk. 6. Restrict destination ports to the ports needed by the monitoring policy. 7. Run monitoring in a network sandbox that cannot access metadata endpoints or sensitive internal control-plane services. 8. Consider a centrally configured webhook destination rather than allowing per-run environment data to select it. 9. Preserve timeouts and add connection timeouts, such as `--connect-timeout`. ]]>
