AutoGPT Classic: incomplete URL validation in forge allows SSRF in browser commands
Description
The URL validation mechanism (validate_url) in the forge component is insufficient. It only verifies that the URL scheme is http or https but fails to block access to private IP ranges, loopback addresses (localhost), or link-local addresses. This allows the Agent (via read_webpage command) to access internal network resources and cloud metadata services, leading to a Server-Side Request Forgery (SSRF) vulnerability.
Details
The vulnerability is located in classic/forge/forge/utils/url_validator.py.
The validate_url decorator is intended to secure URL inputs for the agent's web browsing capabilities. However, the current implementation only performs a simple regex check:
# classic/forge/forge/utils/url_validator.py
if not re.match(r"^https?://", url):
raise ValueError("Invalid URL format: URL must start with http:// or https://")
if check_local_file_access(url):
raise ValueError("Access to local files is restricted")It completely fails to validate the hostname or resolved IP address against private network ranges (e.g., 127.0.0.0/8, 10.0.0.0/8, 192.168.0.0/16) or cloud metadata IP (169.254.169.254).
As a result, the read_webpage function in classic/forge/forge/components/web/selenium.py, which is decorated with @validate_url, accepts and visits internal URLs when instructed by a user or a malicious prompt injection.
PoC
To reproduce this vulnerability, you can run a local mock server and attempt to access it using the validate_url logic.
- Start a mock internal service (e.g., on port 1337): ```python
http_server.py
import http.server, socketserver PORT = 1337 class Handler(http.server.SimpleHTTPRequestHandler): def do_GET(self): self.send_response(200) self.wfile.write(b"CRITICAL_INTERNAL_SECRET") with socketserver.TCPServer(("localhost", PORT), Handler) as httpd: httpd.serve_forever() ```
- Run the exploit script (verifying the validator allows the connection): ```python
poc.py
import sys, os
Adjust path to point to your AutoGPT/classic/forge directory
sys.path.append(os.path.abspath("classic/forge")) from forge.utils.url_validator import validate_url
class MockComponent: @validate_url def read_webpage(self, url): print(f"Validator ALLOWED access to: {url}")
This should raise a ValueError if properly secured, but it does NOT.
try: MockComponent().read_webpage(url="localhost") print("[!] Vulnerability Reproduced: Validator allowed localhost access.") except ValueError as e: print(f"[-] Blocked: {e}") ```
- Observation: The script outputs "Validator ALLOWED access to: localhost".
Impact
This vulnerability allows a malicious actor (via direct prompt to the agent or prompt injection from a visited webpage) to:
- Exfiltrate Cloud Credentials: Access
http://169.254.169.254/latest/meta-data/to steal AWS/GCP/Azure IAM credentials if the agent is running in a cloud environment. - Internal Network Reconnaissance: Scan for open ports on localhost or other devices in the local network (e.g.,
http://192.168.1.1). - Interact with Internal Services: Send GET requests to internal APIs or databases that expose HTTP interfaces without authentication (assuming they are safe behind a firewall).
Release references
The patched-version metadata for this advisory points to the following release(s):