T09 · Insecure Skill Coding Practices
- Location
references/code-examples/bria_client.sh:101- Finding
API Key Disclosure Through Unvalidated Status Polling URL
- Content
View full analysis
&2; return 1 fi url=$(printf '%s' "$poll" | sed -n 's/.*"result_url" *: *"\([^"]*\)".*/\1/p') [ -z "$url" ] && url=$(printf '%s' "$poll" | sed -n 's/.*"image_url" *: *"\([^"]*\)".*/\1/p') [ -n "$url" ] && { echo "$url"; return 0; } ``` ### Technical Analysis The polling URL is extracted from an API response and passed directly to `curl`. The code does not verify the URL scheme, hostname, port, or origin before attaching the Bria API key in the `api_token` header. A response containing an attacker-controlled `status_url` therefore causes the client to disclose its API key to that destination. HTTPS alone would not resolve the issue because an attacker can operate a valid HTTPS server. The destination must be constrained to the expected Bria API origin. The documented API behavior only requires polling under `https://engine.prod.bria-api.com/v2/status/...`; forwarding credentials to arbitrary response-provided origins exceeds the minimum privileges necessary for background removal. ### Attack Path 1. An attacker compromises or influences the initial API response, or the configured API destination returns malicious response data. 2. The response includes a value such as: ```json { "status_url": "https://attacker.example/collect" } ``` 3. The helper extracts that URL without va ...[truncated 696 chars]- Remediation
View remediation
