T09 · Insecure Skill Coding Practices
- Location
scripts/utils_audio.py:17- Finding
Unvalidated API-Provided URL Enables SSRF and Unbounded File Download
- Content
View full analysis
str: resp = requests.get(url, timeout=60) resp.raise_for_status() return save_bytes(resp.content, output_path) ``` ### Technical Analysis When URL output and automatic downloading are enabled, the application passes the `data.audio` value returned by the MiniMax API directly to `requests.get()` without validating the URL's scheme, host, port, resolved IP address, or redirect chain. Requests follows HTTP redirects by default. Consequently, even an initially acceptable URL could redirect to a loopback, private, link-local, reserved, or cloud metadata address. Exploitation would require an attacker to influence the API response, compromise the remote API, or otherwise compromise the trusted HTTPS response path. The response body is also accessed through `resp.content`, which buffers the entire body in memory before writing it to disk. There is no maximum response-size check, content-type validation, or streamed byte limit. A malicious or compromised endpoint could therefore return an excessively large body and cause memory or disk exhaustion. ### Attack Path 1. A user invokes the script with `--output-format url --download`. 2. The script sends the generation r ...[truncated 1589 chars]- Remediation
View remediation
MAX_AUDIO_BYTES: raise ValueError("Audio download exceeds size limit") output.write(chunk) ``` URL validation must occur immediately before each connection, including after every permitted redirect, to reduce redirect-based and DNS-resolution bypasses. ]]>
