
Every Line Was True: Catching Device Code Phishing After the Fact
If device code phishing reached your tenant last Tuesday, how would you detect it, and which log would show it first? And if you found it this morning, could you close it today without knocking the boardroom display offline (or locking out the engineer who signs in from Cloud Shell)?
Part 3 made an uncomfortable point: almost everything Entra ID records about this attack is accurate. If those questions stump your shop, that's not a knock on your team (most people learn sign-in logs one incident at a time).
It's also spread across four logs:
Sign-in log (the first sign-in, when the employee enters the code)
Non-interactive sign-ins (the renewals, which happen with no prompt)
Entra audit log (a new device registered in your directory)
Purview audit log (new inbox rules in the mailbox)
Also check here, if you've turned it on: Microsoft Graph activity log (the attacker mapping your users and groups). It needs P1 or P2, and it only records once an admin turns it on in diagnostic settings and sends it to Log Analytics, Azure Storage or Event Hubs. If nobody set it up before the attack, it has nothing to show.
In short: Device code phishing is hard to detect because every record it leaves is accurate (the right employee, a passed MFA prompt, a successful sign-in). The evidence arrives later, in different logs, so catching it after the fact means lining those records up in order. It's hard to close because a block stops new sign-ins (and, with Conditional Access, renewals for the resources it covers), not a token already issued, and some devices and admin tools legitimately use the flow.
Why don't MFA and tenant defaults catch device code phishing?
Each control checks one moment, and device code phishing lives across three of them. MFA checks the person at the first sign-in. Security defaults stop new device code sign-ins. Neither one reaches a token that's already in the attacker's hands, and Microsoft documents blocking the later renewal only for Conditional Access.
The first sign-in, when the employee enters the code and authenticates. MFA works as designed here (though in the April 2026 campaign Microsoft documented, someone already signed in only had to paste the code and confirm), and a block from security defaults or Conditional Access stops it.
The renewal, when the attacker's app trades its refresh token for a fresh access token, with no prompt.
The token already issued, which the app presents to Exchange, SharePoint or Microsoft Graph without signing in at all.
Conditional Access reaches the second moment. A policy that blocks device code flow uses protocol tracking to spot a session that began that way and rejects its renewal for every resource the policy covers (error AADSTS530036 when the policy covers all resources). Security defaults block new device code sign-ins too, but Microsoft doesn't say whether they stop that renewal.
No block reaches the third moment, because no block is retroactive. An access token already issued keeps working until it expires (60 to 90 minutes by default, or up to 28 hours when the app and the service both support Continuous Access Evaluation), so a block at noon leaves an attacker hiding out in an 11:30 token for the rest of that token's life. A block is no panacea for access that already exists (or for anything built from it, like a registered device).

