T09 · Insecure Skill Coding Practices
- Location
scripts/generate.sh:92- Finding
API Key and Request Data May Be Forwarded Through HTTP Redirects
- Content
View full analysis
&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
View remediation
&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. ]]>
