ORIYANOCYBERSECURITY / AI / TECHNOLOGY
Home/Article

How to Block Device Code Phishing in Microsoft Entra ID and Remove Rogue Devices

Sean··

A device code phishing campaign tracked by Huntress registered 468 rogue Windows devices across 326 identities in 305 Microsoft Entra ID tenants during November 2026, and it is still running. The point that should change your incident response runbook is this: once the attacker's device holds a Primary Refresh Token, a password reset does not evict them. This guide covers how the attack works, how to block the device code flow with Conditional Access, how to tighten device registration, and how to hunt for and remove a rogue device in the right order.

None of this requires a vulnerability. Every step the attacker takes uses a legitimate Microsoft feature, on a legitimate Microsoft page, with the victim's real MFA approval. That's what makes it effective, and it's also what makes it fixable with configuration.

FIDO2 hardware security key on a keyring next to a second security key still in its retail packaging
Image: YubiKey 5C NFC next to a key on a keychain by Daniel Aleksandersen, CC BY 4.0, via Wikimedia Commons. Not modified.

How does device code phishing work in Microsoft 365?

The device code flow is an OAuth sign-in method built for hardware that has no decent keyboard: smart TVs, printers, conference room panels. The device shows a short code, you open a browser on your phone or laptop, type the code at Microsoft's sign-in page, and authenticate. The device then receives tokens on your behalf. Microsoft's own documentation calls it a high-risk authentication method that can be part of a phishing attack, and recommends blocking it wherever possible.

The phishing version simply swaps the TV for the attacker. The attacker starts a sign-in, gets a user code, and sends it to the victim dressed up as something routine, such as a shared document or a meeting invitation. The victim enters the code on the genuine Microsoft page and completes MFA. There's no fake login form and no password typed into the wrong site, so the usual "check the URL" training does nothing. The attacker's session now holds valid access and refresh tokens.

In the Huntress campaign, as reported by BleepingComputer and CSO Online, the attacker used those tokens to register a new Windows device in the victim's tenant and obtain a Primary Refresh Token (PRT), the long-lived credential Windows uses for single sign-on into Microsoft 365. From there the activity moved to Entra ID and Office sign-ins and then to OneDrive, SharePoint and Exchange. As Frank Dickson of Dickson Research put it to CSO, the password never entered into it. Change the password and the PRT keeps working. It can even satisfy Conditional Access rules that only require a registered device.

A few details from the campaign are useful as indicators. In the first two weeks of November the attacker registered 276 devices at 168 organizations with names following the pattern MH- plus 16 uppercase hex characters. Huntress found that every registration reported the Windows build that is the default in ROADtools (10.0.19041.928 in that early batch), an open-source Entra ID research toolkit the attacker appears to have repurposed. Huntress saw 46 device names in total, some reused across as many as 24 unrelated organizations and kept in use for up to 10 days. Huntress hasn't tied the activity to a named actor.

The broader context matters too. BleepingComputer notes that several phishing-as-a-service operations have adopted device code phishing, including Tycoon2FA, Greatness and Kali365, and CSO reports that a kit described by Microsoft in April 2026 generates the code the moment the victim clicks, sidestepping the 15-minute code expiry that used to limit these lures.

Nation-state tradecraft is now a subscription product. Plan accordingly.

Which Entra ID controls stop device code phishing?

The controls stack. No single setting closes every path, but together they take the attack from cheap to awkward. The table maps each control to what it breaks in this chain, based on Microsoft's documentation and the guidance Huntress and the analysts quoted by CSO published this week.

Entra ID controls against device code phishing and rogue device registration
ControlWhat it breaksWhere it lives
Conditional Access policy blocking device code flowThe initial token grab from a phished codeConditional Access, Conditions, Authentication flows (Entra ID P1 or above)
Restrict who may register or join devicesRogue device registration by ordinary accountsEntra ID device settings
Lower the maximum devices per userUnlimited quiet registrations (the default cap is 50)Entra ID device settings
Require MFA for the "Register or join devices" user actionRegistration riding on an existing sessionConditional Access user actions
Require compliant (managed) devices, not just registered onesThe PRT satisfying "registered device" policiesConditional Access grant controls with Intune compliance
Phishing-resistant MFA (FIDO2 keys, passkeys)Users approving sign-ins they didn't startAuthentication methods policy

