Device Code Phishing: What It Is and How to Block It
The victim signs in on the real Microsoft page and passes real MFA, and the attacker walks away with the tokens. A check, block and respond runbook for small IT teams and MSPs.
- Evidence
- Desk research
- Sources
- 21
- Topic
- Identity
- Words
- 1,999
Short answer
Device code phishing abuses the OAuth device sign-in flow. An attacker requests a sign-in code, sends it to a victim, and the victim enters it on the genuine Microsoft page and completes MFA. The attacker's session receives the tokens. Block it with a Conditional Access authentication-flows policy on Entra ID P1, or with security defaults on lower plans.
Key points
- The victim enters the attacker's code on a real Microsoft page, so no password is stolen and MFA is completed for real.
- With Entra ID P1 or Business Premium, block device code flow in Conditional Access, starting in report-only mode.
- Without P1, security defaults block device code flow with no exceptions. Microsoft says new tenants block it from 1 July 2026.
- Check sign-in logs first: Authentication protocol = Device code shows current use; Original transfer method shows later refreshes.
- After a compromise, disable the account and revoke sessions. Microsoft says access tokens can stay valid for up to an hour.
- Google's device flow cannot request Gmail or full Drive scopes, so the Workspace exposure is narrow but not zero.

Device code phishing is an attack on a sign-in method built for smart TVs and printers. The attacker asks Microsoft for a sign-in code, sends it to the victim with a plausible excuse, and the victim types it into the real Microsoft page. They pass their own MFA. The session that receives the tokens belongs to the attacker.
This runbook is for a small IT team or a managed service provider: understand the flow, check who uses it, block it on the licence you have, and respond if someone has already entered a code. Each step is sourced to Microsoft Learn, the IETF, the FBI or Google.
What is device code phishing?
Device code phishing is the abuse of the OAuth 2.0 device authorization grant, defined in RFC 8628 in August 2019. The grant lets a device with no browser or keyboard get tokens by asking the user to finish sign-in on a phone or computer.
Microsoft's developer documentation describes it as a way to sign in to "input-constrained devices such as a smart TV, IoT device, or a printer". The device asks for a user_code and a device_code, shows the user code with a verification_uri, and then polls until sign-in completes. The user has 15 minutes by default. A refresh token comes back if the request included offline_access.
The standard saw the risk coming: "It is possible for the device flow to be initiated on a device in an attacker's possession." Nothing ties the code to the person who requested it.
How the attack runs, step by step
- The attacker requests a device code from Microsoft. Storm-2372 switched to the client ID of a Microsoft app, the Microsoft Authentication Broker, in February 2025.
- The attacker sends the victim the code and the address of Microsoft's real code-entry page.
- The victim enters the code, signs in and completes MFA.
- Microsoft issues access and refresh tokens to the attacker's polling session.
- The attacker reads mail and files for as long as the tokens stay valid.
Microsoft's Teams devices guidance puts it plainly: "Because the sign-in page is real, this attack can be harder for users to recognize."
What a lure looks like
Picture an email headed as a password expiry notice. It says the account will be locked today, gives a short code, and asks the reader to enter it at microsoft.com/devicelogin. Every link points to a genuine Microsoft address.
Microsoft's April 2026 analysis quotes the subject line "Action Required: Password Expiration" and lists invoices, requests for proposal, shared files, e-signing and voicemail as other themes. Storm-2372 posed as prominent people on WhatsApp, Signal or Teams, then sent fake Teams meeting invitations.
The 15-minute expiry used to limit these lures. In the April 2026 campaign, Microsoft says, "the 15-minute countdown only begins the moment the victim clicks the phishing link", because the kit requested a fresh code on each click.
Why doesn't MFA, or even a passkey, stop it?
MFA does not stop device code phishing because the victim completes MFA on the attacker's behalf. Microsoft's April 2026 analysis describes the attacker's access as "bypassing MFA by design". The FBI says Kali365 reached Outlook, Teams and OneDrive "without a password or additional MFA challenges."
Passkeys do not change that by themselves. Microsoft's passkey documentation explains that passkeys use "origin-bound public-key cryptography" and release secrets only to the site they were registered with. That defeats a fake login page. In device code phishing there is no fake page: the victim is on Microsoft's real one, so the passkey works as designed.
Microsoft does not say this in one sentence; it follows from the documented mechanism. Passkeys remain the right method otherwise, as the multi-factor authentication guide for small business sets out. Device code flow needs its own control.
Who uses device code flow legitimately?
Few, by Microsoft's account. Its managed policy page says: "Device code flow is rarely used by customers, but is frequently used by attackers."
The legitimate users Microsoft names are Teams Rooms and other shared Teams devices, smart displays and signage, and "Azure CLI, developer tools, admin tools, or legacy command-line experiences". Teams devices need the flow for first sign-in and again after password or Conditional Access changes.
Step 1: check who signs in with device code today
Microsoft and the FBI both advise auditing existing use before blocking.
- Open the Microsoft Entra admin center and go to Entra ID > Monitoring & health > Sign-in logs, as described on Microsoft's sign-in logs page. A Reports Reader role is enough.
- Add the Authentication protocol filter and choose Device code. This shows every sign-in that used the flow.
- Check the non-interactive sign-ins tab as well as the interactive one.
- Open any result and read Original transfer method under Activity details > Basic info. A value of Device code flow means a later sign-in or token refresh came from an earlier device code session.
- To see device registrations, filter the Resource ID for the Device Registration Service, client ID
01cb2876-7ebd-4aa4-9cc9-d28bd4d359a9.
The field names come from Microsoft's authentication flows page and its Teams devices guidance. For each hit, note the user, app, device and business owner. A device code sign-in by an ordinary user with no Teams Room or CLI tool is a possible incident.
Step 2: block device code flow, by licence
What you can do depends on whether the tenant has Entra ID P1. Microsoft's Conditional Access overview says the feature "requires Microsoft Entra ID P1 licenses", and that Business Premium customers "can also use Conditional Access features".
| Plan | Entra ID edition | How to block device code flow | Exceptions possible | Sign-in log retention (days) |
|---|---|---|---|---|
| Microsoft 365 Business Basic | Free | Security defaults | None | 7 |
| Microsoft 365 Business Standard | Free | Security defaults | None | 7 |
| Microsoft 365 Business Premium | P1 | Conditional Access authentication flows policy | Group-scoped and resource exclusions | 30 |
| Microsoft 365 E3 | P1 | Conditional Access authentication flows policy | Group-scoped and resource exclusions | 30 |
| Microsoft 365 E5 | P2 | Conditional Access, plus risk-based policies | Group-scoped and resource exclusions | 30 |
| Entra ID Free (any plan without P1) | Free | Security defaults | None | 7 |
| Entra ID P1 (standalone) | P1 | Conditional Access authentication flows policy | Group-scoped and resource exclusions | 30 |
Microsoft's licensing page lists P1 in Business Premium, E3, E5 and the frontline F1 and F3 plans, and P2 in E5. Business Basic and Standard are not on either list, so they run on Entra ID Free.
With Entra ID P1 or Business Premium: a Conditional Access policy
Microsoft's policy guide recommends getting "as close as possible to a unilateral block on device code flow". The steps, as Microsoft documents them:
- Sign in as at least a Conditional Access Administrator and go to Entra ID > Conditional Access > Policies > New policy.
- Under Users or workload identities, include All users. Exclude your emergency access (break-glass) accounts and any approved exception groups. Microsoft adds: "Audit this exclusion list regularly."
- Under Target resources, include All resources (formerly 'All cloud apps').
- If devices register by device code, exclude Device Registration Service under Target resources > Exclude. Microsoft has enforced these policies on that service since early September 2024 when a policy targets all resources.
- Under Conditions > Authentication Flows, set Configure to Yes and select Device code flow.
- Under Grant, choose Block access.
- Set Enable policy to Report-only and create it. Review the results, then switch it to On.
A second policy, built the same way with Authentication transfer selected, blocks the QR-code hand-off from desktop Outlook to a phone. The FBI recommends blocking both.
For Teams Rooms and other shared Teams devices, Microsoft's pattern is a persistent security group holding only the Teams device resource accounts, excluded from the policy. Its warning matters: "An exception is account-scoped. There's no way to scope the exception to just one resource or scenario." Keep technicians' and staff accounts out of that group. Move CLI users to browser-based or brokered sign-in where possible.
Microsoft's protocol tracking keeps a session marked as device-code-derived through later refreshes. A device first signed in by device code can be blocked later with error AADSTS530036.
Microsoft also ships a managed policy called Block device code flow. It arrives in report-only mode and is switched on "no less than 30 days" later unless an admin turns it off. That page lists "Microsoft Entra ID P2 or Microsoft 365 Business Premium" as its prerequisite, which conflicts with the P1 requirement elsewhere. Check your policy list for it, and add your break-glass exclusions.
Without P1: security defaults
Microsoft's security defaults page lists "Blocking device code flow" among the basic controls. It says: "After security defaults are enabled in your tenant, authentication requests that use device code flow are blocked." A dated note adds: "Starting July 1, 2026, all new Microsoft Entra tenants block device code flow as part of security defaults."
Security defaults are on or off, with no exceptions, so a Teams Room that needs device code will not sign in. Check the setting at Entra ID > Overview > Properties > Manage security defaults.
The page does not say when the block reached tenants that already had security defaults on before July 2026. Confirm it in the sign-in logs: a successful device code sign-in after enabling means something is still allowing it.
Step 3: if someone already entered a code
Treat it as an account compromise. A password reset alone does not end it, because the attacker holds tokens. Microsoft's compromised mailbox guidance gives the order:
- Disable the account. Microsoft calls this "preferred and highly recommended" during the investigation.
- Revoke sessions. revokeSignInSessions "invalidates all the refresh tokens issued to applications for a user", after "a small delay of a few minutes". Microsoft's April 2026 analysis warns that access tokens can remain active "for up to an hour", which is why disabling comes first.
- Check devices and methods. Attackers in that campaign "registered new devices to generate a Primary Refresh Token". Remove any device or MFA method the user does not recognise.
- Review app consents, admin roles, mail forwarding and inbox rules, including hidden rules.
Then reset the password, re-enable the account and block the flow. Log it in your incident response plan, including what the attacker could read. Mail access can trigger breach notification deadlines.
What about Google Workspace?
Google supports the same grant, but with far fewer permissions. Its limited-input device guide says the flow "is supported only for the following scopes": email, openid, profile, drive.appdata, drive.file, and two YouTube scopes.
None of those reads Gmail. Google's Drive scope list describes drive.file as access to files "that you open with an app", not the whole Drive. A phished Workspace user therefore gives away their identity, files the attacker's app creates or is handed, and possibly a YouTube channel the account manages.
Workspace admins can restrict third-party apps under Security > Access and data control > API controls, including a setting for Unconfigured third-party apps. Google's pages do not say whether these settings cover device-flow clients, so test any change on a pilot organisational unit first.
Finally, give staff one rule: never enter a code that a device in front of you is not showing. The same lures also arrive as ordinary phishing, which the business email security guide covers. Lures sent from what looks like your own address are explained in phishing email from your own domain.
Sources
- RFC 8628: OAuth 2.0 Device Authorization Grant
IETF. Checked . - OAuth 2.0 device authorization grant
Microsoft Learn. Checked . - Authentication flows as a condition in Conditional Access policy
Microsoft Learn. Checked . - Block authentication flows with Conditional Access policy
Microsoft Learn. Checked . - Restrict device code flow for Microsoft Teams devices with Conditional Access
Microsoft Learn. Checked . - Microsoft-managed Conditional Access policies
Microsoft Learn. Checked . - Microsoft Entra Conditional Access overview
Microsoft Learn. Checked . - Configure security defaults for Microsoft Entra ID
Microsoft Learn. Checked . - Microsoft Entra licensing
Microsoft Learn. Checked . - Microsoft Entra data retention
Microsoft Learn. Checked . - Sign-in logs in Microsoft Entra ID
Microsoft Learn. Checked . - user: revokeSignInSessions
Microsoft Learn. Checked . - Respond to a compromised email account in Microsoft 365
Microsoft Learn. Checked . - Passkeys (FIDO2) authentication method in Microsoft Entra ID
Microsoft Learn. Checked . - Storm-2372 conducts device code phishing campaign
Microsoft Threat Intelligence. Checked . - Inside an AI-enabled device code phishing campaign
Microsoft Defender Security Research. Checked . - Unmasking EvilTokens: getting to the root of device code phishing
Microsoft Threat Intelligence. Checked . - Kali365 Phishing-as-a-Service Kit Hijacks Microsoft 365 Access Tokens (I-052126-PSA)
FBI Internet Crime Complaint Center. Checked . - OAuth 2.0 for TV and Limited-Input Device Applications
Google for Developers. Checked . - Choose Google Drive API scopes
Google for Developers. Checked . - Control which third-party & internal apps access Google Workspace data
Google Workspace Admin Help. Checked .
Questions readers ask
Does MFA stop device code phishing?
No. The victim completes MFA themselves, on the genuine Microsoft sign-in page, for a session the attacker started. The FBI says the Kali365 kit reached Outlook, Teams and OneDrive without a password or extra MFA challenge. The control that works is blocking the device code flow itself, through Conditional Access or security defaults.
What is microsoft.com/devicelogin?
It is Microsoft's real page for entering a device sign-in code, used by smart TVs, Teams Rooms devices and command-line tools such as Azure CLI. Because the page is genuine, a message asking you to enter a code there is not proof of safety. Only enter a code that a device in front of you is showing.
Will blocking device code flow break Teams Rooms?
It can. Microsoft says Teams devices use device code flow for first sign-in and for reauthentication after password or policy changes. Its guidance is a persistent exception group holding only the Teams device resource accounts, plus an exclusion for the Device Registration Service. Pilot the policy in report-only mode before switching it on.
Does resetting the password remove the attacker?
Not on its own. The attacker holds tokens, not the password. Microsoft's response guidance is to disable the account, then revoke sign-in sessions, which invalidates refresh tokens. Microsoft warns that access tokens can stay valid for up to an hour, and that attackers may have registered a device, so check devices too.
Is Google Workspace exposed to device code phishing?
Less than Microsoft 365. Google's device flow accepts only sign-in scopes, two limited Drive scopes and two YouTube scopes. It cannot request Gmail or full Drive access, so mailbox reading of the kind seen in Microsoft 365 campaigns is out of reach. Files an app creates or opens are still exposed.


