# GHSA-VM4V-5HGJ-RQ77: AutoGPT Classic: SSRF in llamafile setup script via unvalidated download URL and redirects

- Database: GitHub
- Severity: CVSS 7.7 (High)
- Published: 2026-07-14
- Modified: 2026-10-24

## Affected versions

- autogpt-classic (PyPI): fixed in 0.6.66

## Description

# SSRF Vulnerability in AutoGPT's `serve.py` via Unvalidated URL in `urlretrieve`

## Summary

A Server-Side Request Forgery (SSRF) vulnerability exists in `classic/original_autogpt/scripts/llamafile/serve.py` at line 148. The code passes a URL derived from configurable or user-influenced input directly to `urllib.request.urlretrieve()` without validating the scheme, host, or destination. An attacker who can influence the URL value (via environment variables, config files, or other input vectors) can cause the AutoGPT process to issue HTTP requests to arbitrary internal or external hosts.

## Affected Version

- **Repository:** https://github.com/Significant-Gravitas/AutoGPT
- **File:** `classic/original_autogpt/scripts/llamafile/serve.py`, line 148
- **Affected:** Current `master` branch (verified at time of report)

## Vulnerability Details

### Vulnerable Code

```python
# serve.py, line 148
request.urlretrieve(url, ...)
```

The `url` variable is constructed from a host and/or path value that is configurable at runtime (e.g., sourced from environment variables or a settings file) rather than being a fixed, trusted constant.

### Root Cause

The root cause is the absence of any allowlist validation before the URL is passed to `urlretrieve()`. Specifically:

1. The URL's **scheme** is never checked — allowing `file://`, `http://`, `https://`, or other schemes.
2. The URL's **hostname** is never compared against an expected value (e.g., `localhost` or `127.0.0.1`).
3. The URL's **port** is never validated against the expected llamafile server port.

Because the URL value can be influenced by environment-level configuration, an attacker with write access to the environment (e.g., via a compromised `.env` file, CI/CD pipeline injection, or a path traversal in a config loader) can redirect this request to an arbitrary destination — including internal cloud metadata endpoints, internal services, or external attacker-controlled servers.

## Proof of Concept

```python
import urllib.request as request
import os

# Attacker sets or influences the URL (e.g., via environment variable or config)
# Targeting AWS EC2 metadata endpoint as a realistic internal target
attacker_controlled_url = "http://169.254.169.254/latest/meta-data/iam/security-credentials/"

# This mirrors the vulnerable call at serve.py:148
# No validation occurs before the request is issued
response_path, _ = request.urlretrieve(attacker_controlled_url, "/tmp/ssrf_output")

with open("/tmp/ssrf_output") as f:
    print("[SSRF] Response from internal endpoint:")
    print(f.read())
```

**Expected result:** The AutoGPT process fetches the cloud metadata endpoint and writes the response (potentially including IAM credentials) to disk — demonstrating that the request was issued to an unintended internal host.

## Impact

- **Exfiltration of cloud instance metadata** (e.g., AWS IMDSv1 IAM credentials) if running in a cloud environment.
- **Probing of internal network services** not exposed to the public internet.
- **Potential credential theft** if internal services (e.g., databases, Vault, Kubernetes API) are reachable from the host.

The severity is **High** in cloud-hosted deployments. The exploitability is contingent on an attacker's ability to influence the URL value, which is a realistic threat in misconfigured or multi-tenant environments.

## Fix

Before calling `urlretrieve`, validate the URL against a strict allowlist of expected values:

```python
# One-line fix: assert the URL matches the expected local llamafile download source
assert url.startswith("https://huggingface.co/Mozilla/"), f"Blocked untrusted URL: {url}"
```

For a more robust fix, parse the URL with `urllib.parse.urlparse()` and explicitly validate that the scheme is `https` and the hostname matches the expected download host before proceeding.

### Release references

The patched-version metadata for this advisory points to the following release(s):

- [autogpt-platform-beta-v0.6.66](https://github.com/Significant-Gravitas/AutoGPT/releases/tag/autogpt-platform-beta-v0.6.66)

## References

- https://github.com/Significant-Gravitas/AutoGPT/security/advisories/GHSA-vm4v-5hgj-rq77

Page: https://cve.now/GHSA-VM4V-5HGJ-RQ77

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
