Insights

Device Code Phishing: How Attackers Steal Microsoft 365 Tokens Without a Password

Illustration of a winged envelope on a hook on gray paper with soap bubbles.
Written by
Lior Liberman
Published on
December 1, 2026

Device code phishing is an attack in which an adversary starts a legitimate OAuth device sign-in and persuades a victim to type the attacker’s one-time code into a real identity provider page. The attacker then receives the victim’s access and refresh tokens without ever needing the password. The victim approves the request themselves, so the tokens the attacker collects are legitimately issued, and some of them can survive a user’s password change unless an administrator revokes sessions.

The technique has moved from espionage into commodity crime. Microsoft’s 2026 Digital Defense Report calls it a preferred credential theft method for both nation-state and financially motivated actors. The EvilTokens phishing-as-a-service platform, which appeared in February 2026, helped compromise more than 12,000 inboxes in over 10,000 organizations.

TL;DR:

  • Device code phishing abuses a legitimate OAuth flow, so the victim signs in on a genuine Microsoft page.
  • MFA does not stop it, because the victim completes the sign-in, including any MFA prompt, for the attacker.
  • A password change alone may not end a stolen session; responders need to revoke sessions and remove anything the attacker added.
  • Blocking device code flow with Conditional Access, with narrow exceptions, is the main control.

How the OAuth 2.0 Device Authorization Grant Works

The device authorization grant lets a device with no keyboard or browser, such as a smart TV or a command-line tool, get a user’s tokens by having the user approve the sign-in on a second device. RFC 8628, first published in August 2019, defines the exchange.

The client asks the authorization server for codes and receives a device_code (kept by the client), a user_code (shown to the user), a verification_uri, an expires_in lifetime, and an optional polling interval that defaults to five seconds. The client then polls the token endpoint with grant type urn:ietf:params:oauth:grant-type:device_code. An authorization_pending error means keep waiting, and slow_down means add five seconds to the interval.

In Microsoft Entra ID, the client posts to https://login.microsoftonline.com/{tenant}/oauth2/v2.0/devicecode and polls /oauth2/v2.0/token. The user has 15 minutes to sign in, which is the default expires_in value.

RFC 8628’s security considerations anticipate this abuse: an attacker starts the flow on a device they control and emails the target, asking them to visit the verification URL and enter the code. A short code lifetime limits codes sent by email but can’t stop a phisher who presents a fresh code in real time.

How a Device Code Phishing Attack Unfolds

In Microsoft 365, the attack runs through four stages in order. The victim touches attacker content only in the lure and the landing page that relays the code; the sign-in and token issuance happen on Microsoft’s own endpoints.

The Lure

Storm-2372 built rapport before sending a code. Microsoft observed the actor posing as a prominent person on WhatsApp, Signal, and Microsoft Teams, then emailing a fake Teams meeting invitation whose meeting ID was an actor-generated device code. Commodity kits send broad lures at volume. EvilTokens lures used 44 themes, including invoices, requests for proposals, shared files, and “Action Required: Password Expiration.” Lures often describe the code as a one-time passcode and arrive as a button, hyperlink, or QR code.

Code Generation and the 15-Minute Window

The 15-minute expiry was the attacker’s main constraint, since a code pasted into an email lure expired before a late reader could use it. Later campaigns moved code generation to the landing page. In an April 2026 campaign, a script requested the code from Microsoft’s device authorization endpoint at the moment of the click, so the countdown started when the victim arrived. The same actors had confirmed target addresses through the GetCredentialType endpoint 10 to 15 days earlier.

The Victim Signs In on a Real Microsoft Page

The EvilTokens landing page shows a live code with a Copy Code button and a Continue with Microsoft button that redirects to microsoft.com/devicelogin. The victim enters the code on the genuine page and confirms the request, signing in with a password and MFA if they don’t already have an active session. Because the sign-in page is real, nothing in the URL or branding looks wrong. In a lure built around the Belgrade Security Conference, the only clue Volexity found was a Microsoft Authentication Broker dialog shown after authentication.

Token Capture and Persistence

