T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/scrape_web.py:127- Finding
Unrestricted URL Fetching Enables Server-Side Request Forgery
- Content
View full analysis
tuple: """Fetch page HTML and return (html_text, response).""" print(f"[FETCH] Fetching: {url}") try: resp = requests.get(url, headers=HEADERS, timeout=timeout, allow_redirects=True) resp.raise_for_status() # Detect encoding if resp.encoding and resp.encoding.lower() == "iso-8859-1": resp.encoding = resp.apparent_encoding html = resp.text print(f"[OK] Fetched {len(html)} bytes, encoding: {resp.encoding}") return html, resp except requests.exceptions.Timeout: print(f"[ERROR] Request timed out after {timeout}s") return "", None except requests.exceptions.HTTPError as e: print(f"[ERROR] HTTP error: {e}") return "", None except Exception as e: print(f"[ERROR] Fetch failed: {e}") return "", None ``` ### Technical Analysis The required `--url` argument is passed directly to `requests.get()` without validating its scheme, hostname, resolved IP address, or destination network. Redirects are explicitly enabled through `allow_redirects=True`, and redirect destinations are not revalidated. As a result, a user can make the host running the Skill send requests to network locations that may not be directly accessible to that user. Potential targets include: - Loopback services such as `127.0.0.1` and `::1` - Private IPv4 and IPv6 networks - Link-local services - Cloud instance metadata endpoints - Internal administration panels and APIs - Public URLs that redirect to an internal destination The scraper subsequently extracts response content and writes it to Markdown or JSON. The workflow may then expose that content to the agent or publish it to a We ...[truncated 1168 chars]- Remediation
View remediation
