T09 · Insecure Skill Coding Practices
- Location
scripts/bgm.py:68- Finding
Unvalidated API-provided audio URL enables server-side request forgery and unbounded downloads
- Content
View full analysis
int: p = argparse.ArgumentParser() p.add_argument("--script", required=True) p.add_argument("--duration", type=int, required=True) p.add_argument("--out", required=True) args = p.parse_args() out = pathlib.Path(args.out) if out.exists(): print(f" ⏭️ {out.name} 已存在") return 0 script = json.loads(pathlib.Path(args.script).read_text()) moods = top_moods(script) prompt = build_prompt(moods, args.duration) print(f"🎵 BGM prompt: {prompt}") project_dir = out.parent guard = CostGuard.load(project_dir) try: url = suno_generate(prompt, args.duration) r = requests.get(url, stream=True) out.parent.mkdir(parents=True, exist_ok=True) with open(out, "wb") as f: for chunk in r.iter_content(8192): f.write(chunk) ``` ### Technical Analysis The audio URL is obtained from the response of the third-party Suno-compatible API and passed directly to `requests.get()` without validation. The implementation does not restrict the URL scheme or destination host, reject embedded credentials, verify the resolved IP address, or constrain redirects. Consequently, a compromised, malicious, or incorrectly configured upstream service could return a URL targeting: - Loopback services such as `127.0.0.1` - Private network ranges - Link-local or cloud metadata services - Unexpected external tracking endpoints - Redirectors that event ...[truncated 1555 chars]- Remediation
View remediation