Technologists who have worked through these three moments ask a sharper question than "Is it blocked?" They ask which moment it's blocked at (and since when), and they can trace one token's life from first sign-in to last use. Leadership then hears which access a change stopped and which it didn't.
What makes device code phishing hard to detect after the fact?
The signs exist, but they're accurate and scattered. The first sign-in shows the authentication protocol "Device code." Later renewals land in the non-interactive sign-in log, where the Original transfer method field ("Device code flow") is what ties them back to the first sign-in. Then come a device registration or a new MFA method (both in the Entra audit log) and an inbox rule (in the Purview audit log).
Part 3 named the craft: knowing which records belong together. Nobody doubts the veracity of any single one (every line is true). The hard part is everything around them:
The evidence lives in different places. Sign-ins and audit events sit in Entra ID, inbox rules in the Microsoft 365 audit log in Purview. Microsoft Graph activity logs (where an attacker mapping your users and groups would show up) exist only with P1 or P2, and only if someone sent them to Log Analytics, storage or Event Hubs beforehand.
The evidence ages out. Entra ID keeps sign-in and audit logs 7 days on the free tier, 30 with P1 or P2. A refresh token lasts 90 days by default (and replaces itself each time it's used), so an attacker who waits can outlast what the tenant keeps.
The renewals are easy to skim past. The non-interactive log groups similar sign-ins, and a welter of background refreshes looks normal. Original transfer method is the field that ties those renewals back to device code, so the session stays well-nigh invisible unless you look for it.

A sign-in that succeeded by design raises no alert at all, so the first intimation often isn't in a log. It's an offhand remark at the service desk ("IT called me about a code"), and Microsoft says the employee's memory of that call can be the earliest evidence anyone gets.

A technologist who has traced one of these sessions end to end (even once, in a lab) knows which records to line up, and in what order. He can say when access started and what it touched. Leadership hears "Tuesday at 9:14, and here's everything it reached" instead of "we're still looking."
Which legitimate uses make blocking device code flow a judgment call?
Some devices and tools genuinely use device code flow. Teams Rooms and other shared Teams devices use it to register, reprovision and sometimes reauthenticate, and admin tools such as Azure CLI fall back to it when they can't open a browser. Each one you keep becomes an exception, and each exception reaches further than its name suggests.
The facile answer is "block it" (Microsoft does recommend that wherever possible), but the judgment lives in the few places that still need the flow, under the exigencies of a meeting room that has to work at 9 a.m.
Start with Teams devices. Microsoft's Teams device guidance makes their resource accounts a persistent exception, with two easy-to-miss provisos. The exception is account-scoped (that account can use device code flow for any app the policy covers), and the Device Registration Service exclusion applies to everyone the policy covers (the same service Storm-2372 used to register its own device). Personal Teams devices are harder still, so Microsoft warns against broad user exclusions.
Admin tools are easy to overlook. That Azure CLI fallback means an engineer can land in the flow without ever choosing it (in Cloud Shell, say), and Graph PowerShell and Exchange Online PowerShell offer it as an option too.

This is where one belief costs the most: "We passed the audit, so we're secure." Passing takes work, but an audit only checks that the block existed the day someone looked. A mechanistic pass sees "Block device code flow" turned on and moves on, as if the name were a talisman. As I wrote in Conditional Access Exclusions: A Hygiene Guide for IT Managers, "The policy still shows as on. The excluded identity just walks past the part you turned on to protect it."

Exceptions decay the way skills do (a forlorn account for a room retired last spring sits in the group for months, because nothing breaks). Technologists who have studied what each kind of exception reaches can name every entry's owner and reach in minutes, and tell a judicious exception from one nobody remembers granting. When the auditor asks why the policy excludes the boardroom display, leadership gets a name and a reason instead of a guess.
What should your tenant be able to answer about device code phishing?
Your tenant should be able to answer a handful of plain questions with evidence your team can show. Each one below is a question the Advanced level of the Device Code Phishing What-If Simulator walks through (so your team can work out the answer before an attacker tests it).
If someone entered an attacker's code last month, before any block, what does the attacker still hold, and what would a new block stop?
Which of the attacker's tokens expire on their own, and which keep renewing?
Under security defaults, does a refresh token from an earlier device code sign-in still renew? (Microsoft doesn't document it.)
When a device code sign-in fails, can your team tell which control stopped it, and whether it was the first sign-in or a renewal? (Otherwise a failed sign-in can be a red herring.)
For each exception you keep, what does it reach that its name doesn't say?
Questions like these tend to hang fire until an incident forces them, and by then the logs may have aged out.

Picture a month from now. A user tells the service desk that IT called about a code, and by that afternoon your team has lined up the first sign-in, the renewals and the device registration. A team steeped in Part 3's seven steps (and these questions) answers without guessing, and leadership hears it from its own people first. That's the tenet under this series: technology, at its Greek root (tekhne), means applied skill, and here the skill is knowing what a block reaches. One thing to do today: open the simulator's Advanced level, pick your tenant's situation and run the earlier-authentication scenario. Then answer the first question above with your team, out loud.
Try it: Device Code Phishing What-If Simulator, Advanced level [SIMULATOR URL]
Back to the mechanics: Part 3, How Device Code Phishing Works When Nothing Is Broken, walks the seven steps this part builds on.
For your executives: Part 2, Device Code Phishing Costs Every Tenant. You Choose When You Pay., covers what each exception costs (hand it to whoever approves them).
Frequently asked questions
How long does a refresh token last?
In Microsoft Entra ID, a refresh token (what an app trades for a new access pass, with no sign-in prompt) lasts 90 days by default. It replaces itself each time it's used, so an attacker who waits can outlast the sign-in logs Entra ID keeps. Blocking device code flow (sign-in for devices without a browser) with Conditional Access rejects those renewals for the apps the policy covers.
See additional data here: Token Management Strategies: Mastering Security in Modern IT Ecosystems
Does the access token expire?
Yes. Microsoft sets an access token (the short-lived pass an app shows to reach email, files or Teams) to expire after 60 to 90 minutes by default, or up to 28 hours when the app and the service both support Continuous Access Evaluation. Blocking device code flow (sign-in for devices without a browser) doesn't annul (declare invalid) a token the attacker already holds, so it keeps working until then.
See additional data here: Token Management Strategies: Mastering Security in Modern IT Ecosystems
How long are Entra logs retained?
Microsoft Entra ID keeps sign-in and audit logs for 7 days on the free tier and 30 days with P1 or P2 (the paid licenses). A refresh token (what an app trades for a new access pass, with no prompt) lasts 90 days by default, so an attacker who waits can outlast what the tenant keeps.
What is the difference between access tokens and refresh tokens?
An access token (the short-lived pass an app shows to reach email, files or Teams) lasts 60 to 90 minutes by default, or up to 28 hours when the app and the service both support Continuous Access Evaluation. A refresh token lasts 90 days, and the two are allied (closely connected): the app trades the refresh token for each new access token, with no prompt. Conditional Access (Entra ID's if-then sign-in rules) can block the next renewal, but not a token already issued.
See additional data here: Token Management Strategies: Mastering Security in Modern IT Ecosystems
Glossary
Original transfer method: The sign-in log field that ties a request to an earlier device code session.
Protocol tracking: How Entra ID keeps treating a session as device code flow through later refreshes.
Non-interactive sign-in: A sign-in an app does for a person (a token refresh, say), with no prompt.
Access token: The short-lived pass an app shows to reach email, files or Teams.
Resource account: The account assigned to a Teams room or shared device.
Device Registration Service: The Microsoft service that registers devices in Entra ID.
Microsoft 365 audit log: The Purview log that records user and admin activity across Microsoft 365, such as new inbox rules.
Microsoft Graph activity logs: Records of requests to Microsoft Graph, kept only with P1 or P2, and only if someone sends them to Log Analytics, storage or Event Hubs.
AADSTS530036: The error Entra ID returns when a device code session's refresh token fails Conditional Access authentication flow checks and the policy covers all resources.
Independent educational content from Dynamic Technical Solutions (DTS). DTS isn't affiliated with, endorsed by or sponsored by Microsoft. Microsoft, Microsoft Entra, Microsoft Purview, Microsoft 365, Microsoft Teams, Azure, Exchange, SharePoint and PowerShell are trademarks of the Microsoft group of companies. Other names belong to their owners. Based on Microsoft documentation as of November 2026.
Disclaimer
This article provides independent educational guidance from Dynamic Technical Solutions (DTS), based on information and Microsoft documentation available at the time of publication or most recent revision. Microsoft may change features, settings, policies, and procedures. Review the linked Microsoft sources for current guidance and confirm applicability to your environment before making changes.
DTS is not affiliated with, endorsed by, or sponsored by Microsoft. Microsoft, Microsoft 365, Microsoft Entra, Microsoft Graph, Microsoft Teams, SharePoint, and OneDrive are trademarks of the Microsoft group of companies. All other product names and trademarks belong to their respective owners.


