Device Code Phishing: How to Block It in Microsoft 365

Most phishing advice tells staff to check the web address before they sign in. Device code phishing gets around that advice, because the victim signs in on Microsoft's real website. Nothing about the page looks wrong, because nothing about the page is wrong.
This technique is behind a phishing kit called EvilTokens that security researchers reported again this week, and Microsoft has warned about the same method being used against Microsoft 365 tenants since early 2025. The good news for a small business is that the fix is specific, quick to test, and already included in the licence many of you pay for.
How device code phishing works
Device code sign-in exists for equipment that has no proper keyboard or browser, like a conference room display or a smart TV. The device shows a short code, you open microsoft.com/devicelogin on your phone or laptop, type the code, and sign in. The device is then trusted to act as you.
An attacker can start that same process from their own computer. They get a valid code from Microsoft, then send it to your employee dressed up as something routine: a shared DocuSign envelope, an Adobe document, a OneDrive file, or a Teams meeting invite. The message says "enter this code to view the document." The employee goes to the genuine Microsoft page, enters the code, completes MFA as usual, and has just signed the attacker in.
What the attacker receives is not a password. It is a set of tokens that keep working without another MFA prompt. Microsoft has observed attackers using that access to read mailboxes, create hidden inbox rules, and register their own device in the tenant, in some cases within minutes. From there, the usual next step is invoice fraud: a reply in an existing email thread asking a customer to pay a new bank account.
Why MFA alone does not stop it
MFA is still the most important of the Microsoft 365 security settings, and it stops the vast majority of password attacks. Device code phishing does not steal a password, though. The employee performs the MFA step themselves, on Microsoft's real site, for a sign-in the attacker started. MFA is working exactly as designed; it is just approving the wrong request.
That is why the fix is not "more MFA." The fix is to stop this type of sign-in from working at all for people who never need it, which is almost everyone in a small business.
How to block device code sign-in in Microsoft 365
Microsoft's own guidance is to block device code flow wherever possible. You do that with a Conditional Access policy, which requires Microsoft Entra ID P1. That is included in Microsoft 365 Business Premium. If your users are on Business Basic or Business Standard, Conditional Access is not available without an add-on licence or an upgrade.
Step 1: Check whether anyone uses it today
In the Microsoft Entra admin center, open the sign-in logs and filter the Authentication protocol to Device code. In most small businesses this list is empty, or shows only a Teams Room device or an IT admin's command-line tool. Note anything legitimate before you change anything.
Step 2: Create the policy in report-only mode
In Entra ID > Conditional Access > Policies, create a new policy:
- Users: include all users. Exclude your emergency access (break-glass) accounts and any accounts you identified in step 1.
- Target resources: all resources.
- Conditions > Authentication flows: set Configure to Yes and select Device code flow.
- Grant: Block access.
- Enable policy: Report-only.
If you have Teams Rooms or other Teams devices that sign in with a code, Microsoft also recommends excluding the Device Registration Service resource and keeping those device accounts in a dedicated exception group, so the devices can still register.
Step 3: Review, then turn it on
Leave the policy in report-only mode for a few days and check what it would have blocked. If the results only show sign-ins you expected to block, switch the policy to On. Review the exception group every few months so it does not quietly grow.
If someone already entered a code
Treat it as a compromised account, even if the employee is not sure:
- Revoke the user's sessions in the Entra admin center so the stolen tokens stop working. An access token that was already issued can stay valid for up to an hour, so also consider disabling the account briefly while you investigate.
- Check the user's registered devices and remove any the employee does not recognise.
- Look for inbox rules that forward, delete or move mail, and for MFA methods the user did not add.
- Search the sign-in logs for that user with the Device code protocol to see when it happened.
- Warn anyone the account emails regularly about payments, and confirm any recent bank-detail changes by phone.
What to tell your staff
A one-line rule covers it: Microsoft will never ask you to type a code to open a document. If a message asks you to go to microsoft.com/devicelogin and enter a code, and you are not standing in front of a meeting-room screen that is showing that code, stop and ask.
The same habit helps with the other campaign doing the rounds this month: fake "Microsoft 365 outage" emails that threaten to delete your messages unless you click a link. Real service problems are listed in the Microsoft 365 admin center under Service health, and I track the ones that matter to small businesses on the IT status and advisories page. For broader guidance, see phishing protection for small businesses.
Where this fits in a wider review
Blocking device code sign-in is one setting, but it tends to sit next to others that are worth checking at the same time: legacy sign-in methods, external email forwarding, who holds global administrator rights, and whether staff can approve app consent requests on their own. If you would like those reviewed together, a Microsoft 365 Security Assessment covers them read-only and gives you a prioritised list of what to change. If you already know you want the controls set up and watched each month, that is part of Secure Cloud Workplace.
Need help with this?
Book a free 20-minute call — I'll tell you what needs to happen, no sales pitch.