T09 · Insecure Skill Coding Practices
- Location
scripts/search_web.py:63- Finding
Server-Side Request Forgery Through Unrestricted URL Fetching
- Content
View full analysis
dict: """ Fetch and parse a webpage. Args: url: URL to fetch Returns: Dictionary with title, content, and metadata """ headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36' } try: response = requests.get(url, headers=headers, timeout=15, allow_redirects=True) response.raise_for_status() soup = BeautifulSoup(response.text, 'html.parser') ``` ### Technical Analysis The `fetch_url` function passes a caller-controlled URL directly to `requests.get()` without validating its scheme, hostname, resolved IP address, port, or destination network. Consequently, an attacker who can supply a URL can cause the process to issue HTTP requests to resources reachable from the host running this skill, including: - Loopback services such as `127.0.0.1` or `[::1]`. - Private-network services in RFC 1918 address ranges. - Link-local addresses and potential cloud instance metadata services. - Internal services that are not externally reachable. - Redirect destinations, because `allow_redirects=True` is enabled without revalidating each redirect target. - Hostnames that resolve to prohibited addresses or use DNS rebinding to change their resolution between validation and connection. The response body is extracted and returned in the `content` field, up to 5,000 characters. This makes the issue a response-disclosing SSRF rather than merely a blind SSRF. Although the returned content is truncated, `requests` downloads the response before truncation, so a malicious or unexpectedly large response may also consume excessive memory. ### Attack Path 1. An attacker asks the agent or another caller to fetch an attacker-select ...[truncated 1655 chars]- Remediation
View remediation
