BetterSWE DigestWhat is BetterSWE?

Deep Dive · Issue 12

Why OAuth Device-Code Phishing Became 2026's Fastest-Growing Attack, Explained

RFC 8628 assumed the login code always reaches you through a screen you trust. Attackers just email it to you instead, and everything after that is real.

Input-constrained devices each showing a short device code for a phone to approve

The setup

A login built for screens with no keyboard

Input-constrained devices each showing a short device code for a phone to approve

How do you sign a smart TV or a CLI tool into your account when it has no keyboard? RFC 8628, the OAuth 2.0 Device Authorization Grant, answers by moving credential entry to a device you already trust. The screen displays a short code, you type it at a URL on your phone, and the TV gets signed in.

Smart TV (shows WJB-MJHT)Your phone (microsoft.com/devicelogin)ApproveTV signed in

The whole design leans on one quiet assumption: the code reaches you over a trustworthy out-of-band channel, because it is printed on the screen of the very device asking for access. Break that one assumption and the protocol still runs perfectly. It just runs for someone else.

The inversion

The attacker requests the code, not the device

An attacker generating a device code and delivering it to a victim through a phishing lure

The flow uses two codes. The user_code is short and human-friendly, roughly 8 characters formatted like WJB-MJHT, while the long, high-entropy device_code is polled quietly by the client against the token endpoint every ~5 seconds until you approve. You only ever see the short one.

NORMAL
  device asks for code ─► shows WJB-MJHT on its own screen
  you enter it ─► approve ─► device gets the token

PHISHED
  ATTACKER asks for code ─► gets WJB-MJHT
            │  (emailed as a plausible lure)
            ▼
  YOU enter it at the REAL microsoft.com/devicelogin ─► approve
            │
            ▼
  token lands in the ATTACKER's polling client
Same protocol, same real domain. Only the requester changed.

So the attacker starts the flow, receives the code, and mails it inside a fake meeting invite or e-signature notice. You approve at the genuine Microsoft page, and the token drops into the attacker's polling client. RFC 8628 §5.4 literally names "remote phishing" as a known risk, so this was anticipated by the authors, not discovered later.

Persistence

One approval, months of silent access

A vault of stolen tokens including a Primary Refresh Token master key

What the attacker collects is not a password but tokens. The access token grants ~90 minutes of direct API reach into Exchange Online, OneDrive, SharePoint and Teams, and the refresh token is valid for 90 days and self-renews on every exchange. A single successful phish can quietly hold access for months without ever prompting you again.

device-code flow using the
Microsoft Authentication Broker client ID
        │
        ▼
  refresh token ── exchange ──► device-registration token
                                       │
                                       ▼
              enroll attacker device in Entra ID
                                       │
                                       ▼
     Primary Refresh Token (PRT) — SSO across all of M365
              survives a password reset ✗
The escalation path Storm-2372 pivoted to.

It gets worse if the attacker runs the flow with the Microsoft Authentication Broker client ID. That refresh token can be exchanged for a device-registration token, enroll an attacker-controlled device in Entra ID, and yield a Primary Refresh Token, which grants SSO everywhere with no further MFA and survives a password reset. The standard first-response remediation just stops working.

Why MFA folds

The victim really does pass MFA

A victim completing a real MFA push on the genuine Microsoft sign-in page

Here is why the usual defenses miss it: nothing about the sign-in is fake. The victim completes a real authentication ceremony at the real microsoft.com/devicelogin, so the push approval, TOTP, or Windows Hello all succeed normally and Entra ID records a legitimate, MFA-satisfied sign-in. There is no lookalike domain to flag and no cookie to intercept.

Credential phishing

fake domain, stolen cookie, an origin mismatch to catch

Device-code phishing

real domain, real MFA, nothing anomalous to catch

FIDO2 and passkeys only help here through a server-side Conditional Access policy that restricts which methods can complete the device-code ceremony, because there is no origin mismatch when the real domain is used. TOTP, push approval, and SMS OTP give no protection at all, which is why Microsoft's own guidance is to block the device-code flow entirely wherever possible.

