OAuth and PostMessage - Chaining misconfigurations for your access token.
The identity provider's redirect_uri parameter accepted path traversal sequences, letting the callback path be manipulated, and a page on another subdomain posted its URL fragment to any parent origin without framing protection. Chaining these let an attacker steal a logged-in victim's access token and take over their account if the victim visited a malicious page.
It had been a while since I last wrote about a finding. In this writeup, I want to share a vulnerability where I chained an OAuth misconfiguration—yes, they still exist—with a postMessage misconfiguration.
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 failed to normalise or reject traversal sequences in the redirect_uri callback path, and a separate page used postMessage with a wildcard target origin while lacking framing protection.
Impact
An attacker could steal a logged-in victim's access token and take over their account, though the severity was lowered because the postMessage issue sat on an out-of-scope subdomain.
What the attacker needed
Victim is logged in to the main app; victim clicks a malicious link; attacker hosts a page with an iframe
The fix
The issue was fixed by removing the page with the unsafe postMessage code and blocking traversal sequences in the redirect_uri parameter.
How it was found
- Craft a malicious page that embeds the vulnerable learning-centre page in an iframe, pointing it at the OAuth authorisation endpoint.
- The victim, already logged in, is redirected by the authorisation server to a callback path containing a traversal sequence, with the access token in the URL fragment.
- The normalised path starts a second OAuth flow for the other subdomain, keeping the token in the fragment.
- The second client's callback redirects to the attacker-controlled state value, landing on the page with the unsafe postMessage code.
- That page reads the fragment and posts it to the parent, which is the attacker's page.
- The attacker uses the stolen token to take over the victim's account.
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 with a service like Google, the site sends you to a login server and back with a token that proves who you are. Here, the login server could be tricked into sending the browser to a slightly different path than intended, and a separate page on the same company's site would happily shout that token to whatever page had embedded it. An attacker who gets a victim to open a link can therefore end up with the victim's login token.
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.