T09 · Insecure Skill Coding Practices
- Location
scripts/extract_visible_text.py:43- Finding
Unrestricted URL Fetching Enables Server-Side Request Forgery
- Content
View full analysis
str: req = Request(url, headers={'User-Agent': user_agent}) with urlopen(req) as resp: charset = resp.headers.get_content_charset() or 'utf-8' return resp.read().decode(charset, errors='replace') ``` ```python def download_file(url: str, suffix=''): req = Request(url, headers={'User-Agent': UA}) with urlopen(req) as resp: data = resp.read() ctype = resp.headers.get('Content-Type', '') if not suffix: path = urlparse(url).path.lower() for ext in ['.png', '.jpg', '.jpeg', '.webp', '.bmp', '.gif', '.svg']: if path.endswith(ext): suffix = ext break if not suffix: if 'png' in ctype: suffix = '.png' elif 'jpeg' in ctype or 'jpg' in ctype: suffix = '.jpg' elif 'webp' in ctype: suffix = '.webp' elif 'gif' in ctype: suffix = '.gif' elif 'svg' in ctype: suffix = '.svg' else: suffix = '.bin' fd, tmp = tempfile.mkstemp(prefix='visible-text-', suffix=suffix) os.close(fd) Path(tmp).write_bytes(data) return tmp ``` ### Technical Analysis The Skill accepts a user-controlled `--url` and passes it directly to `urllib.request.urlopen`. It also parses image URLs from untrusted HTML and downloads those URLs when `--ocr-images` is enabled. There is no validation of: - The URL scheme - The destination hostname - The resolved IP address - Redirect destinations - Network ports - Embedded URL credentials - Loopback, link-local, private, reserve ...[truncated 2018 chars]- Remediation
View remediation
