T09 · Insecure Skill Coding Practices
- Location
scripts/video_url_to_text.py:376- Finding
Unrestricted Video URL Fetch Enables Server-Side Request Forgery
- Content
View full analysis
5: ext = ".mp4" output_filename = f"{filename}{ext}" output_path = os.path.join(output_dir, output_filename) print(f"[1/5] 正在下载视频: {url}") print(f"保存到: {output_path}") response = requests.get(url, stream=True, timeout=300) response.raise_for_status() with open(output_path, "wb") as f: for chunk in response.iter_content(chunk_size=8192): f.write(chunk) file_size = os.path.getsize(output_path) print(f"下载完成,文件大小: {file_size / 1024 / 1024:.2f} MB") return output_path, filename ``` ### Technical Analysis The URL originates directly from a command-line argument or standard input and is passed to `requests.get()` without validating its scheme, hostname, resolved IP address, port, or redirect destinations. The `requests` library follows redirects by default. An attacker can therefore cause the system running the Skill to send requests to destinations that may not be accessible from the attacker's own network position, including: - Loopback services such as `127.0.0.1` or `::1` - RFC 1918 private-network services - Link-local services and cloud instance metadata endpoints - Internal administrative interfaces - Redirectors that initially appear public but redirect to a protected address Parsing the URL solely to derive a filename extension does not provide any security validation. The downloaded response is written locally, processed by `ffmpeg`, and may subsequently be uploaded to TOS. ### Attack Path 1. An attacker submits a URL pointing directly to an inte ...[truncated 1124 chars]- Remediation
View remediation
