The Red Agent POV: How it Reasoned its Way to SSRF
A GCP Cloud Run service accepted a URL parameter that was supposed to fetch only GitHub blob URLs, but a double-slash after a valid GitHub URL caused the fetcher to treat the trailing part as a local absolute path. An attacker could read local files, including environment variables with GCP service-account credentials and the application source code.
For the first deep-dive blog in our Red Agent POV series we will focus on a Server-Side Request Forgery (SSRF) exploit discovered by the Red Agent, which is one of the most common and impactful bug classes in modern cloud applications. In this exploit, the Red Agent found a critical multi-step attack chain that…
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 URL validator checked only the prefix of the URL for a valid GitHub structure, while the file-fetching logic interpreted the part after a double slash as an absolute local path, so the two components disagreed on what the URL meant.
Impact
An unauthenticated attacker could read local files, including live GCP service-account credentials and the full application source code, leading to a complete compromise chain.
What the attacker needed
None
How it was found
- Send a request to the endpoint with a URL parameter pointing to the GCP metadata server; observe it is blocked because the URL must be a GitHub blob URL.
- Try path traversal sequences in the URL parameter; observe they are rejected because the validator checks the full URL structure.
- Try URL confusion techniques such as authority confusion, fragment injection, subdomain spoofing, and scheme switching; observe they are blocked, confirming the fetcher makes real HTTP requests.
- Try injecting traversal strings into the repository name component; observe they are blocked.
- Enumerate real GCP-related repositories to learn internal naming conventions.
- Append a double slash followed by an absolute filesystem path after a valid GitHub blob URL; observe the server returns the contents of the local file.
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 application had a feature that fetched a file from a URL you gave it, but it only allowed URLs that looked like GitHub links. The attacker found that by adding two slashes and a file path after a valid GitHub link, the server would read a file from its own disk instead of from GitHub. This let them steal secret keys and the program's code.
What is SSRF?
The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.