T09 · Insecure Skill Coding Practices
- Location
scripts/search_web.py:62- Finding
Unrestricted URL Fetching Enables Server-Side Request Forgery
- 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) ``` ### Technical Analysis The `fetch_url` function passes a caller-controlled URL directly to `requests.get`. It performs no validation of the URL scheme, hostname, destination port, or resolved IP address. Consequently, a caller can direct the application to make HTTP requests to destinations that may not be externally accessible, including: - Loopback services such as `127.0.0.1` - Private network ranges such as `10.0.0.0/8` and `192.168.0.0/16` - Link-local services such as cloud metadata endpoints - Internal services reachable only from the Agent's network environment The request also sets `allow_redirects=True`. A seemingly legitimate public URL can therefore redirect to a prohibited internal address. Because redirect destinations are not revalidated, a basic validation check applied only to the original URL would not be sufficient. The function subsequently extracts page text and returns up to 5,000 characters of content to the caller, creating a direct channel through which responses from reachable internal HTTP services may be disclosed. ### Attack Path 1. An attacker invokes the URL-fetching functionality with an internal destination, such as a loopback address, private-network host, or link-local metadata endpoint. 2. Alternatively, the attacker supplies a public URL under their control that redirects to an internal destination. 3. `fetch_url` passes the sup ...[truncated 1232 chars]- Remediation
View remediation
