T09 · Insecure Skill Coding Practices
- Location
scripts/fetch_video.py:338- Finding
Unrestricted URL Navigation Enables Server-Side Request Forgery
- Content
View full analysis
str: item = (item or "").strip() if not item: return "" if item.startswith("http://") or item.startswith("https://"): return item if item.isdigit() and 8 <= len(item) <= 25: return f"https://www.douyin.com/video/{item}" return item ``` ### Technical Analysis Although the Skill is documented as a Douyin-specific downloader, `normalize_input_to_url` accepts any value beginning with `http://` or `https://` without validating its hostname, resolved IP address, port, or protocol security. The resulting URL is passed directly to Playwright's `page.goto`. Consequently, an attacker who can control a positional argument or a line in the batch input file can make the process navigate to arbitrary network destinations. This includes loopback services, private network addresses, link-local endpoints, or attacker-controlled public pages. Redirect destinations are also not restricted. Checking only the URL scheme is insufficient for SSRF prevention. Hostnames can resolve to private addresses, and an initially permitted public address can redirect to or be rebound to an internal address. ### Attack Path 1. An attacker supplies a crafted input through a positional argument or `--file`, such as an HTTP URL targeting a service reachable only from the host running the Skill. 2. `read_inputs` retains the input without security validation. 3. `normalize_input_to_url` accepts the URL unchanged because it starts with `http://` or `https://`. 4. `download_video` passe ...[truncated 1001 chars]- Remediation
View remediation