The attacker’s polling client receives an access token as soon as the victim finishes, plus a refresh token when the request included the offline_access scope, as Storm-2372’s requests did. Storm-2372 then used Microsoft Graph to search mailboxes for terms such as password, admin, credentials, and gov, exfiltrated what it found, and sent new device code lures from the victim’s account to colleagues.

A February 14, 2025 update described an escalation. The actor used the Microsoft Authentication Broker client ID to obtain a refresh token, requested a token for the device registration service, registered an actor-controlled device in Entra ID, and obtained a Primary Refresh Token (PRT). Microsoft also observed the actor routing sign-ins through regionally appropriate proxies.

Why MFA Does Not Stop Device Code Phishing

Authentication finishes on a separate device, so the session that started the request is not strongly bound to the user’s original context. The token goes to whoever polls with the matching device_code, which is the attacker, and it carries the user’s real MFA claim.

CERT-EU warned in April 2026 that device code abuse bypasses MFA and passkeys. Microsoft’s Storm-2372 guidance treats phishing-resistant MFA as one layer, alongside a block on the flow itself, restrictions on device registration, and sign-in risk policies. Token protection accepts only session tokens bound to a registered device for native apps such as Exchange Online, SharePoint Online, and Teams, which makes stolen tokens harder to replay elsewhere. Storm-2372’s device registration shows why limiting who can register devices matters too.

Device Code Phishing vs Credential, AiTM, and Consent Phishing

Attackers seek different artifacts with these four phishing types, so defenders need different controls:

Attack type What is stolen Does MFA help? Primary controls
Credential phishing Password, sometimes a one-time code Any MFA helps; phishing-resistant MFA helps most Phishing-resistant MFA
AiTM phishing Session cookie after real MFA Standard MFA alone may not; phishing-resistant MFA is recommended Phishing-resistant MFA, compliant device requirements
Consent phishing Permissions granted to a malicious app MFA alone does not prevent malicious consent Restricting user consent and reviewing existing grants
Device code phishing Access and refresh tokens, sometimes a PRT MFA alone does not prevent it Conditional Access block on device code flow, with narrow exceptions

From Storm-2372 to Commodity Phishing Kits

Microsoft assessed with moderate confidence that Storm-2372 aligns with Russian interests. The actor has been active since August 2024 against government, NGOs, IT services and technology, defense, telecommunications, health, higher education, and energy organizations in Europe, North America, Africa, and the Middle East. Microsoft’s July 31, 2026 update reclassified Storm-2372 as an initial access sub-cluster of Midnight Blizzard.

Named activity since then splits between targeted espionage and criminal scale:

  • Proofpoint tracks UNK_AcademicFlare, a suspected Russia-aligned actor using compromised government and military accounts to build rapport since September 2025.
  • Proofpoint saw TA2723, a financially motivated actor, start device code phishing in October 2025.
  • Volexity reported a second November 2025 campaign, separate from the Belgrade lure, in which a fake conference registration ended in a device code workflow.
  • Microsoft tied Storm-2945, another Midnight Blizzard sub-cluster, to device code campaigns that led to Entra device registration.
  • EvilTokens abused Cloudflare Workers until Cloudflare and Microsoft’s Digital Crimes Unit disrupted it in September 2026.

CERT-EU counted at least 10 distinct kits in circulation in April 2026, with EvilTokens the most prevalent, and Proofpoint tracks TA4903 running a custom kit that works much like EvilTokens. In August 2026, a “Salary Review” campaign targeted more than 10,000 users at over 4,800 organizations, almost all in the US and mainly professional services firms, especially law firms. A Word attachment carried a QR code that led to a device code page.

How to Detect Device Code Phishing in Entra ID Sign-In Logs

In Entra sign-in logs, AuthenticationProtocol set to deviceCode marks sign-ins that used device code flow. Later requests in the same session can show a different protocol, so check OriginalTransferMethod too, which records that device code flow started the session. Search both SigninLogs and AADNonInteractiveUserSignInLogs. Watch what follows the device code sign-in, especially sign-in anomalies such as non-interactive sign-ins from a new IP address, client, or user agent shortly afterward.

The query below is a hunting lead. It pairs successful device code sign-ins with successful sign-ins by the same user within the next day from IP addresses that user had not used in the previous 30 days. It matches on user alone, so confirm hits with OriginalTransferMethod before escalating:

