T09 · Insecure Skill Coding Practices
- Location
scripts/imagegen.py:350- Finding
Unvalidated API Response Enables SSRF, Path Traversal, and Unbounded File Downloads
- Content
View full analysis
0: pct = int(downloaded * 100 / total) bar = "█" * (pct // 5) + "░" * (20 - pct // 5) print(f"\r {bar} {pct}% ({downloaded // 1024}KB)", end="", flush=True) ``` ```python task_type = task.get("taskType", "task") for i, item in enumerate(succeeded): result_url = item.get("resultUrl") if not result_url: continue ext = ".mp4" if "video" in task_type.lower() else ".png" filename = f"{task_type}_{task_id}_{i+1}{ext}" out_path = out_dir / filename download_file(result_url, out_path) ``` ### Technical Analysis The application uses two values obtained from the remote task API without validation: 1. `resultUrl` is passed directly to `requests.get()`. No scheme, hostname, port, resolved IP address, or redirect destination is validated. Requests follows redirects by default. A compromised or malicious API response can consequently direct the client to an internal, loopback, link-local, or otherwise unintended HTTP endpoint. 2. `taskType` is included directly in a filesystem path. Path separators, absolute-path syntax, or `..` compon ...[truncated 1924 chars]- Remediation
View remediation
