Triple Trouble: Bypassing Sanitization to Steal Microsoft Tokens
A DOM-based XSS vulnerability existed in a Microsoft subdomain's redirectUrl parameter, allowing an attacker to execute JavaScript and steal access tokens from localStorage. The WAF was bypassed using a triple javascript: scheme and callback-based function invocation.
medium.com
Published on medium.com
In this write-up, I’ll walk you through how I uncovered a DOM-based cross-site scripting (XSS) vulnerability in one of Microsoft's subdomains by analyzing JavaScript, which led to the discovery of an unconventional payload format. I’ll also break down how I bypassed the Web Application Firewall (WAF) to craft a…
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 za() function recursively processed the redirectUrl and used the URL constructor in a way that allowed a javascript: scheme to survive multiple validation rounds.
Impact
An attacker could steal user access tokens from localStorage, potentially leading to account takeover.
What the attacker needed
Victim clicks a crafted link; victim is logged in
The fix
The vulnerability was fixed by adding checks to the za() function to block javascript: schemes, though a bypass was later found and fixed again.
How it was found
- Log in to the application and observe the redirectUrl parameter used after authentication.
- Test with a javascript: scheme calling print() and note the WAF blocks it.
- Try assigning print to a variable and invoking it indirectly, still blocked.
- Use a callback like [1].some(print) combined with variable assignment to bypass WAF.
- Analyze the za() function and discover it calls itself recursively, requiring multiple javascript: schemes.
- Craft a payload with three javascript: schemes (or labels) to survive both calls and execute.
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.
Cross-site scripting (XSS) lets an attacker run their own JavaScript in a victim's browser on a trusted site. Here, the site took a URL parameter and used it to redirect the user without properly checking it, so the attacker could make the browser run malicious code. That code then read stored login tokens and sent them to the attacker's server.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.