By NHI Mgmt Group Editorial TeamBased on Silverfort: “Device code attacks in Azure: From exploitation to detection” (June 9, 2026)

TL;DR: Device code phishing abuses the OAuth device code flow so victims authenticate on Microsoft’s real login page while attackers receive valid access tokens, according to Silverfort, and the tactic has moved from STORM-2372 tradecraft to the EvilTokens PhaaS kit in under a year. Conventional login protections assume credential capture or fake infrastructure; this pattern turns legitimate sign-in into token theft and leaves little for perimeter tools to inspect.


At a glance

What this is: This analysis explains how device code phishing uses Microsoft Entra ID’s OAuth device code flow to hand attackers valid tokens without stealing passwords, and why that pattern is now being commoditised.

Why it matters: It matters because identity teams must govern token issuance, device code usage, and non-interactive sign-ins, not just passwords and MFA prompts, to stop attacks that look legitimate at the login layer.


Context

Device code phishing is an OAuth abuse pattern in which a user completes sign-in on Microsoft’s real device code page while an attacker polls for the resulting token. The security gap is not credential theft alone, but the fact that the polling device is never bound to the person who approved the flow.

For Entra ID programmes, that means the control problem sits in protocol use and token governance rather than email filtering or browser hardening. If a user population has no documented business need for device code authentication, the attack surface exists only because the flow remains available.

The article frames this as a design property of the OAuth device code grant, not a patchable bug. That makes it relevant to IAM, NHI-adjacent token handling, and incident response planning because the compromise happens through a legitimate identity transaction.


Key questions

Q: What breaks when device code flow is left enabled for the broad workforce?

A: The organisation creates an unnecessary path for attackers to turn user approval into access tokens without capturing passwords. Because many users almost never need the flow, broad enablement expands attack surface without adding commensurate business value. The control failure is not just exposure, but the absence of a strong exception model.

Q: Why do passwords, MFA, and passkeys fail to stop device code phishing?

A: They fail because the user completes a legitimate sign-in inside the identity provider, so the attacker receives a valid token rather than stealing the factor itself. The security problem is delegated token issuance to the wrong client, not weak primary authentication. Detection has to look at protocol use and downstream session activity.

Q: What are the signs that device code phishing is happening in Entra ID?

A: Look for successful device code sign-ins tied to first-party clients, unusual geographies or ASNs, and non-interactive token activity that does not match the user’s normal behaviour. Legitimate end-user workflows rarely generate this pattern, so a single hit often warrants investigation and correlation with mailbox or device activity.

Q: Should organisations block device code authentication or keep it for exceptions?

A: Most organisations should block it by default and allow it only for documented headless or constrained-device use cases. If an exception is needed, scope it tightly by user group, device class, and location, then pair it with monitoring so the exception does not become a standing attack surface.


Technical breakdown

How device code phishing turns a legitimate OAuth grant into token theft

The device code flow was designed for headless or input-constrained devices, where a user enters a code on a separate browser and the original client polls for approval. In phishing, the attacker requests the code first, then tricks the victim into completing the flow on Microsoft’s own page. Because the protocol does not bind the polling client to the authenticating user, whoever polls with the code receives the access token and refresh token. That means the attacker never needs a fake login page, a reverse proxy, or captured credentials, only a valid authorization transaction.

Practical implication: Treat the device code grant as an exposed authentication path that needs explicit policy control, not as a harmless alternate sign-in method.

Why MFA and perimeter tools see a clean sign-in

Device code phishing works because the victim really does authenticate, including any MFA prompt, and the only URL involved is Microsoft’s own login domain. Email gateways, URL scanners, and many EDR detections have nothing malicious to block because the lure can point to a benign Microsoft page. The useful security signal appears later in the identity logs: a successful device code sign-in to a first-party client from an unusual location or from an identity that rarely uses that flow. Non-interactive sign-in records matter because token refresh activity is often invisible in the user-facing browser session.

Practical implication: Monitor device code sign-ins and non-interactive token use as identity events, not as endpoint malware events.

