T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/verify_url.sh:4
- Finding
- Curl Option Injection Through an Unvalidated Verification URL<![CDATA[ ## Vulnerability Details **File Location**: `scripts/verify_url.sh`, lines 4–8 **Vulnerability Type**: Command option injection **Risk Level**: High ### Vulnerable Code ```bash URL="${1:?usage: verify_url.sh <url> [expected_snippet]}" SNIPPET="${2:-}" TMP="$(mktemp)" CODE=$(curl -sSL -o "$TMP" -w "%{http_code}" "$URL" || true) ``` ### Technical Analysis The script passes the user-controlled `URL` argument directly to `curl` without first validating it and without using the `--` end-of-options delimiter. Shell quoting prevents word splitting and shell metacharacter interpretation, but it does not prevent the invoked program from interpreting an argument beginning with `-` as a command-line option. Consequently, a value such as `--config=/path/to/file` or an equivalent short option can be interpreted as a curl option rather than as a URL. If an attacker can place or reference a crafted curl configuration file, that configuration can specify additional URLs, uploads, proxy settings, request headers, output destinations, or local file URLs. The script also lacks restrictions on URL schemes and destinations. This makes the option-injection weakness more consequential and permits requests to unintended internal or local resources if malicious curl behavior is introduced. ### Attack Path 1. An attacker influences the URL supplied to `verify_url.sh`. 2. The attacker supplies an option-shaped value, such as a curl configuration directive referencing a crafted or attacker-controlled local configuration file. 3. The script passes the value to `curl` without an option terminator. 4. Curl interprets the value as an option instead of a deployment URL. 5. Directives from the referenced configuration can cause unintended network requests, local-file access, file uploads, or writes to attacker-selected paths. 6. These operations execute with the filesystem and network privileges of the user or Agent running the Skill. ### Impact Assessment Successful explo ...[truncated 541 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Place the `--` option terminator before the URL: ```bash CODE=$(curl -sSL -o "$TMP" -w "%{http_code}" -- "$URL" || true) ``` 2. Validate that the input is an absolute `https://` URL before invoking curl. Reject values beginning with `-`, unsupported schemes, embedded credentials, malformed hosts, and control characters. 3. Where deployment targets are known, enforce an allowlist of approved Puter domains or expected target hosts. 4. Reduce denial-of-service and network abuse risk by setting connection, execution, redirect, and response-size limits. For example: ```bash curl \ --silent --show-error --location \ --connect-timeout 10 \ --max-time 30 \ --max-redirs 5 \ --max-filesize 10485760 \ --output "$TMP" \ --write-out "%{http_code}" \ -- "$URL" ``` 5. Consider rejecting redirects to local, loopback, link-local, private, or otherwise restricted addresses when URLs can originate from untrusted users. ]]>
