T05 · Unauthorized Access and Privilege Escalation
Error
- Location
- scripts/monitor_prices.py:41
- Finding
- Unrestricted Browser Navigation Enables Access to Internal and Local Resources<![CDATA[ ## Vulnerability Details **File Location**: `scripts/monitor_prices.py:41-65`, with attacker-controlled input passed at `scripts/monitor_prices.py:145` **Vulnerability Type**: Server-Side Request Forgery and local-resource access **Risk Level**: High ### Vulnerable Code ```python def get_page_snapshot(url): """Open URL and get interactive snapshot.""" # Open the page stdout, stderr, code = run_agent_browser(["open", url]) if code != 0: return None, f"Failed to open {url}: {stderr}" # Get snapshot stdout, stderr, code = run_agent_browser(["snapshot", "-i", "--json"]) if code != 0: return None, f"Failed to get snapshot: {stderr}" try: elements = json.loads(stdout) return elements, None except json.JSONDecodeError: return None, "Failed to parse snapshot JSON" def extract_price(url, selector): """Extract price from a webpage using agent-browser.""" # Open the page stdout, stderr, code = run_agent_browser(["open", url]) if code != 0: return None, f"Failed to open page: {stderr}" # Try to find element by selector stdout, stderr, code = run_agent_browser(["get", "text", selector]) ``` The unvalidated URL originates from the product CSV: ```python price, error = extract_price(product['url'], product['selector']) ``` ### Technical Analysis The script passes a URL read directly from a user-supplied CSV file to `agent-browser open`. It does not restrict URL schemes, destination hostnames, resolved IP addresses, ports, or redirects. Consequently, a malicious product list can instruct the browser to navigate to destinations outside the intended public e-commerce scope. Depending on the protocols supported by `agent-browser`, possible targets include: - Loopback services such as `http://127.0.0.1` or `http://localhost` - Private network services in RFC 1918 address ranges - Link-local services, including cloud metadata endpoints such as ...[truncated 1858 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Permit only `http` and `https` URLs and reject all other schemes. 2. Reject URLs containing embedded credentials or malformed hostnames. 3. Resolve the hostname before navigation and reject every resolved address that is loopback, private, link-local, multicast, unspecified, or otherwise reserved. 4. Explicitly block known metadata destinations, including IPv4 and IPv6 metadata addresses. 5. Revalidate the destination after every redirect to prevent redirect-based SSRF. 6. Consider requiring an explicit allowlist of approved retailer domains. 7. Restrict unnecessary ports, preferably allowing only ports 80 and 443. 8. Run browser automation in a network sandbox that cannot reach local, private, or metadata networks. 9. Apply DNS-rebinding-resistant validation by connecting only to the already validated address or enforcing equivalent browser/network-layer controls. 10. Validate selectors and extracted data against the expected price format before storing them. ]]>