Start with the device code block. Microsoft recommends getting "as close as possible to a unilateral block," and most organizations don't need the flow for more than a handful of meeting room devices or legacy tools. Dickson's view, quoted by CSO, is the same in fewer words: most users do not need it.

  1. Measure current use first. Filter the Entra sign-in logs by authentication protocol for device code events, and check both interactive and non-interactive sign-ins, since token refreshes land in the latter.
  2. In the Entra admin center, go to Entra ID, Conditional Access, Policies, and create a policy covering all users, excluding your break-glass accounts.
  3. Target all resources. Under Conditions, Authentication flows, set Configure to Yes and select Device code flow. Under Grant, choose Block access.
  4. Create it in Report-only mode, review the impact for a week, then switch it On. Carve out documented exceptions by device platform or named location rather than by exempting whole user groups.
  5. In device settings, limit who may register and join devices, lower the per-user device cap from the default 50 to something realistic for your staff, and require MFA for registration through the Conditional Access user action.

Two quirks are worth knowing before you flip that switch. Microsoft enforces authentication flow policies on the Device Registration Service when the policy targets all resources, so if any legitimate process registers devices through device code flow, you'll need to exempt that resource deliberately. And Entra applies protocol tracking: a session that started with device code flow stays marked as such through later token refreshes, so a narrow exception for one app can still produce blocks when that same session reaches for another. Report-only mode exists for exactly this reason.

How to hunt for rogue Entra ID devices

Detection here is refreshingly concrete. In your Entra sign-in data (in Microsoft Sentinel or Log Analytics, the SigninLogs and AADNonInteractiveUserSignInLogs tables), look for successful sign-ins where the authentication protocol is device code, particularly from users who have never legitimately used it. Then pivot to the Entra audit logs and pull device registration events for those same users in the following minutes. A device code sign-in followed quickly by a new device registration is the shape of this campaign. Adjust field names to your schema; the sequence is what matters.

For the specific campaign, sweep your device inventory. Export all Entra registered devices and filter for display names beginning with MH-, an operating system version of 10.0.19041.928, and recent registration dates with no matching Intune enrollment. That last check catches variants that change the naming pattern. A registered Windows device that no one in IT has ever seen and that isn't managed is worth a phone call to its owner today.

What is the right order to remove a rogue device?

Order matters. Huntress and BleepingComputer are explicit that if the rogue device isn't removed, the attacker's PRT can survive a password reset, so device removal comes first. The sequence: delete the rogue device from Entra ID, revoke the user's sessions and refresh tokens, then reset the credentials. After that, sweep for anything else the attacker planted while they had the run of the account, especially new MFA methods and mailbox inbox rules, which are the usual tools for business email compromise. Review what the account touched in OneDrive, SharePoint and Exchange during the window.

Here's what I'd change first in most response plans. Many incident playbooks still treat "reset password and force MFA re-registration" as containment for a phished account. Against a device-bound token, that's theatre. Write device inventory review into the first fifteen minutes of every Microsoft 365 account compromise, not as a follow-up item for next week.

The campaign is a reminder of where the identity perimeter has quietly moved. As Dickson told CSO, in Microsoft 365 the password is no longer the key; the device is. Block the flow you don't use, make registration a privilege instead of a default, and teach the response team to look at devices before passwords. Then go check your tenant for anything named MH-.

References

Toulas, B. (2026, December 3). Device-code phishing campaign plants rogue devices in 305 Entra tenants. BleepingComputer. https://www.bleepingcomputer.com/news/security/device-code-phishing-campaign-plants-rogue-devices-in-305-entra-tenants/

Plumb, T. (2026, December 4). Microsoft 365 attackers are bypassing password resets by registering their own rogue devices. CSO Online. https://www.csoonline.com/article/4256610/microsoft-365-attackers-are-bypassing-password-resets-by-registering-their-own-rogue-devices.html

Microsoft. (n.d.). Block authentication flows with Conditional Access policy. Microsoft Learn. https://learn.microsoft.com/en-us/entra/identity/conditional-access/policy-block-authentication-flows

Microsoft. (n.d.). Conditional Access: Authentication flows. Microsoft Learn. https://learn.microsoft.com/en-us/entra/identity/conditional-access/concept-authentication-flows

Microsoft. (n.d.). Manage device identities using the Microsoft Entra admin center. Microsoft Learn. https://learn.microsoft.com/en-us/entra/identity/devices/manage-device-identities