Skip to content
OAuth / SSO Write-up Intermediate

OAuth2 and the implicit grant flow

The Microsoft Teams Web Client service principal in Azure AD had an insecure reply URL pointing to an HTTP address on [redacted], allowing an attacker who controls that domain (e.g. via a rogue Wi-Fi network) to receive OAuth access tokens. An attacker could then use the token to read emails, send emails, and access OneDrive and SharePoint files as the victim.

dirkjanm.io

Published on dirkjanm.io

One of the main powers of Office 365 is the tight integration between all the online applications. At the same time this is a risk since those applications have access to other elements such as emails in Outlook or files on SharePoint/Onedrive.

The author, on dirkjanm.io

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 a misconfigured OAuth reply URL in the Microsoft Teams Web Client service principal that allowed an HTTP redirect to [redacted], which an attacker could control.

Impact

An attacker could read all the victim's emails, send emails as the victim, and access their OneDrive and SharePoint files; the token expires after one hour by default, and the attack is not logged in Azure AD sign-in logs.

What the attacker needed

Victim connects to attacker-controlled network; victim signed in or SSO enabled; attacker controls [redacted] resolution

The fix

The insecure reply URLs were removed from the service principal, first for new tenants and later for existing tenants, and Azure AD now returns an error when the vulnerable URL is used.

How it was found

  1. Set up a rogue Wi-Fi network that redirects the victim to a site of the attacker's choosing.
  2. Redirect the victim to the Microsoft sign-in page using the Teams application ID and the [redacted] reply URL.
  3. After the victim signs in (or via SSO), the login page redirects to [redacted] with the access token in the URL fragment.
  4. Serve JavaScript from the attacker-controlled [redacted] page to capture the token and send it to the attacker.
  5. Use the stolen token to access the victim's emails, OneDrive, and SharePoint files.

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 sign in to an app like Microsoft Teams, the login service sends a special pass (an access token) back to the app's website. The app must tell the login service in advance which website addresses are allowed to receive that pass. Here, one allowed address was an insecure HTTP site on a domain the attacker could control, so the attacker could receive the pass and use it to read the victim's email and files.

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.

Similar reports

View all

Same bug class and techniques, clearest first.

OAuth and single sign-on flaws

The lesson behind this report.

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.