November 7, 2026
The SSRF That Mailed Out Your OAuth Token
A Google Cloud debugger bug shows why integrations must control where stored credentials are sent

By Muhammad Asim Shahzad
2 min read
AI disclosure: This article was drafted with AI assistance as an analytical case study of a public disclosure. It is not my own discovery.
Most SSRF stories chase internal metadata. Ron Chan reported one through Google VRP in which Stackdriver Debugger fetched a client-supplied URL and included the user's linked source-control access token in that request. Google fixed it; the researcher noted he couldn't bypass the fix.
Disclaimer:_ Educational and defensive use only. Fixed in 2019. This article intentionally omits exploit requests. Test only within authorized scope._
Vulnerability Overview
- Type: SSRF with credential forwarding, reachable cross-site
- CWE (analytical mapping, not from the source): CWE-918, CWE-352
- CVE: Not stated in the disclosure
- Severity/CVSS and bounty: Not stated in the disclosure
Root Cause (from the disclosure)
Users linked a Bitbucket, GitLab or GitHub account by OAuth, and the researcher found that handshake correctly implemented. The weakness came later: a helper endpoint for listing repository branches accepted a full upstream URL from the browser. Per the researcher, the destination wasn't restricted, the backend request carried the user's token, and the endpoint lacked CSRF protection.
Impact
A forwarded source-control token can reach whatever its scopes allow: potentially private repositories, secrets in code, and CI configuration. Because a victim only needed to be signed in with a linked account, the issue scaled to any user of the feature.
Defensive Analysis (my own, not from the source)
The design flaw is that the client chose the destination while the server chose the credential. Those decisions must live together on the server.
1. Accept identifiers, not URLs. The browser sends a provider name and project ID; the server builds the URL from a fixed base.
2. Validate the final destination, not the input string. Parse with one library, require HTTPS, compare the exact host against an allowlist of API hosts, and reject userinfo, unusual ports and IP literals.
3. Deny redirects for credentialed calls. Many HTTP clients follow redirects and may resend headers. Disable automatic redirects, or re-validate each hop and strip credentials before following.
4. Map tokens to approved API hosts explicitly. The domain where a user authenticates often differs from the API host the token is used with, so don't infer one from the other. Keep a reviewed per-provider list of hosts each token may be sent to.
Developer pseudocode for the safe pattern:
# Pseudocode: server-side allowlist and safe token attachment
API_HOSTS = {
"gitlab": "gitlab-api.example.test",
"github": "github-api.example.test",
}
def fetch_branches(user, provider, project_id):
host = API_HOSTS[provider] # KeyError -> reject
url = f"https://{host}/projects/{quote(project_id, safe='')}/branches"
parsed = urlsplit(url)
if parsed.scheme != "https" or parsed.hostname != host:
raise Rejected()
token = vault.token_for(user, provider)
return http.get(url,
headers={"Authorization": f"Bearer {token}"},
allow_redirects=False, # never forward creds on redirect
timeout=5)# Pseudocode: server-side allowlist and safe token attachment
API_HOSTS = {
"gitlab": "gitlab-api.example.test",
"github": "github-api.example.test",
}
def fetch_branches(user, provider, project_id):
host = API_HOSTS[provider] # KeyError -> reject
url = f"https://{host}/projects/{quote(project_id, safe='')}/branches"
parsed = urlsplit(url)
if parsed.scheme != "https" or parsed.hostname != host:
raise Rejected()
token = vault.token_for(user, provider)
return http.get(url,
headers={"Authorization": f"Bearer {token}"},
allow_redirects=False, # never forward creds on redirect
timeout=5)5. Protect credentialed actions from cross-site triggering. Require a CSRF token or a custom header checked server-side, and use SameSite cookies.
6. Limit blast radius. Request read-only scopes, prefer short-lived tokens, route integration traffic through an egress proxy with a host allowlist, and log outbound destinations so anomalies are visible.
7. Rotate on discovery. If a credential may have been sent anywhere unexpected, treat it as compromised.
Key Takeaways
- In SSRF review, check what the server adds to a request, not only where it can reach.
- A correct OAuth handshake says nothing about how tokens are used afterward.
- The server, never the client, should pair destinations with credentials.
Credit & Sources
Research by Ron Chan (@ngalongc): [Google VRP] SSRF in Google Cloud Platform StackDriver (December 2019), listed in Awesome-Bugbounty-Writeups. Analysis, code and fixes are original suggestions.