Microsoft 365

Device Code Phishing in Microsoft 365: Block It and Spot It in Your Sign-In Logs

This phishing trick uses Microsoft's real sign-in page, so staff training alone will not stop it. A Conditional Access policy can, and your sign-in logs will show if it has already happened.

By Noah Stertzbach, owner of NHM Ohio · Published · 6 min read

This article was written with the help of AI. We used an AI assistant to draft it, then checked the steps against Microsoft's documentation and threat research. Sources are linked throughout.

Device code phishing is one of the few attacks where the sign-in page your employee sees is genuinely Microsoft's. Microsoft's own documentation calls the device code flow "a high-risk authentication method that can be part of a phishing attack" and recommends blocking it wherever possible.

How the Attack Works

The device code flow exists so you can sign in to things without a keyboard, like a conference room screen. The screen shows a short code; you type it at microsoft.com/devicelogin on your phone and sign in there. Attackers abuse it like this:

  1. The attacker starts a sign-in on their own computer and gets a code from Microsoft.
  2. They send your employee a message, often a fake Teams meeting invite, asking them to enter the code to join.
  3. The employee goes to the real Microsoft page, enters the code, and signs in with password and MFA.
  4. Microsoft gives the session to the attacker's computer, not the employee's.

Microsoft documented exactly this in a campaign it tracks as Storm-2372, active since August 2024. The attackers used the tokens to search mailboxes for words like "password" and "admin," sent more device-code lures from the compromised account to coworkers, and in a later wave registered their own device in the victim's Entra directory to keep access.

Why Attacker-Registered MFA Is the Real Danger

Once an attacker has a working session, the next move is usually to make it permanent: register their own phone or authenticator app as an MFA method, or join their own device to your directory. After that, a password reset does not lock them out. That is why the second policy below, which controls who can register security info and from where, matters as much as blocking the flow.

Step 1: See Whether Anyone Uses the Device Code Flow

In the Microsoft Entra admin center, open Sign-in logs, add the Authentication Protocol filter and choose Device code. Microsoft suggests this before you block anything. Look at who signed in this way, from where, and to which app. For most small offices the honest answer is either nobody, or one meeting-room device.

When you review a blocked or suspicious sign-in later, the Original transfer method field in the sign-in details shows whether that session started with a device code, even if the current request did not.

Step 2: Block the Device Code Flow

Microsoft's steps, in short:

  1. Go to Entra ID > Conditional Access > Policies and select New policy.
  2. Include All users. Exclude your emergency access (break-glass) accounts.
  3. Under Target resources, include All resources.
  4. Under Conditions > Authentication Flows, set Configure to Yes and select Device code flow.
  5. Under Grant, select Block access.
  6. Set the policy to Report-only, review what it would have blocked, then switch it to On.

If a meeting-room device genuinely needs the flow, Microsoft suggests narrowing the exception, for example to that device type in one network location, rather than leaving it open for everyone.

Step 3: Control Who Can Register MFA

Microsoft's security info registration policy uses the Register security information user action as its target. The template requires users outside your trusted locations to meet an authentication strength before they can add or change MFA methods, and uses a Temporary Access Pass for new hires who have nothing registered yet. That makes it much harder for someone holding a stolen session to quietly add their own phone.

While you are in Entra, check who is allowed to join devices to your directory. Microsoft's Storm-2372 guidance specifically recommends restricting which users can register devices.

Step 4: Look for Signs It Already Happened

  • Device code sign-ins from users who have no reason to use them.
  • MFA methods added recently, especially from an unfamiliar location.
  • Newly registered devices the user does not recognize.
  • New inbox rules that move or delete mail.

If you find any of these, revoke the user's sessions, reset the password and remove what does not belong. Our post on Microsoft 365 token replay walks through that clean-up in more detail.

Sources

Common questions

Why does device code phishing work when the sign-in page is real?

Because the page is real. The attacker starts a sign-in on their own machine, gets a code from Microsoft, and persuades your employee to type that code at microsoft.com/devicelogin. When the employee finishes signing in, Microsoft hands the session to the attacker's machine.

Will blocking the device code flow break anything?

It can. Some conference room devices, digital signs and older command-line tools use it. Microsoft recommends running the policy in report-only mode first and allowing the flow only for documented cases you cannot replace.

Do we need a special license?

Conditional Access is included with Microsoft Entra ID P1, which comes with Microsoft 365 Business Premium. Business Basic and Standard do not include it.

What should we do if we find a device code sign-in nobody expected?

Treat the account as compromised: revoke its sessions, reset the password, and remove any devices and MFA methods the user does not recognize. Then check its mailbox for new inbox rules.

Need help with IT services or web hosting?

Talk with our team about managed IT support, secure hosting, migration, and day-to-day operations.

About the author

Noah Stertzbach, owner of NHM Ohio

Noah Stertzbach

Owner, NHM Ohio

Noah started NHM Ohio in 2021 and runs it from East Canton, Ohio. Clients work with him directly.

More about Noah and NHM Ohio →

IT Security Tips Newsletter

Weekly insights for Northeast Ohio businesses

Practical security and IT tips for Ohio business owners. No spam, and every email has an unsubscribe link.

DMARC setup guidesPhishing examplesSSL renewal checklistsBackup restore checklists

Check your own website

See what the internet can see about your business

A free outside-in check of your website, email and domain records, with what to fix first. No card and no password to choose.

Free, no card, no password to choose: your name and email make a free DomainGuard account that keeps the report, and we email you a link to confirm it. We only read what the internet can already see.

Want Someone to Set Up These Policies?

We set up Conditional Access in report-only mode, review what it would block with you, then turn it on. Northeast Ohio businesses on Microsoft 365.

Looking for specific offerings? Managed IT services or web hosting services.