T09 · Insecure Skill Coding Practices
- Location
scripts/transcribe_audio.py:222- Finding
Unvalidated Server-Provided Transcription URL Enables SSRF
- Content
View full analysis
Vulnerability Details
File Location:
scripts/transcribe_audio.py:222-224, 335-339
Vulnerability Type: Server-Side Request Forgery (SSRF) through an unvalidated API response URL
Risk Level: MediumVulnerable Code
python def _fetch_json_url(url: str) -> dict[str, Any]: try: with urllib.request.urlopen(url, timeout=180) as resp: raw = resp.read().decode("utf-8")python if async_mode and status.upper() == "SUCCEEDED": transcription_url = (((final_resp.get("output") or {}).get("result") or {}).get("transcription_url") or "") if isinstance(transcription_url, str) and transcription_url: transcription_json = _fetch_json_url(transcription_url) final_resp["transcription_result"] = transcription_jsonTechnical Analysis
After a successful asynchronous transcription, the script extracts
transcription_urlfrom the remote API response and passes it directly tourllib.request.urlopen.The destination is not subject to:
- Scheme validation, such as requiring HTTPS.
- An Alibaba Cloud hostname allowlist.
- DNS resolution and rejection of loopback, private, link-local, multicast, or reserved addresses.
- Redirect-target validation.
- A maximum response-size limit.
Because
urllibfollows HTTP redirects by default, validating only the initial URL would also be insufficient. An allowed-looking URL could redirect the client to an internal address.Exploitation requires an attacker to influence the response returned by the configured DashScope endpoint, such as through compromise of the provider or another trusted response path. The primary API endpoints themselves are hard-coded HTTPS URLs, which reduces exposure but does not eliminate the unsafe trust boundary.
Attack Path
- A user invokes asynchronous transcription with
--wait. - The script submits the request to the hard-coded DashScope API and polls until the task reports
SUCCEEDED. - An attacker capable of influenci ...[truncated 1590 chars]
- Remediation
View remediation
Remediation Suggestions
- Accept only
httpstranscription-result URLs. - Allowlist the exact Alibaba Cloud storage hostnames documented for transcription results. Compare normalized hostnames exactly rather than using suffix-only substring checks.
- Resolve the hostname and reject every resolved loopback, private, link-local, multicast, unspecified, or reserved IP address for both IPv4 and IPv6.
- Disable automatic redirects or implement a redirect handler that revalidates the scheme, hostname, port, and resolved addresses at every hop.
- Restrict destination ports to
443. - Apply a bounded response-size limit rather than reading the entire response into memory.
- Validate the response content type and expected transcription-result schema before storing it.
- Fail closed if the destination cannot be validated.
- Add tests covering direct private addresses, encoded IP representations, IPv6 loopback and link-local addresses, DNS rebinding scenarios, and redirects to internal destinations.
- Accept only
