T09 · Insecure Skill Coding Practices
- Location
scripts/ima_reference_validation.py:105- Finding
Unrestricted remote media fetching enables server-side request forgery
- Content
View full analysis
tuple[str, int, str | None]: with requests.get(url, stream=True, timeout=30) as response: response.raise_for_status() ``` The separate video-cover download path is also affected: ```python def download_remote_media_to_temp(url: str, suffix: str = "") -> str: """Download remote media URL to a temporary local file and return the path.""" with requests.get(url, stream=True, timeout=60) as response: response.raise_for_status() with tempfile.NamedTemporaryFile(delete=False, suffix=suffix) as temp_file: for chunk in response.iter_content(chunk_size=1024 * 64): if chunk: temp_file.write(chunk) return temp_file.name ``` It is reached with user-controlled input: ```python if isinstance(source, str) and is_remote_url(source): suffix = Path(source).suffix or ".mp4" temp_video_path = download_remote_media_to_temp(source, suffix=suffix) video_path = temp_video_path ``` ### Technical Analysis The Skill fetches user-supplied HTTP and HTTPS URLs without validating the destination hostname, resolved IP address, port, or redirect chain. The only relevant input check is whether the string begins with `http://` or `https://`. Consequently, URLs targeting loopback, private, link-local, reserved, or cloud metadata addresses are accepted. Because `requests` follows redirects by default, an initially public URL can also redirect to an internal destination. The reference-validation downloader applies a byte limit, but that limit does not prevent SSRF. The separate vi ...[truncated 1416 chars]- Remediation
View remediation
