The SSRF That Mailed Out Your OAuth Token
A helper endpoint in Google Cloud Stackdriver Debugger that listed repository branches accepted a full upstream URL from the browser and fetched it with the user's linked source-control OAuth token attached. Because the destination was unrestricted and the endpoint lacked CSRF protection, an attacker could make the victim's browser trigger requests that sent the token to a host of the attacker's choosing.
medium.com
Published on medium.com
Bug Bounty
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.
Context
Stackdriver Debugger, part of Google Cloud Platform, is the product at the centre of this case. Users could link a Bitbucket, GitLab or GitHub account by OAuth, and the debugger then used that link to work with the user's source-control repositories. One of the features involved a helper endpoint that listed repository branches for the browser.
That branch-listing helper is where the problem sat. The browser supplied a full upstream URL to the endpoint, and the backend fetched it. The researcher, Ron Chan, reported the issue through Google VRP; his write-up is dated December 2019. Google fixed it, and the researcher noted he could not bypass the fix.

The illustration above is AI-generated and accompanies the write-up.
Setup
The precondition for a victim was simple: they had to be signed in with a linked source-control account. The report does not describe any special tooling, versions or additional roles beyond that. The researcher found the OAuth handshake itself correctly implemented, so the linking flow was not the weak point.
Finding it
Most SSRF work chases internal metadata endpoints. This one is different: the interesting part is not only where the server could be made to reach, but what the server attached to the request when it got there. The branch-listing helper accepted a full upstream URL from the browser, and the backend request carried the user's linked source-control access token. According to the researcher, the destination was not restricted and the endpoint had no CSRF protection.
That combination is what made it worth reporting: a client-controlled destination, a server-supplied credential, and a way to trigger the request cross-site.
Exploitation
The write-up intentionally omits the exploit requests, so there are no payloads or raw HTTP exchanges to reproduce here. What the disclosure establishes is the shape of the attack:
- A victim is signed in and has linked a Bitbucket, GitLab or GitHub account.
- The attacker causes the browser to call the branch-listing helper with an upstream URL of the attacker's choosing. Because the endpoint lacked CSRF protection, this could be triggered cross-site.
- The backend fetches the supplied URL and includes the victim's linked source-control access token in that request.
- The token is sent to whatever destination the attacker names, since the destination was not restricted.
The report does not state which HTTP method, parameter names or response bodies were involved, and it does not give the exact request that was sent.
Root cause
The OAuth handshake was correct. The weakness came afterwards, in how the stored token was used. The helper endpoint for listing repository branches took a full upstream URL from the browser, did not restrict the destination, and attached the user's token to the backend request. It also lacked CSRF protection, so a third-party page could cause the request to happen.
The design flaw, as the analysis puts it, is that the client chose the destination while the server chose the credential. Those two decisions need to live together on the server. A correct OAuth handshake says nothing about how tokens are used afterwards.
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.
Fix
Google fixed the issue in 2019, and the researcher noted he could not bypass the fix. The defensive guidance below is the author's own analysis, not part of the disclosure.
- Accept identifiers, not URLs. The browser sends a provider name and project ID; the server builds the URL from a fixed base.
- 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.
- 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.
- 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 do not infer one from the other. Keep a reviewed per-provider list of hosts each token may be sent to.
- Protect credentialed actions from cross-site triggering. Require a CSRF token or a custom header checked server-side, and use SameSite cookies.
- 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.
- Rotate on discovery. If a credential may have been sent anywhere unexpected, treat it as compromised.
Developer pseudocode for the safe pattern, as given in the write-up:
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)
Variants to test
- Client-supplied upstream URL on any integration helper. Look for endpoints that proxy to a third-party API on behalf of a linked account. A positive result is a request where you control the destination and the response or an out-of-band callback shows the server's request arriving with the user's credential attached.
- Credentialed endpoints without CSRF protection. Try triggering the helper from a third-party page while signed in. A positive result is the backend request firing without a CSRF token or custom header, with the token still attached.
- Redirect handling on credentialed calls. Point the helper at a URL that redirects to a host you control. A positive result is the client following the redirect and resending the Authorization header to the new host.
- Host allowlist bypasses. If a fix restricts the destination, try userinfo, unusual ports, IP literals and lookalike hostnames. A positive result is the request reaching a host outside the intended allowlist.
- Scope review of linked tokens. Check what the forwarded token can actually do. A positive result is a token whose scopes reach private repositories, secrets in code or CI configuration.
What happened, in plain words
Google Cloud Platform is a large collection of online services that Google runs for developers. One of those services was called Stackdriver Debugger. It helped developers inspect and troubleshoot their programs while those programs were running in the cloud.
Many developers keep their code on a source-control website such as Bitbucket, GitLab or GitHub. Think of source control as a shared online folder that keeps every version of a project's files and records who changed what. Stackdriver Debugger let a user connect one of those accounts to it, so the debugger could look at the user's code repositories. A repository (often shortened to "repo") is one project's folder of files plus its history.
The connection between the two services was made with OAuth. OAuth is a standard way for one website to get limited permission to act on another website on your behalf, without you handing over your password. A familiar example: when a website offers "Sign in with Google", that is OAuth at work. You approve the connection once, and the first website receives a token.
A token is a long random string that works like a temporary key or a cloakroom ticket. Whoever holds it can do whatever it is allowed to do, so it must be kept secret, just as you would not leave a cloakroom ticket lying on a table. In this case the token let the debugger read the user's source-control account.
One feature of the debugger needed to show a list of branches. A branch is a parallel copy of a project's files, used to work on a change without disturbing the main version. To get that list, the debugger's website (the part running in your browser) called a small helper on Google's servers, and that helper then contacted the source-control service. This kind of helper is often called an endpoint: a specific address on a server that does one job when it is called.
The problem was in that helper. The browser told the helper the full web address (URL) to fetch, and the helper fetched it. A URL is the address of a page or resource on the web, like https://example.test/some/path. The helper did not check where it was being sent, and it attached the user's source-control token to the request it made. On top of that, the helper had no protection against being triggered by another website.
This is a class of bug called SSRF, short for Server-Side Request Forgery. In plain terms: you trick a server into making a web request to an address of your choosing. A comparison: imagine a helpful assistant who will post a letter to any address you write on the envelope, and who also signs it with the boss's name. If you can choose the address, you can have the boss's signed letter delivered to your own house.
The researcher who found this was Ron Chan. He reported it through Google VRP; his write-up is dated December 2019. VRP stands for Vulnerability Reward Program: a scheme where companies pay people for reporting security bugs responsibly instead of exploiting them. Google fixed the issue, and the researcher noted that he could not bypass the fix.

