Cobalt Pentest Case Study: OAuth Redirect to Account Takeover
An unvalidated open redirect in the OAuth server's ReturnUrl parameter allowed an attacker to redirect a victim to a malicious site, where JavaScript could extract the id_token from the URL fragment and send it to the attacker. The attacker could then use the stolen token to sign in as the victim and change their password, leading to account takeover.
cobalt.io
Published on cobalt.io
Hi friends! In this blog, I’m going to tell you how in a Cobalt pentest, I found an unvalidated and open redirect vulnerability in the OAuth server, which I managed to escalate to Account takeover through a little trick to get the user's access token.
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 OAuth server did not validate the ReturnUrl parameter against a list of allowed redirect URIs, allowing redirection to arbitrary external sites.
Impact
An attacker could steal the victim's id_token and other tokens, leading to complete account takeover, including changing the victim's password.
What the attacker needed
Victim is authenticated; victim clicks a link
The fix
The OAuth server should validate redirect URLs against a pre-registered allowlist to prevent redirection to arbitrary locations.
How it was found
- An authenticated victim visits a crafted login URL with a ReturnUrl pointing to the attacker's server.
- The victim is redirected to the attacker's page, which runs JavaScript to read the id_token from the URL fragment and send it to the attacker.
- The attacker uses the stolen id_token to sign in as the victim and change the password.
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.
When you log in using another service (like 'Sign in with Google'), the service sends you back to the original site with a special code in the web address. This report shows that the site did not check where it was sending you back to, so an attacker could make it send you to their own site instead. The attacker's site could then read the secret code from the web address and use it to log in as you.
What is Open redirect?
A trusted site forwards users to any address an attacker picks; rarely paid alone, often the missing link in a chain.