Skip to content
XSS Write-up Advanced

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…

Asem Eleraky, on medium.com

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

  1. Log in to the application and observe the redirectUrl parameter used after authentication.
  2. Test with a javascript: scheme calling print() and note the WAF blocks it.
  3. Try assigning print to a variable and invoking it indirectly, still blocked.
  4. Use a callback like [1].some(print) combined with variable assignment to bypass WAF.
  5. Analyze the za() function and discover it calls itself recursively, requiring multiple javascript: schemes.
  6. 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.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.