The illustration above is AI-generated and accompanies the write-up.
Setup
To be affected, a victim needed only one thing: to be signed in to the debugger with a source-control account already linked. The report does not describe any special tools, software versions or extra roles beyond that.
Why does this matter? Because a bug that needs no unusual setup affects many more people. If a victim had to install something odd or hold a special administrator role, only a handful of users would be at risk. Here, any ordinary user of the feature qualified.
The researcher also checked the OAuth handshake, meaning the step where the two services agree to trust each other and the token is first issued. He found it correctly implemented. So the linking flow, the part everyone worries about, was not the weak point. The mistake came later, in how the stored token was used.
Finding it
Most SSRF hunting looks for internal metadata endpoints. Cloud servers often expose a special internal address that hands out information about the machine, and attackers try to make the server fetch that address so the answer comes back to them. This case is different. The interesting part is not only where the server could be made to go, but what the server carried with it when it arrived.
The branch-listing helper accepted a full upstream URL from the browser. "Upstream" here means the other service being contacted, the source-control provider. The backend request, the one the server made on its own, carried the user's linked source-control access token. According to the researcher, the destination was not restricted, and the endpoint had no CSRF protection.
CSRF stands for Cross-Site Request Forgery. It means another website can make your browser send a request to a site where you are already signed in, and the site treats it as if you had asked for it yourself. A comparison: a stranger cannot open your front door, but if they can slip a note under it asking your assistant to run an errand, your assistant will happily do it because the request came from inside your house. CSRF protection is the equivalent of your assistant checking that the note carries a secret code only you know.
Put together, three things made this worth reporting: the browser chose the destination, the server supplied the credential, and a third-party page could trigger the request.
Exploitation
The write-up deliberately leaves out the exploit requests, so there are no payloads or raw HTTP exchanges to reproduce here. A payload is the actual data an attacker sends to make a bug happen. What the disclosure does establish is the shape of the attack:
- A victim is signed in and has linked a Bitbucket, GitLab or GitHub account.
- The attacker causes the browser to call the branch-listing helper with an upstream URL of the attacker's choosing. Because the endpoint lacked CSRF protection, this could be triggered cross-site, meaning from a page on a different website.
- The backend fetches the supplied URL and includes the victim's linked source-control access token in that request.
- The token is sent to whatever destination the attacker names, since the destination was not restricted.
The report does not state which HTTP method, parameter names or response bodies were involved, and it does not give the exact request that was sent. An HTTP method is the verb in a web request, such as GET for "give me this" or POST for "here is some data". Parameters are the named values attached to a request, like the fields on a form.
Why does the order matter? Each step is a normal, harmless action on its own. Signing in is normal. Listing branches is normal. Sending a token to the provider is normal. The bug is the combination: the attacker gets to choose the destination while the server keeps attaching the secret.
Root cause
The OAuth handshake was correct. The weakness came afterwards, in how the stored token was used. The helper endpoint for listing repository branches took a full upstream URL from the browser, did not restrict the destination, and attached the user's token to the backend request. It also lacked CSRF protection, so a third-party page could cause the request to happen.
The design flaw, as the analysis puts it, is that the client chose the destination while the server chose the credential. "Client" here means the browser side, the code running on the user's machine, which the attacker can influence. "Server" means Google's backend, which holds the secret. Those two decisions need to live together on the server. A correct OAuth handshake says nothing about how tokens are used afterwards.
A comparison: a bank teller who checks your identity perfectly at the door, then later hands your account balance to anyone who names a branch office, has done the hard part right and the easy part wrong. The security of the first step does not carry over to the second.
Impact
A forwarded source-control token can reach whatever its scopes allow. A scope is the list of permissions attached to a token, the way a hotel key card might open your room but not the pool. If the token was allowed to read private repositories, it could reach them: potentially private repositories, secrets in code, and CI configuration.
CI stands for Continuous Integration, an automated system that builds and tests code whenever it changes. Its configuration files often contain credentials for other systems, which makes them a valuable target. Secrets in code means passwords, API keys and similar values that developers have accidentally left in their files.
Because a victim only needed to be signed in with a linked account, the issue scaled to any user of the feature. CVSS is a standard scoring system for how serious a vulnerability is. A CVE is a public catalogue number assigned to a known vulnerability.
Fix
Google fixed the issue in 2019, and the researcher noted he could not bypass the fix. The defensive guidance below is the author's own analysis, not part of the disclosure.
- Accept identifiers, not URLs. The browser sends a provider name and project ID; the server builds the URL from a fixed base. An identifier is just a name or number, like a project ID, rather than a full address. If the server builds the address itself from a fixed starting point, the browser cannot point it anywhere else.
- 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. Parsing means breaking the URL into its parts properly instead of pattern-matching text. HTTPS is the encrypted version of the web's protocol. An allowlist is a list of things that are permitted, with everything else refused. The host is the domain name part of a URL. Userinfo is the optional
username:password@part before the host, which can be used to disguise the real destination. A port is the numbered channel on a server. An IP literal is a raw numeric address instead of a name. - 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. A redirect is a server telling the client "the thing you want is over there instead". Headers are the extra labelled lines sent with a web request, and the Authorization header is where a token usually travels. If a client follows a redirect and resends the header, the token goes to the new place too.
- 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 do not infer one from the other. Keep a reviewed per-provider list of hosts each token may be sent to. An API is a defined set of addresses a service offers so programs can talk to it, like a restaurant menu of what you can order. The login website and the API can live on different domains, so assuming one from the other is unsafe.
- Protect credentialed actions from cross-site triggering. Require a CSRF token or a custom header checked server-side, and use SameSite cookies. A cookie is a small piece of data a website stores in your browser so it can recognise you on the next request. SameSite is a cookie setting that stops the browser sending it along with requests started by other websites.
- 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. Blast radius means how much damage one leaked credential can do. An egress proxy is a checkpoint that all outgoing traffic must pass through, so it can be filtered and recorded.
- Rotate on discovery. If a credential may have been sent anywhere unexpected, treat it as compromised. Rotating means replacing the credential with a new one and cancelling the old, the way you change a lock if a key goes missing.
Developer pseudocode for the safe pattern, as given in the write-up. Pseudocode is code written to show the idea rather than to run as-is.
API_HOSTS = {
"gitlab": "gitlab-api.example.test",
"github": "github-api.example.test",
}
Line by line:
API_HOSTS = {starts a dictionary, which is a lookup table of key and value pairs, and gives it the nameAPI_HOSTS."gitlab": "gitlab-api.example.test",maps the provider namegitlabto the one host the server is allowed to contact for GitLab."github": "github-api.example.test",does the same for GitHub.}closes the table.
The point of this table is that the browser never supplies a host. It supplies a provider name, and the server looks up the only host that name is allowed to mean. If the name is not in the table, there is no answer, and the request is refused.
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)
Line by line:
def fetch_branches(user, provider, project_id):defines a function, a named block of code, that takes three inputs: who the user is, which provider they linked, and which project they want branches for.host = API_HOSTS[provider]looks up the allowed host for that provider in the table above. The comment# KeyError -> rejectnotes that if the provider is not in the table, the lookup fails and the request is refused. That is the allowlist doing its job.url = f"https://{host}/projects/{quote(project_id, safe='')}/branches"builds the address on the server from the fixed host and the project ID.quoteencodes the project ID so that special characters in it cannot break out of the address and change where it points.parsed = urlsplit(url)breaks the finished address into its parts so they can be checked.if parsed.scheme != "https" or parsed.hostname != host:checks that the address really uses HTTPS and that its host is exactly the one from the table. This is validating the final destination rather than trusting the input.raise Rejected()stops everything if either check fails.token = vault.token_for(user, provider)fetches the user's stored token from a vault, a protected store for secrets.return http.get(url,makes the outgoing request to the address the server built.headers={"Authorization": f"Bearer {token}"},attaches the token in the standard Authorization header, using the Bearer scheme, which is the usual way to present a token.allow_redirects=False, # never forward creds on redirecttells the HTTP client not to follow redirects, so the token cannot be resent to a new host.timeout=5)gives up after five seconds, so a slow or hostile destination cannot hold the request open.
Variants to test
These are patterns to look for when reviewing similar integrations. The report gives them as things to test, not as confirmed findings.
- Client-supplied upstream URL on any integration helper. Look for endpoints that proxy to a third-party API on behalf of a linked account. A positive result is a request where you control the destination and the response or an out-of-band callback shows the server's request arriving with the user's credential attached. An out-of-band callback is a signal sent to a server you control, which proves the request really left the target.
- Credentialed endpoints without CSRF protection. Try triggering the helper from a third-party page while signed in. A positive result is the backend request firing without a CSRF token or custom header, with the token still attached.
- Redirect handling on credentialed calls. Point the helper at a URL that redirects to a host you control. A positive result is the client following the redirect and resending the Authorization header to the new host.
- Host allowlist bypasses. If a fix restricts the destination, try userinfo, unusual ports, IP literals and lookalike hostnames. A positive result is the request reaching a host outside the intended allowlist.
- Scope review of linked tokens. Check what the forwarded token can actually do. A positive result is a token whose scopes reach private repositories, secrets in code or CI configuration.
Key takeaways
- In SSRF review, check what the server adds to a request, not only where it can reach.
- The server, never the client, should pair destinations with credentials.
Glossary
- API: a defined set of addresses and rules a service offers so other programs can talk to it.
- API host: the domain name of the server that provides an API.
- Allowlist: a list of permitted values, with everything not on the list refused.
- Authorization header: the labelled line in a web request where a token is usually presented.
- Backend: the part of a service that runs on the company's servers, as opposed to the browser.
- Bearer token: a token presented in the Authorization header, where simply holding it grants access.
- Bitbucket, GitLab, GitHub: websites that host source code and its history.
- Blast radius: how much damage a single leaked credential or bug can cause.
- Branch: a parallel copy of a project's files used to work on a change separately.
- Browser: the program on your computer, such as Chrome or Firefox, that displays websites.
- CI (Continuous Integration): an automated system that builds and tests code whenever it changes.
- CI configuration: the files that tell the CI system what to do, often containing credentials.
- Client: the side of a connection running on the user's machine, usually the browser.
- Cookie: a small piece of data a website stores in your browser so it can recognise you later.
- Credential: any secret that proves identity or grants access, such as a token or password.
- Cross-site: started from a different website than the one being targeted.
- CSRF (Cross-Site Request Forgery): tricking a signed-in user's browser into sending a request the site treats as the user's own.
- CSRF token: a secret value a page must include so the server can tell a genuine request from a forged one.
- CVE: a public catalogue number assigned to a known vulnerability.
- CVSS: a standard scoring system for how serious a vulnerability is.
- Debugger: a tool for inspecting and troubleshooting a running program.
- Domain: the name part of a web address, such as
example.test. - Egress proxy: a checkpoint all outgoing traffic must pass through, so it can be filtered and logged.
- Endpoint: a specific address on a server that performs one job when called.
- Function: a named block of code that takes inputs and produces a result.
- Header: an extra labelled line sent with a web request or response.
- Host: the server named in a URL, usually a domain name.
- HTTPS: the encrypted version of the web's protocol.
- HTTP method: the verb of a web request, such as GET or POST.
- Identifier: a name or number that identifies something, rather than a full address.
- IP literal: a raw numeric server address used instead of a domain name.
- OAuth: a standard way for one site to get limited permission to act on another on your behalf, without your password.
- OAuth handshake: the step where two services agree to trust each other and a token is issued.
- Out-of-band callback: a signal sent to a server you control, proving a request really left the target.
- Parameter: a named value attached to a request, like a form field.
- Payload: the actual data sent to make a bug happen.
- Port: the numbered channel on a server that a connection uses.
- Pseudocode: code written to show an idea rather than to run as-is.
- Redirect: a server telling the client the thing it wants is at a different address.
- Repository (repo): one project's folder of files plus its full history.
- Rotate: replace a credential with a new one and cancel the old.
- SameSite: a cookie setting that stops the browser sending it with requests started by other sites.
- Scope: the list of permissions attached to a token.
- Secret: a password, key or similar value that must stay private.
- Server: a computer that provides a service over the network.
- Source control: a system that stores every version of a project's files and records who changed what.
- SSRF (Server-Side Request Forgery): tricking a server into making a web request to an address of the attacker's choosing.
- Stackdriver Debugger: the Google Cloud Platform service at the centre of this case.
- Timeout: a limit on how long a request may take before it is abandoned.
- Token: a long random string that grants access to whatever it is scoped for, like a temporary key.
- Upstream: the other service being contacted on the user's behalf.
- URL: the address of a page or resource on the web.
- Userinfo: the optional
username:password@part of a URL, which can disguise the real destination. - Vault: a protected store for secrets.
- VRP (Vulnerability Reward Program): a scheme that pays people for reporting security bugs responsibly.