Device Code Phishing: How It Steals Microsoft 365 Tokens

Attack coverageUpdated

Device code phishing gets users to enter an attacker's code on the real Microsoft sign-in page, handing over OAuth tokens. How it works and how to stop it.

Device code phishing abuses the OAuth 2.0 device authorization flow: the attacker requests a sign-in code from Microsoft, then persuades the victim to enter it at the genuine microsoft.com/devicelogin page and sign in. The victim completes their own password and MFA, and Microsoft issues access and refresh tokens to the attacker's session instead of theirs.

Nothing about the sign-in page is fake, so lookalike-domain checks and credential-form detection have nothing to grab. The technique has also gone commercial. In May 2026 the FBI warned about Kali365, a phishing-as-a-service platform first seen in April 2026 that lets attackers "obtain Microsoft 365 access tokens and bypass multi-factor authentication," complete with AI-generated lures and campaign dashboards (FBI IC3).

How device code phishing works

  1. The attacker requests a code. They call Microsoft's device authorization endpoint and get back a short user code, the same kind a smart TV or command-line tool shows you.
  2. The lure delivers it. A fake Teams meeting invite, shared document, or "security verification" page shows the code, often with a Copy button and step-by-step instructions.
  3. The victim signs in for real. They open microsoft.com/devicelogin, enter the code, type their password, and approve MFA, all on Microsoft's own domain.
  4. The attacker collects tokens. Their backend polls Microsoft's token endpoint. Once the victim approves, Microsoft hands the access and refresh tokens to the attacker.
  5. They dig in. Microsoft saw attackers use Microsoft Graph to search mail for keywords, exfiltrate the results, and send more device code phishing from the victim's account. By requesting the code as the Microsoft Authentication Broker client, an attacker can go further: register a device in Entra ID and obtain a Primary Refresh Token.

Real-world examples

  • Storm-2372. Microsoft documented a campaign active since August 2024 against government, NGOs, IT services, defense, telecommunications, health, higher education, and energy organizations across Europe, North America, Africa, and the Middle East. The lures were fake Teams meeting invitations, and the group later shifted to the Authentication Broker client ID to register devices.
  • Kali365. Beyond the FBI alert, our analysis found Kali365 is 71% similar to the Sneaky2FA AiTM kit in page code and HTML structure, so the device-code payload ships on an inherited anti-analysis front end.
  • Signs Australia. We analyzed a campaign that staged an AES-256-GCM encrypted HTML file on a compromised SharePoint tenant. Opened locally, it decrypted itself into a fake Adobe verification page, requested an Authentication Broker device code, and polled compromised third-party sites every five seconds for the victim's tokens.

Warning signs and detection signals

  • Any message asking someone to enter a code at microsoft.com/devicelogin that they did not start from a TV, CLI, or device in front of them.
  • A web page or local HTML file that shows a code, copies it to the clipboard, and opens a popup to the device login page.
  • Entra sign-in logs showing the device code flow for users who never use it.
  • Microsoft Authentication Broker sign-ins from an unusual or unmanaged device, especially followed by a device registration or PRT issuance.
  • Sign-in location that does not match where the user's endpoint is.
  • A page polling an unfamiliar backend every few seconds while the user is on the Microsoft sign-in page.

How Surface stops it

Surface watches the part of the attack identity logs never see: the page that walked the user to the device login.

  • Flow policy. An allow or block policy for the OAuth device-code flow in the browser, so users who have no business using it never reach it.
  • Lure detection. Alerts when a device-code page is reached from an external link, the shape the lures above have in common.
  • Callback checks. Detection of callbacks to localhost or raw IP addresses.
  • Kit signatures. Surface Vision includes an OAuth impersonation category and runs locally in the browser, on the page the user actually sees.

That last point matters for loaders. In the Signs Australia case the phishing page did not exist until it decrypted inside the browser, and Surface blocked it at that point with the reason "Device code page opened from another tab/window." For more, see phishing and social engineering defense.

Pair this with the identity-side control. Microsoft recommends organizations "get as close as possible to a unilateral block on device code flow" using a Conditional Access authentication flows policy, and the FBI gives the same advice.

If it already happened

  1. Revoke sessions and refresh tokens for the user (revokeSignInSessions in Microsoft Graph, or Revoke-MgUserSignInSession in PowerShell).
  2. Hunt for devices registered to the user during the window and remove them, since a registered device can be used to obtain a Primary Refresh Token.
  3. Review mailbox activity, inbox rules, and OAuth grants, and check whether phishing was sent from the account to colleagues or partners.
  4. Block the device code flow with Conditional Access. Start in report-only mode to find legitimate use, and exclude break-glass accounts.
  5. Report it. US organizations can file with the FBI's IC3, which asks for the phishing emails, sign-in details, and any unauthorized devices or sessions.

Related techniques: consent phishing and HTML smuggling.