OAuth Account Hijacking via redirect_uri
The OAuth service did not validate the redirect_uri parameter, allowing an attacker to redirect the authorization code to an arbitrary site. An attacker could steal a victim's authorization code and use it to log in as that user, including an admin.
osintteam.blog
Published on osintteam.blog
Today, we’ll be walking through my step-by-step methodology as I approach an Oauth vulnerability. This is part of my Methodology Walkthrough series at the Cybersec Cafe.
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 client failed to validate the redirect_uri parameter against an allowlist, accepting any URL.
What the attacker needed
Victim clicks a link or views a page; attacker has an exploit server; OAuth login enabled
How it was found
- Log in to the application using the OAuth social media login.
- Capture the OAuth callback request containing the authorization code and redirect_uri.
- Change the redirect_uri to an arbitrary URL and observe that the server still redirects.
- Craft an iframe that requests the OAuth authorization endpoint with the redirect_uri pointing to the exploit server.
- Deliver the exploit to the victim and check the exploit server's access log for the victim's authorization code.
- Log out and visit the OAuth callback URL with the stolen code to access the admin panel.
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.
OAuth is a way for websites to let you log in using another service, like Google. When you log in, the service sends a special code back to the website. If the website doesn't check where that code is sent, an attacker can trick it into sending the code to their own site, letting them log in as you.
What is OAuth / SSO?
Mistakes in OAuth, OpenID Connect, SAML or token handling that leak codes and tokens or link an attacker's identity to a victim's account.