T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/suno.sh:133
- Finding
- Unrestricted URL Download and Arbitrary File Overwrite## Vulnerability Details **File Location**: `scripts/suno.sh`, lines 133-153 **Vulnerability Type**: Unvalidated URL retrieval and unrestricted output path **Risk Level**: High ### Vulnerable Code ```bash cmd_download() { local url="" out="" while [[ $# -gt 0 ]]; do case "$1" in --url) url="$2"; shift 2 ;; --out) out="$2"; shift 2 ;; *) shift ;; esac done [[ -z "$url" ]] && { echo '{"error": "Missing --url"}'; exit 1; } if [[ -z "$out" ]]; then local filename filename="suno-$(date +%Y%m%d-%H%M%S)-$(openssl rand -hex 4).mp3" out="$DOWNLOAD_DIR/$filename" fi curl -sfL "$url" -o "$out" 2>&1 echo "{\"downloaded\": \"$out\"}" } ``` ### Technical Analysis The `download` command passes the user-controlled `--url` value directly to `curl` and writes the response to the user-controlled `--out` path. Neither value is validated. The URL is not restricted to HTTPS or to approved Suno/CDN hosts. Depending on the protocols supported by the installed `curl` build, an attacker can use schemes such as `file://` or request internal HTTP services. The `-L` option also follows redirects without validating whether the final destination remains on an approved host. The output path is not canonicalized or restricted to `SUNO_DOWNLOAD_DIR`. An absolute path, path traversal sequence, or symlink can therefore target any file writable by the invoking account. `curl -o` will overwrite an existing writable file. Shell command injection is not present in this code because the URL and output path are quoted. The vulnerability instead arises from excessive resource access granted through valid `curl` functionality. ### Attack Path 1. An attacker or untrusted instruction causes the skill to invoke the `download` command with a crafted URL and destination. 2. For local file copying, the attacker supplies a readable local resource, such as `file:///path/t ...[truncated 1386 chars]
- Remediation
- ## Remediation Suggestions 1. Accept only `https://` URLs and reject all other schemes. 2. Allowlist the exact Suno and approved audio-CDN hostnames required by the feature. 3. Resolve and validate destination addresses to block loopback, link-local, private, multicast, and cloud metadata ranges where they are not required. 4. Disable redirects or validate every redirect target against the same scheme, hostname, and address restrictions. 5. Do not accept arbitrary output paths. Accept only a filename and construct the destination beneath `SUNO_DOWNLOAD_DIR`. 6. Canonicalize the destination and verify that it remains inside the approved directory. 7. Reject traversal components, absolute paths, symlinks, non-regular files, and existing files. 8. Create output files atomically with restrictive permissions and fail if the destination already exists. 9. Apply response size and transfer time limits to reduce resource-exhaustion risk. 10. Return JSON using `jq` rather than string interpolation so unusual path characters cannot produce malformed output.