How attackers move from token issuance to persistence

Once the attacker has access and refresh tokens, the risk shifts from initial access to persistence and reconnaissance. The article describes device registration to obtain a Primary Refresh Token, Microsoft Graph queries to map users and roles, inbox rules to hide alerts, and targeted collection of finance or executive mail. This is why token revocation alone is only partial containment: already-issued access tokens remain valid until expiry, and a compromised session may already have been used to create durable access paths. The same pattern creates a short initial window and a longer post-compromise window.

Practical implication: Respond as if the session may already have created persistence, not as if token theft ends at issuance.


Threat narrative

Attacker objective: Obtain authenticated Microsoft 365 access that can be turned into persistent mail, data, and fraud operations without stealing a password.

  1. Entry occurs when the attacker initiates a legitimate device code authorization request and delivers the code and Microsoft login URL to the victim through phishing.
  2. Credential harvesting is replaced by token acquisition when the victim completes sign-in on the real Microsoft page and the polling attacker receives valid access and refresh tokens.
  3. Escalation follows when the attacker uses those tokens to register devices, query Microsoft Graph, and create inbox rules for persistence.
  4. Impact is achieved when the attacker exfiltrates high-value email content and organizational data for business email compromise or financial fraud.

Read our 52 NHI Breaches Analysis report for a comprehensive view of breaches impacting Non-Human Identities including AI Agents.


NHI Mgmt Group analysis

Device code phishing exposes a protocol trust gap, not a password problem. The attack succeeds because the identity system treats code approval as sufficient proof of intent, even though the polling client is never bound to the person who entered the code. That means many existing controls are aimed at the wrong failure mode. Practitioners should stop framing this as ordinary phishing and treat it as token issuance abuse.

Microsoft Entra ID control logic assumes the device code flow is a niche exception. That assumption no longer holds once commodity kits can run repeated campaigns at scale and the flow becomes attractive to both state-linked and criminal actors. When a low-friction authentication path is broadly enabled, its exception status becomes an enterprise risk surface. The implication is that access policy must be explicit about which populations truly need the flow.

Device code phishing is a good example of identity blast radius without credential theft. The attacker never needs to learn the password, yet still acquires usable access, refreshability, and often persistence. That expands the blast radius from one login event into mailbox manipulation, device registration, and downstream fraud. Practitioners should measure risk by what a valid token can do, not by whether a password was stolen.

Protocol-level detection has to become part of identity governance. Traditional IAM programmes often focus on authentication success, recertification, and account lifecycle, but this pattern shows the gap between successful sign-in and trustworthy access. The meaningful control is not merely whether a user authenticated, but whether the authentication method, client, and location make sense together. Teams need governance rules that distinguish normal headless use from human-mediated phishing flows.

Token revocation is an incident response control, not a root-cause fix. The article’s post-compromise sequence shows that attackers can act before defenders notice, and already-issued access tokens may stay usable even after passwords change. That makes token governance and session observability the durable control plane. Security leaders should treat this as a lifecycle and containment problem, not a one-off detection problem.

From our research library:

What this signals

Device code flow should now be treated as a policy decision, not a convenience feature. If your organisation has not explicitly documented a business need for it, the safer position is to remove it from the default authentication surface. That changes the IAM conversation from detection after approval to prevention before the code is ever issued.

Token-centric response planning matters more than password reset muscle memory. This attack pattern shows how quickly a valid token can outlive the moment of user approval and enable persistence through mail rules, device registration, and Graph reconnaissance. IAM and SOC teams need a shared view of session, token, and consent state, not just account status.

Device code phishing compresses the distance between human approval and machine abuse. The practical lesson is that identity programmes need controls that understand authentication method, client type, and sign-in context together. Where those signals are not analysed together, the flow looks clean even when the session is compromised.