let SignIns = union SigninLogs, AADNonInteractiveUserSignInLogs
    | where ResultType == "0";
let baseline = SignIns
    | where TimeGenerated between (ago(32d) .. ago(2d))
    | where AuthenticationProtocol != "deviceCode"
    | summarize KnownIPs = make_set(IPAddress) by UserPrincipalName;
SignIns
| where TimeGenerated > ago(2d)
| where AuthenticationProtocol == "deviceCode"
| project DeviceCodeTime = TimeGenerated, UserPrincipalName,
    DeviceCodeIP = IPAddress, DeviceCodeLocation = Location, DeviceCodeApp = AppDisplayName
| join kind=inner (
    SignIns
    | where TimeGenerated > ago(2d)
    | project FollowTime = TimeGenerated, UserPrincipalName, FollowIP = IPAddress,
        FollowApp = AppDisplayName, FollowUA = UserAgent
    ) on UserPrincipalName
| where FollowTime > DeviceCodeTime and FollowTime <= DeviceCodeTime + 1d
| join kind=leftouter baseline on UserPrincipalName
| extend KnownIPs = iff(isnull(KnownIPs), dynamic([]), KnownIPs)
| where not(set_has_element(KnownIPs, FollowIP))
| summarize FirstSeen = min(FollowTime), NewIPs = make_set(FollowIP),
    Apps = make_set(FollowApp), UserAgents = make_set(FollowUA)
    by UserPrincipalName, DeviceCodeTime, DeviceCodeIP, DeviceCodeLocation, DeviceCodeApp

Tune it to your baseline. It needs at least 32 days of retention in both tables, and users with no sign-in history in the window will return every IP as new.

If only Teams device resource accounts use device code flow, escalate any deviceCode sign-in by a person. If developers use it for Azure CLI, hunt for device code sign-ins followed by Graph or Exchange access from an unfamiliar IP. Escalate immediately when an Entra device registration follows within minutes, or when New-InboxRule or Set-InboxRule appears in the unified audit log for the same user. Microsoft treats unusual token or PRT activity around a fresh device registration as a Storm-2372 indicator.

Defender XDR customers can also adapt Microsoft’s April 2026 advanced hunting queries, which look for error code 50199 followed by a successful sign-in. Error 50199 is the confirmation prompt a victim sees after entering the code.

How to Block or Restrict Device Code Flow

Since early 2025, Microsoft has moved toward blocking device code flow by default. Its managed policy named “Block device code flow” appears in eligible tenants in report-only mode, and Microsoft normally switches it on no less than 30 days later unless an administrator opts out. Administrators get two weeks’ notice before enforcement. Microsoft’s reasoning is that customers rarely use the flow and attackers use it often.

Starting July 1, 2026, security defaults block device code flow in all new tenants. In an older tenant, check whether the managed policy is actually on. A custom Conditional Access policy lets you block the flow with your own exceptions and requires Entra ID P1. The steps below run in order.

Find Out Who Uses Device Code Flow Today

Before blocking, list who depends on the flow by summarizing 30 days of deviceCode sign-ins by user and AppId. Record the user, app, location, device context, and business owner for each dependency you find.

Create an Authentication Flows Policy

Create a policy targeting all users and resources, set Conditions > Authentication flows to Device code flow, and grant Block. Run it in report-only mode first, review the results, then switch it on. Apply the usual Conditional Access exclusion for emergency access accounts. Once the policy is on, error AADSTS530036 on sessions that started with device code flow is expected.

Scope Exceptions for Legitimate Devices

Exceptions should be narrow and documented. If Teams Rooms or Teams Android devices need the flow, place their resource accounts in a persistent exclusion group and exclude the Device Registration Service resource. The account exclusion covers more than Teams: an excluded account can use device code flow for any app the policy covers, so keep that group small and monitored. If Android conference room devices are the only users, block the flow everywhere except Android devices in a specific network location.

If CLI tools depend on it, move them to browser-based login or managed identities. If migration is not possible, limit the exception to a named group of developer accounts and, where feasible, a trusted network location. Treat any remaining non-Teams exception as a documented risk acceptance with an owner and review cadence.

