Device code phishing
The victim enters a code on Microsoft's own login page and approves a real prompt. The attacker requested that code from a second device and walks away with access and refresh tokens.
How it works
OAuth's device code flow, the device authorization grant in RFC 8628, exists for input-constrained hardware: a smart TV, a console, or a command-line tool that cannot easily host a browser login. The protocol has three steps.
- The device sends its client ID to the authorization server's device authorization endpoint and receives a
device_code, a short human-readableuser_code, averification_uri, an expiry and a polling interval. - The device shows the user code and URL. The user opens that URL on a phone or laptop, signs in with their normal credentials and MFA, and types the code.
- Meanwhile the device polls the token endpoint with
grant_type=urn:ietf:params:oauth:grant-type:device_code. It getsauthorization_pendinguntil the user finishes, then receives an access token and usually a refresh token.
The design deliberately separates the device requesting access from the device approving it. An attacker starts the flow themselves, from their own machine, using the client ID of a legitimate public client such as Microsoft Office or the Microsoft Authentication Broker. They get a real code from the real identity provider and send it to the victim in a lure: a Teams or Signal meeting invite, a document share, a "secure chat" request. The victim opens the genuine sign-in page (for Microsoft, microsoft.com/devicelogin), enters the code, and signs in with their own credentials and their own MFA, including a passkey if they have one. Nothing about the page is fake. When the victim approves, the identity provider issues tokens to the polling session the attacker started.
Codes are short-lived. Volexity notes Microsoft device codes are valid for 15 minutes, which is why targeted campaigns pair the code with real-time messaging so the victim acts quickly. Commodity kits such as Kali365 and the more than 25 others Push Security tracks automate the rest. What the attacker does next depends on the client ID they chose. Microsoft reported in February 2025 that Storm-2372 switched to the Microsoft Authentication Broker client ID so its refresh token could request a token for the device registration service, register an attacker-controlled device in Microsoft Entra ID, and obtain a Primary Refresh Token.
The same flow exists outside Microsoft. Christophe Tafani-Dereeper showed in 2021 that AWS IAM Identity Center's device authorization, used by aws sso login, can be phished the same way, and OpenSourceMalware documented a 2026 phish that completed a GitHub OAuth device flow for repo and workflow scopes.
Why it works
RFC 8628 anticipated this. Its Section 5.4, "Remote Phishing", warns that the flow can be initiated on a device in an attacker's possession and recommends that the authorization server tell the user they are authorizing a device and confirm it is in their possession. That confirmation is a sentence on a screen, and the control assumption that fails is that a user will read it and understand it. A user who was told to "enter this code to join the meeting" has no reason to think about which device is on the other end.
There is no binding between the person approving the code and the device that receives the tokens. The login page, the domain, the TLS certificate and the MFA prompt are all authentic, so the phishing tells that training covers (misspelled domains, fake login forms) do not exist. Phishing-resistant MFA does not help either, because the origin check passes: the victim really is on the identity provider's own page. The fraud is in the grant, not the authentication. The tokens issued are also long-lived. A refresh token obtained this way keeps working after the interaction ends, survives a password reset unless sessions are revoked, and comes from a sign-in that looks like a routine device pairing.
How to detect it
- Entra sign-in logs. Device code sign-ins carry
AuthenticationProtocol=deviceCodeinSigninLogs. Follow-on token requests in the same session carry the original transfer method (OriginalTransferMethod, valuedeviceCodeFlowin Microsoft Graph), so you can trace a device-code session intoAADNonInteractiveUserSignInLogs. Build a baseline of which users,AppIdvalues and locations legitimately use the flow, then alert on everything outside it. - Location mismatch inside one sign-in. The victim authenticates from their usual IP, but the polling client, and every subsequent token redemption, comes from an unrelated
IPAddressorAutonomousSystemNumber, often a hosting provider or a regionally matched proxy. - Persistence after the grant. A "Register device" event in Entra audit logs, or new security info registered, shortly after a device-code sign-in. Huntress found 48 rogue Entra devices named
DESKTOP-plus eight hex characters in its 2026 replay campaign. - Mailbox and Graph activity. Keyword searches and bulk mail access through Microsoft Graph from the new session, and new inbox rules.
- Bursts across users. A cluster of device-code grants across otherwise unrelated users in a short window suggests one lure sent to many targets.
Be honest about the limits: some organizations legitimately use device code flow for meeting-room hardware, shared kiosks, and CLI tools such as the Azure CLI, so a blanket alert on the protocol alone is noisy. Attackers choose common first-party client IDs precisely so the app name looks normal. The useful signal is the combination of an unexpected user or location with follow-on activity, not the grant type in isolation, and by the time that combination appears the tokens have already been issued.
How to stop it
- Block the device code flow with a Conditional Access authentication flows policy. Microsoft describes device code flow as a high-risk authentication method and recommends blocking it wherever possible. Most organizations have no devices that need it.
- Scope it tightly where it must stay. Allow it only for named users, specific apps, or managed devices in specific network locations, and review the exception list.
- Revoke and clean up after any suspected grant. Revoke sessions and refresh tokens with
revokeSignInSessions, then separately delete unrecognized devices and MFA methods, since neither is removed by a password reset. - Require step-up for device registration and MFA changes, so a phished refresh token cannot be converted into a registered device and a Primary Refresh Token.
- Bind tokens to devices with Entra Token Protection where supported, so tokens issued to an unregistered attacker machine are refused by protected resources.
- Teach the specific lure. No legitimate meeting or document requires typing a code into microsoft.com/devicelogin. Phishing-resistant MFA is still worth deploying because it closes the AiTM path attackers pivot to when this flow is blocked, but it does not stop this technique on its own.
Seen in the wild
- Stolen Microsoft 365 session tokens replayed into 79 organizations (2026): Huntress tied the tokens to device-code phishing on Microsoft's real sign-in page and to AiTM relays, followed by rogue device registration and MFA method swaps. See our coverage.
- Microsoft: Storm-2372 conducts device code phishing campaign (February 2025): active since August 2024 against government, NGOs, IT, defense and other sectors, with lures resembling WhatsApp, Signal and Teams.
- Volexity: multiple Russian threat actors targeting Microsoft device code authentication (February 2025): campaigns from mid-January 2025, including one attributed to CozyLarch, which overlaps with APT29.
- Kali365 phishes Microsoft's own device login page for durable Microsoft 365 tokens and device code phishing industrialises: 25 kits
- Three Russian clusters move from password phishing to OAuth token theft
- GhostAction phish completes a GitHub device flow, then hides a stealer in a font file
Device-code phishing fits the Identity Breach Report 2026 definition of a talk-past attack: the victim approves access, so authentication is satisfied rather than broken. The report's talk-past share of human-account breaches rose to 38.2% in 2025-2026, from 23.3% in 2023-2024, and its tenth control, governing OAuth apps and user consent, points to this technique.
Sources
- MITRE ATT&CK T1528: Steal Application Access Token
- MITRE ATT&CK T1566.002: Phishing: Spearphishing Link
- RFC 8628: OAuth 2.0 Device Authorization Grant, Section 5.4 Remote Phishing
- Microsoft Entra: Conditional Access authentication flows
- Microsoft Graph: signIn resource (authenticationProtocol, originalTransferMethod)
- Azure Monitor: SigninLogs table reference
- Microsoft Security: Storm-2372 conducts device code phishing campaign
- Volexity: Russian threat actors targeting Microsoft device code authentication
- Dr. Nestori Syynimaa: introducing a new phishing technique for compromising Office 365 accounts (October 2020)
- Christophe Tafani-Dereeper: phishing for AWS credentials via AWS SSO device code authentication (2021)
- Huntress: token replay into 79 Microsoft 365 organizations
In the Identity Breach Database
Real incidents in our sourced breach database where this technique was used.
- Stolen Microsoft 365 session tokens replayed into 79 organizations 2026 · Phishing (adversary-in-the-middle)
Related on Start with Identity
- BlogJalisco and OmegaLord: phishing kits built around device-code abuse
ReliaQuest found two Microsoft 365 phishing kits. Jalisco abuses the OAuth device authorization grant, generating fresh codes in real time to beat the 15-minute
- GlossaryMFA Device
An MFA device is the physical thing a user has (a phone running an authenticator app, a hardware security key, a smart card, or an OTP token) that supplies the
- BlogA phishing kit rents an AI voice agent to call theft victims and ask for their 2FA code
SOCRadar documented AnonyMousKIT, a phishing-as-a-service platform built to strip Apple Activation Lock. An AI persona called Alice from Apple Support phones vi
- GlossaryAccount Recovery
The process by which a user regains access after losing their authenticator: a lost device, a forgotten password, or a revoked credential. It is a parallel auth
- GlossaryBiometric Authentication
Biometric authentication confirms a person by comparing a live measurement of a physical characteristic, such as a fingerprint or face, against a template captu
- GuideIdentity Federation Implementation Guide: Protocols, Trust, and Cross-Domain SSO
A step-by-step guide to implementing identity federation covering SAML, OIDC, and WS-Federation protocols, trust relationship configuration, attribute mapping,