For practitioners

  • Block device code flow for users without a documented need Use Conditional Access to disable the device code grant for the broad workforce and reserve it only for approved CLI, headless, or constrained-device scenarios.
  • Alert on device code sign-ins and non-interactive token use Correlate successful device code sign-ins with anomalous geographies, rare clients, and non-interactive refresh activity that indicates token theft after the user approves the flow.
  • Extend incident response to token revocation and session review When device code phishing is suspected, revoke access, disable the account if warranted, and inspect OAuth app consents, active sessions, and any new device registrations.
  • Restrict high-value accounts with token binding Apply token protection or binding controls to executive, finance, and administrative accounts so stolen tokens are harder to replay from a separate machine.
  • Audit tenant apps that still allow device code flow Inventory OAuth applications and first-party client use so unsupported or unintended device code exposure can be removed before attackers can abuse it.

Key takeaways

  • Device code phishing works because a real Microsoft sign-in can still hand valid tokens to the wrong machine, which makes it a protocol abuse problem rather than a fake-login problem.
  • The attack has progressed from targeted tradecraft to commoditised phishing operations, which means exposure is now broad enough to matter to everyday identity programmes.
  • Blocking unused device code flow, monitoring non-interactive token activity, and revoking tokens during incident response are the controls that materially reduce the blast radius.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP Non-Human Identity Top 10 and MITRE ATT&CK address the attack and risk surface, while NIST SP 800-53 Rev 5 and NIST CSF 2.0 set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
OWASP Non-Human Identity Top 10NHI-04 — Insecure AuthenticationDevice code phishing abuses a legitimate authentication flow to deliver tokens to the wrong party.
NHI-07 — Long-Lived SecretsRefresh tokens and session persistence extend the blast radius after the victim approves the code.
NHI-10 — Human Use of NHIA human being coerced into approving a machine-oriented flow is central to the abuse pattern.
Recommendation — Block or tightly scope authentication flows that let a valid code or token be reused by an unintended client. Reduce token lifetime exposure and ensure revocation processes cover refresh tokens as well as passwords. Separate human approval paths from machine authentication paths so users cannot hand tokens to unattended clients.
NIST SP 800-53 Rev 5IA-5 — Authenticator ManagementThe article centres on issuing, revoking, and constraining authenticators and tokens.
Recommendation — Apply authenticator lifecycle controls to revoke compromised tokens and limit device-code exposure.
MITRE ATT&CKTA0006;TA0003;TA0040 — Credential Access; Persistence; ImpactThe attack chain moves from token acquisition to durable access and downstream fraud.
Recommendation — Map device code abuse to token theft, persistence, and impact techniques in your detection and response content.
NIST CSF 2.0PR.AA-05 — Access Permissions, Entitlements and AuthorizationsThe article is about controlling who can use a sensitive authentication path and under what conditions.
Recommendation — Constrain device code access with policy so only authorised populations can use the flow.

Key terms

  • Device code phishing: An identity attack that abuses the device authorization flow by tricking a user into entering a code on a legitimate login page while the attacker completes the flow elsewhere. It is effective because it relies on a real authentication protocol and can bypass password theft and familiar MFA prompts.
  • Device Code Flow: A device code flow is an OAuth pattern for clients that cannot host a browser. The application gets a user code and polling credential, while the user completes login in a separate browser session. In CLI contexts, it shifts risk into token handling and session boundary control.
  • Non-interactive sign-in: A sign-in event that occurs without a user actively entering credentials in the moment. These events often represent token refresh, background application use, or service activity. In device code phishing investigations, they are a critical place to look for post-approval token replay and persistence activity.
  • Token Binding: Token binding links a token to a specific device, certificate, or connection so it cannot be reused elsewhere without the bound proof. It reduces replay risk by making theft alone insufficient, although it does not remove the need for monitoring and revocation.

Deepen your knowledge

NHI governance, agentic AI identity, and machine identity lifecycle are core topics in our NHI Foundation Level course, the industry's only accredited NHI security programme. If you are building or maturing an IAM programme, it is worth exploring.
NHIMG Editorial Note
Published by the NHIMG editorial team on June 20, 2026.
Updated on October 6, 2026.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org