T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/generate.sh:92
- Finding
- API Key and Request Data May Be Forwarded Through HTTP Redirects<![CDATA[ ## Vulnerability Details **File Location**: `scripts/generate.sh:92-95` **Vulnerability Type**: Sensitive credential disclosure through server-controlled redirects **Risk Level**: Medium ### Vulnerable Code ```bash response=$(curl -s -m "$TIMEOUT" --location "$API_URL" \ --header 'Content-Type: application/json' \ --header "x-api-key: $X_API_KEY" \ --data "$payload" 2>&1) ``` ### Technical Analysis The script uses curl's `--location` option, allowing the remote API server to control redirect destinations. The request contains a custom `x-api-key` header and a JSON body containing the user's prompt and reference-image URLs. Custom headers specified with `--header` can remain associated with redirected requests. Consequently, a compromised, malicious, or misconfigured API endpoint could issue a redirect to an attacker-controlled host and cause sensitive request information to be transmitted outside the declared endpoint. Following redirects is not necessary for the Skill's core image-generation functionality when the API has a fixed, documented endpoint. ### Attack Path 1. The user invokes `scripts/generate.sh` with a valid API key and image-generation parameters. 2. The script sends the request to the declared API endpoint. 3. The endpoint, or infrastructure controlling it, returns an HTTP redirect to an attacker-controlled host. 4. Curl follows the redirect because `--location` is enabled. 5. The redirected request may expose the custom API-key header, prompt, reference-image URLs, or other request data to the attacker-controlled destination. ### Impact Assessment Successful exploitation could disclose: - The user's `X_API_KEY`, potentially allowing unauthorized API use and consumption of paid credits. - User prompts, which may contain confidential or proprietary information. - Reference-image URLs, including potentially sensitive or access-bearing URLs. The issue does not grant local system privileges or arbitrary code execution. I ...[truncated 96 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Remove `--location` because the API endpoint is fixed and redirects are not required: ```bash response=$(curl -sS -m "$TIMEOUT" "$API_URL" \ --header 'Content-Type: application/json' \ --header "x-api-key: $X_API_KEY" \ --data "$payload" 2>&1) ``` - Treat any 3xx response as an error and report it without following the destination. - If redirects are operationally unavoidable, resolve and validate each redirect target against an exact HTTPS origin allowlist before sending credentials. - Never forward `x-api-key` to a different scheme, hostname, or port. - Consider using `--proto '=https'` to prevent protocol downgrade. ]]>
