T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/submit.sh:60
- Finding
- TLS Certificate Verification Disabled for Authenticated API Requests and Media Downloads<![CDATA[ ## Vulnerability Details **File Location**: `scripts/submit.sh:60-64`, `scripts/poll.sh:44-45`, `scripts/generate.sh:76-78` **Vulnerability Type**: Improper certificate validation **Risk Level**: High ### Vulnerable Code `scripts/submit.sh:60-64`: ```bash RESP=$(curl -sS -k --location "$API_URL" \ -H 'X-DashScope-Async: enable' \ -H "Authorization: Bearer $DASHSCOPE_API_KEY" \ -H 'Content-Type: application/json' \ -d "$DATA") ``` `scripts/poll.sh:44-45`: ```bash RESP=$(curl -sS -k --location "https://dashscope.aliyuncs.com/api/v1/tasks/$TASK_ID" \ -H "Authorization: Bearer $DASHSCOPE_API_KEY") ``` `scripts/generate.sh:76-78`: ```bash # Download mkdir -p "$(dirname "$OUT")" curl -L -k -o "$OUT" "$VIDEO_URL" ``` ### Technical Analysis The `-k` option instructs `curl` to accept TLS certificates without verifying their authenticity. It is used for both authenticated DashScope API calls and the final media download. Because certificate verification is disabled, HTTPS encryption does not establish that the remote endpoint is the legitimate DashScope service. An attacker capable of intercepting network traffic, controlling a proxy, influencing DNS, or presenting a malicious certificate can impersonate the API endpoint. The authenticated requests include the DashScope bearer token in the `Authorization` header. A successful interception can therefore disclose the API key. A forged polling response can also provide an attacker-selected `video_url`, after which `generate.sh` downloads attacker-controlled content while again disabling certificate validation. ### Attack Path 1. A user invokes `submit.sh`, `poll.sh`, or `generate.sh` with `DASHSCOPE_API_KEY` set. 2. An attacker obtains a network interception position, controls a configured proxy, or redirects the DashScope hostname. 3. The attacker presents an invalid or attacker-issued TLS certificate. 4. Because `curl -k` disables certificate validation, the scripts accept the connection. 5 ...[truncated 930 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove `-k` from every `curl` invocation: ```bash curl --fail-with-body --show-error --silent --location ... ``` 2. Use the operating system's trusted certificate store and fail closed when certificate validation fails. 3. If an organization uses an authorized TLS inspection proxy, install its CA certificate in the trust store or provide it explicitly with `--cacert`; do not disable all verification. 4. Validate the returned media URL before downloading it: - Require the `https` scheme. - Restrict the hostname to documented DashScope or Alibaba Cloud media domains. - Reject embedded credentials, unexpected ports, and malformed URLs. 5. Consider disabling redirects or limiting them with `--proto '=https'` and `--proto-redir '=https'`. 6. Use `--fail-with-body` so HTTP failures cannot be mistaken for valid API or media responses. 7. Rotate any API key that has already been used over untrusted networks with these scripts. ]]>
