Skip to content
SSRF Write-up Intermediate

Exploit SSRF with Gopher for GCP Initial Access

The profile page's image-fetching feature accepted a user-supplied URL and fetched it server-side without proper validation, creating a server-side request forgery (SSRF) vulnerability. By using a gopher URL to inject a custom HTTP request with the required metadata header, an attacker could reach the Google Cloud metadata server and obtain a service account access token, then use it to list a storage bucket and access its contents.

medium.com

Published on medium.com

TRACEROUTE (using port 80/tcp) HOP RTT ADDRESS 1 40.33 ms 192.168.0.1 2 40.56 ms 10.14.161.1 3 ... 4 5 47.75 ms 10.240.254.53 6 ...

Reju Kole, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the server-side image fetcher passed the user-supplied URL to a library that supports the gopher protocol without restricting the destination or protocol, allowing crafted requests to internal services.

Impact

An attacker could obtain a service account access token and use it to list and potentially read files in the cloud storage bucket, including a file named user_data.csv.

What the attacker needed

Access to the profile page; ability to set the url parameter

How it was found

  1. Find the profile page and note that it takes an image URL as a parameter.
  2. Change the url parameter to an external site and observe that the response content is returned.
  3. Use a gopher URL to send a request to the metadata server with the Metadata-Flavor header to list service accounts.
  4. Append the token path to the service account name and send again to retrieve an access token.
  5. Use the token with curl to list objects in the storage bucket.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

The website had a feature that let you give it a link to an image, and the server would go and fetch that link for you. Because it did not check where the link pointed, you could give it a link to a special internal Google Cloud address that only the server itself can reach. That address handed back a secret token, which then let the attacker read files in the company's cloud storage.

What is SSRF?

The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.

Similar reports

View all

Same bug class and techniques, clearest first.

Server-side request forgery (SSRF)

The lesson behind this report.

The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.