Teach Users to Reject Codes They Did Not Request

Build one rule into awareness training: never enter a sign-in code you did not start on your own device. A meeting invite, document share, or verification code request that asks you to visit a device login page comes from someone else’s device.

What to Do After Someone Enters a Device Code

Contain first, then clean up, in the order Microsoft recommends for token theft:

  1. Temporarily disable the account and revoke sessions with Revoke-MgUserSignInSession, which invalidates refresh tokens. Disabling the account blocks new sign-ins and token refreshes while you clean up. Access tokens already issued last until they expire, typically 60 to 90 minutes, unless the resource enforces Continuous Access Evaluation.
  2. Reset the password, twice for hybrid accounts.
  3. Delete devices enrolled by the compromised account and delete MFA methods the attacker added.
  4. Delete added or changed inbox rules, using Get-InboxRule -Mailbox <user> -IncludeHidden to find hidden ones and Remove-InboxRule to remove them. Check forwarding settings and app consent grants. Review the victim’s sent mail for fresh device code lures sent to coworkers, since Storm-2372 used compromised accounts this way.
  5. Search the unified audit log for MailItemsAccessed and SharePoint FileAccessed events across the compromise window.
  6. Re-enable the user only after attacker-added devices and MFA methods are gone and the user has re-registered their own.

The audit-log results define which mailboxes, files, and colleagues need follow-up.

Why a Password Change Is Not Enough

When users change their own password, Entra revokes password-based refresh tokens but can leave non-password-based ones alive. Device code phishing is one of several routes to a stolen session, and infostealers take one straight from the victim’s browser. After a device code phish, your team should be able to name every session, device, and mailbox rule the attacker touched. Daylight’s MDR investigates and responds to what happens after a phish lands.

Frequently Asked Questions About Device Code Phishing

How Is Device Code Phishing Different From MFA Fatigue?

MFA fatigue usually starts with a stolen password: the attacker signs in and floods the user with push prompts until one gets approved. Device code phishing needs no password. The victim starts the sign-in by typing the attacker’s code, so any MFA prompt that appears looks expected, and number matching offers little protection because the user is answering a sign-in they began themselves.

Does Device Code Phishing Affect Google and Other Identity Providers?

Google, Okta, and AWS IAM Identity Center all support the device grant, with limits. Google restricts it to a small set of scopes, and Okta requires administrators to enable the grant on the app (and in an access-policy rule on custom authorization servers). The AWS CLI has defaulted to PKCE, a browser-based authorization code flow, since version 2.22.0. Proofpoint has seen Google-themed device code campaigns at much lower volumes, and published campaign reporting centers on Microsoft 365.

How Long Do Stolen Refresh Tokens Stay Valid?

Entra refresh tokens default to 90 days for most clients and 24 hours for single-page apps, and each use extends them until they are revoked or a policy cuts them short. Continuous Access Evaluation sessions can carry access tokens that last up to 28 hours, though revocation reaches them in near real time.

Does Azure CLI Need Device Code Flow?

Rarely. Azure CLI uses Web Account Manager on Windows and browser login on Linux and macOS by default. It falls back to device code when it can’t open a browser or when you ask for it with --use-device-code. For automation, Microsoft recommends a managed identity or a service principal.

Can Personal Microsoft Accounts Be Targeted?

Yes. Personal Microsoft accounts can complete device code flow through the /consumers endpoint. Conditional Access is a tenant control: your tenant’s policies govern sign-ins to your tenant’s resources, including Microsoft account guests, and Microsoft does not document an equivalent policy for personal accounts signing in to consumer services.

Subscribe to newsletter

Subscribe to receive the latest blog posts to your inbox every week.

Thanks for your interest.
Oops! Something went wrong while submitting the form.
By subscribing you agree to our Privacy Policy.
Two pinkish translucent bubbles of different sizes on a black background.Two pinkish translucent bubbles of different sizes on a black background.Two pinkish translucent bubbles of different sizes on a black background.
Illustration of a mythical hippocampus creature with the upper body of a horse and the lower body of a fish with scales and a curled tail.Illustration of coral colony with tube-shaped and frilled coral structures in shades of pink and red on a transparent background.

For expert judgment, scaled to your world, head for Daylight