The 2026 driver

A six-year-old trick, now a subscription

The EvilTokens phishing-as-a-service console with prebuilt M365 templates

The technique itself is old. It was publicly introduced back in 2020 and had proof-of-concept tooling by 2022. Nothing about the protocol changed in 2026, so the surge is not a new exploit. What changed is packaging.

EvilTokens PhaaS

  • M365 lure templates
  • AI-generated copy
  • Token console
  • 24/7 support

Phishing-as-a-service platforms like EvilTokens, which debuted on Telegram in February 2026, turned the whole attack into a rented product: prebuilt DocuSign and SharePoint lures, AI-written copy, anti-analysis tricks, a management console for harvested tokens, even a support team. By April 4, 2026 detection infrastructure recorded a 37.5x jump in device-code phishing pages, driven by EvilTokens plus at least 11 other distinct kits.

In the wild

340 organizations, three IP addresses

Multi-hop phishing infrastructure ending on a Railway.com cluster with three dominant IPs

One campaign shows the assembly line running at scale. It hit 340+ Microsoft 365 organizations across the US, Canada, Australia, New Zealand and Germany, spanning construction, healthcare, legal, finance and government. The delivery chain is built entirely from trusted infrastructure to slip past filters.

phishing email
  └─ Cisco / Trend Micro / Mimecast URL rewrite   (inherits sender trust)
       └─ Cloudflare Workers + compromised sites   (multi-hop redirect)
            └─ Railway.com PaaS                     (clean IP reputation)
                 3 Railway IPs ≈ 84% of malicious events
Every hop borrows someone else's good reputation.

Links rode inside legitimate Cisco, Trend Micro and Mimecast URL-rewrite systems, bounced through Cloudflare Workers, and landed on Railway.com PaaS whose clean IPs dodged Microsoft's risk scoring, with just three Railway IPs behind roughly 84% of activity. The twist tied to EvilTokens: the landing page renders the device code right on screen, cutting the last manual step out of the attacker's own workflow.

The takeaway

A feature, weaponized at zero cost

Why it matters

Device-code phishing turns a legitimate OAuth convenience into account takeover without a fake domain, a stolen password, or a bypassed MFA prompt, which is exactly why it slips past the defenses most organizations rely on. Commoditized kits made a niche 2020 technique a mainstream threat almost overnight. The practical fix exists (Microsoft ships a Conditional Access policy that blocks the flow), but roughly a quarter of orgs that pay for the licensing never turn it on, and blocking it can break device registration if done carelessly.

The short version

  • RFC 8628 assumes the login code reaches you on a **screen you trust**; phishers break that by requesting the code themselves and mailing it to you.
  • Every step after that is genuine, so there is **no fake domain, no stolen credential, and no MFA to bypass**.
  • Stolen refresh tokens and Primary Refresh Tokens grant **months of access that survive a password reset**.
  • The 2026 surge (a measured **37.5x**) came from phishing-as-a-service kits like EvilTokens, not a new exploit.
  • The real defense is **blocking device-code flow via Conditional Access** and revoking tokens, not just resetting passwords.

Sources

  1. 1.OAuth Device Code Phishing: 37x Surge in Enterprise ATO – Lab Space
  2. 3.OAuth 2.0 Device Authorization Grant
  3. 4.RFC 8628 - OAuth 2.0 Device Authorization Grant
  4. 5.Device Authorization Grant: Solving OAuth for screens without keyboards — WorkOS
  5. 8.Device Code Phishing Hits 340+ Microsoft 365 Orgs Across Five Countries via OAuth Abuse
  6. 9.Storm-2372 conducts device code phishing campaign | Microsoft Security Blog
  7. 10.Defending against evolving identity attack techniques | Microsoft Security Blog
  8. 11.We Need to Talk About Device Code Phishing