T09 · Insecure Skill Coding Practices
- Location
scripts/generate_music.py:71- Finding
Unvalidated API-Controlled Audio Download Enables SSRF and Resource Exhaustion
- Content
View full analysis
Vulnerability Details
File Location:
scripts/generate_music.py:71-73; duplicated inscripts/create_song.py:130-132
Vulnerability Type: Server-Side Request Forgery (SSRF), unrestricted redirects, and unbounded response download
Risk Level: MediumVulnerable code in
scripts/generate_music.py:71-73:python response = requests.get(audio_url, timeout=60) with open(filepath, 'wb') as f: f.write(response.content)Duplicated vulnerable code in
scripts/create_song.py:130-132:python response = requests.get(audio_url, timeout=60) with open(filepath, 'wb') as f: f.write(response.content)The same unsafe pattern is also presented as recommended usage in
SKILL.md:93-95.Technical Analysis
The
audio_urlvalue is obtained from the MiniMax API response and passed directly torequests.get. Although the initial API endpoint is fixed, the returned download location is externally controlled data and is not validated before the local request is made.The implementation does not:
- Restrict the URL to HTTPS.
- Restrict downloads to expected MiniMax or approved CDN hostnames.
- Reject loopback, private, link-local, multicast, or reserved IP addresses.
- Revalidate the destination after DNS resolution.
- Validate each redirect destination;
requestsfollows redirects by default. - Call
raise_for_status()to reject unsuccessful responses. - Check that the response has an expected audio content type.
- Stream the response with an enforced maximum size.
- Verify that the downloaded data is a valid audio file.
The entire response is first loaded into memory through
response.contentand then written to disk with an.mp3extension regardless of its actual type. A compromised API, compromised upstream account, malicious CDN response, or poisoned response path could therefore cause the machine running the Skill to issue requests to otherwise inaccessible net ...[truncated 2021 chars]- Remediation
View remediation
Remediation Suggestions
- Parse the returned URL and permit only
httpsURLs. - Maintain an explicit allowlist of documented MiniMax audio CDN hostnames. Do not rely on suffix checks that can be bypassed by names such as
trusted.example.attacker.test. - Resolve the hostname and reject every address in loopback, private, link-local, multicast, unspecified, and reserved ranges for both IPv4 and IPv6.
- Disable automatic redirects with
allow_redirects=False, or validate the scheme, hostname, resolved addresses, and port of every redirect target before following it. - Use
response.raise_for_status()before creating the output file. - Allow only expected audio media types and validate the downloaded file signature rather than trusting the extension or
Content-Typeheader alone. - Use
stream=True, read fixed-size chunks, and stop when a strict maximum output size is reached. The limit should reflect the documented maximum expected song size. - Write to a temporary file with restrictive permissions and atomically rename it only after all validation succeeds. Delete partial files on failure.
- Apply the same hardened helper to both
generate_music.pyandcreate_song.py, and update the unsafe example inSKILL.md. - Where supported by the API, prefer inline audio data with explicit decoded-size validation over fetching an unrestricted remote URL.
- Parse the returned URL and permit only
