T09 · Insecure Skill Coding Practices
- Location
handler.py:37- Finding
Unrestricted URL Fetching Enables Server-Side Request Forgery
- Content
View full analysis
str: import requests if "arxiv.org/abs/" in url: resp = requests.get(url, timeout=15) from markdownify import markdownify as md return md(resp.text, strip=["script", "style"])[:8000] headers = {"User-Agent": "Mozilla/5.0 (compatible; kb-digest/1.0)"} resp = requests.get(url, headers=headers, timeout=15) resp.raise_for_status() try: from markdownify import markdownify as md content = md(resp.text, strip=["script", "style", "nav", "footer"]) except ImportError: import re content = re.sub(r"\s+", " ", re.sub(r"<[^>]+>", " ", resp.text)) return content[:8000] ``` The affected function is invoked with user-controlled values in both individual and batch processing: ```python result = digest(fetch_url(url), url, output_type, cfg) ``` ```python if args.url: content, source_name = fetch_url(args.url), args.url ``` ### Technical Analysis The Skill makes outbound requests to arbitrary user-supplied URLs without validating the URL scheme, destination hostname, resolved IP address, destination port, or redirect targets. Python Requests follows HTTP redirects by default, so validating only the initial textual URL would not be sufficient. An attacker can direct the runtime to request loopback addresses, private-network services, link-local endpoints, or cloud metadata services. The retrieved response is converted to text and then passed to `digest()`, which sends up to 4,000 characters to the configured LLM endpoint. Consequently, the flaw can provide both an internal-network read primitive and a path for indirectly disclosing retrieved data. The network access needed to retrieve public articles is co ...[truncated 1498 chars]- Remediation
View remediation
