T09 · Insecure Skill Coding Practices
- Location
scripts/download_video.py:122- Finding
Unrestricted Page URL Fetching Enables Server-Side Request Forgery
- Content
View full analysis
Optional[str]: try: response = requests.get(page_url, headers=HEADERS, timeout=30) response.raise_for_status() return response.text except requests.RequestException as e: print(f"Failed to fetch page: {e}") return None ``` The function is called directly with the user-supplied command-line argument: ```python html_content = fetch_page_content(args.url) ``` ### Technical Analysis The application performs an HTTP request to a user-controlled URL without validating: - The URL scheme - The destination hostname - The resolved IP address - The destination port - Redirect destinations - Whether the destination belongs to Xiaohongshu Although the Skill is intended to process Xiaohongshu pages, the implementation does not enforce this restriction. The `requests` library also follows redirects by default, so validating only an initial URL in a future partial fix would not be sufficient. An attacker can provide a URL targeting loopback addresses, private network ranges, link-local services, or cloud instance metadata endpoints. DNS rebinding or an attacker-controlled redirect can similarly route a superficially legitimate request to a prohibited destination. ### Attack Path 1. An attacker supplies a URL such as `http://127.0.0.1:PORT/internal`, a private-network service, or a URL that redirects to such a destination. 2. `args.url` is passed directly to `fetch_page_content()`. 3. `requests.get()` connects to the attacker-selected destination from the environment running the Skill. 4. The target response is read and processed as HTML. 5. Observable output, response differences, or subsequent media extraction can disclose service availability or cause further request ...[truncated 644 chars]- Remediation
View remediation
