T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/call-model.sh:100
- Finding
- API Credentials and User Content Can Be Transmitted Over Plaintext HTTP<![CDATA[ ## Vulnerability Details **File Location**: `scripts/sync-models.sh:28-29`; `scripts/call-model.sh:100-103, 128-131, 163-166, 193-197` **Vulnerability Type**: Missing transport security enforcement for sensitive network requests **Risk Level**: High ### Vulnerable Code From `scripts/sync-models.sh:28-29`: ```bash response=$(curl -sS --max-time 30 "$BASE_URL/models" \ -H "Authorization: Bearer $API_KEY") ``` From `scripts/call-model.sh:100-103`: ```bash response=$(curl -sS --max-time 120 "$BASE_URL/chat/completions" \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d "$body") ``` From `scripts/call-model.sh:128-131`: ```bash response=$(curl -sS --max-time 180 "$BASE_URL/images/generations" \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d "$body") ``` From `scripts/call-model.sh:163-166`: ```bash response=$(curl -sS --max-time 300 "$BASE_URL/chat/completions" \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d "$body") ``` From `scripts/call-model.sh:193-197`: ```bash curl -sS --max-time 120 "$BASE_URL/audio/speech" \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d "$body" \ -o "$outfile" ``` ### Technical Analysis The scripts take `BASE_URL` from an environment variable and use it without validating the URL scheme. Consequently, a value beginning with `http://` is accepted. Every request includes the provider API key in an HTTP `Authorization` header. Model calls can additionally transmit user prompts, text intended for speech synthesis, image URLs, and other task content. If plaintext HTTP is used, network traffic is neither confidential nor protected against modification. Sending an API key to a configured provider is necessary for the declared remote-model functionality, and no hidden or hardcoded exfiltration endpoint was found. The vulnerability is the failure to enforce secure transport ...[truncated 1156 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Parse and validate `BASE_URL` before making any request. 2. Require the URL to use `https://` by default. 3. If local development requires plaintext HTTP, permit it only for loopback addresses through an explicit opt-in flag. 4. Reject malformed URLs, URLs containing embedded credentials, and unexpected schemes such as `file://`. 5. Consider implementing an optional allowlist of trusted provider hostnames. 6. Configure `curl` to require modern TLS, for example: ```bash case "$BASE_URL" in https://*) ;; http://127.0.0.1:*|http://localhost:*) [[ "${SMART_ROUTER_ALLOW_INSECURE_LOCALHOST:-0}" == "1" ]] || { echo "Plaintext HTTP requires explicit localhost opt-in" >&2 exit 1 } ;; *) echo "SMART_ROUTER_BASE_URL must use HTTPS" >&2 exit 1 ;; esac curl --proto '=https' --tlsv1.2 ... ``` 7. Document clearly that prompts, image URLs, and generated-task content are disclosed to the configured external provider. 8. Use provider credentials with the narrowest available permissions, spending limits, and expiration period. ]]>
