T09 · Insecure Skill Coding Practices
Error
- Location
- examples.md:56
- Finding
- Bearer Credential May Be Transmitted to an Unvalidated Environment-Controlled Endpoint## Vulnerability Details **File Location**: `examples.md:19-27, 56-72` **Vulnerability Type**: Unvalidated destination for bearer-token transmission **Risk Level**: High The documented CI script verifies only that `CLAWDEALS_API_BASE` and `CLAWDEALS_API_KEY` are non-empty: ```bash if [ -z "${CLAWDEALS_API_BASE:-}" ]; then echo "Missing CLAWDEALS_API_BASE" exit 1 fi if [ -z "${CLAWDEALS_API_KEY:-}" ]; then echo "Missing CLAWDEALS_API_KEY" exit 1 fi ``` It subsequently attaches the bearer credential to requests sent to URLs derived from the environment-controlled base URL: ```bash curl_json() { local method="$1" local url="$2" local json_body="${3:-}" local expected_csv="$4" local idempotency_key="${5:-}" local headers=(-H "Authorization: Bearer $CLAWDEALS_API_KEY" -H "Content-Type: application/json") if [ -n "$idempotency_key" ]; then headers+=(-H "Idempotency-Key: $idempotency_key") fi local out if [ -n "$json_body" ]; then out="$(curl -sS -X "$method" "$url" "${headers[@]}" -d "$json_body" -w "\n__HTTP_STATUS:%{http_code}\n")" else out="$(curl -sS -X "$method" "$url" "${headers[@]}" -w "\n__HTTP_STATUS:%{http_code}\n")" fi ``` ### Technical Analysis `CLAWDEALS_API_BASE` is trusted without validation of its URL scheme, hostname, port, or canonical path. Every request made through `curl_json` includes `Authorization: Bearer $CLAWDEALS_API_KEY`. Although `SKILL.md` declares a runtime network allowlist and identifies `https://app.clawdeals.com/api` as the canonical production endpoint, that metadata does not protect the shell block when copied into an ordinary CI environment. A compromised workflow variable, repository environment, CI secret configuration, or operator shell can redirect requests to an attacker-controlled server. The absence of redirect restrictions also increases exposure if an allowed endpoint returns an HTTP redirect an ...[truncated 1405 chars]
- Remediation
- ## Remediation Suggestions 1. Validate `CLAWDEALS_API_BASE` before making any authenticated request: - Require HTTPS. - Require an exact approved hostname. - Reject embedded credentials, fragments, unexpected ports, and malformed paths. - Permit localhost only behind an explicit development flag. 2. Hard-code the production API origin where practical instead of accepting an arbitrary environment-controlled URL. 3. Use a separate, short-lived, minimally scoped smoke-test credential that cannot access production resources. 4. Add a preflight assertion similar to: ```bash case "$CLAWDEALS_API_BASE" in "https://app.clawdeals.com/api") ;; *) echo "Refusing unapproved CLAWDEALS_API_BASE" >&2 exit 1 ;; esac ``` 5. Explicitly disable redirects for authenticated requests or validate every redirect destination before forwarding credentials. 6. Protect CI environment variables from untrusted pull requests and restrict who can modify workflow, environment, and secret configuration. 7. Document immediate credential revocation and rotation procedures for suspected endpoint misconfiguration.
