Blog · Microsoft 365 · Entra ID · Phishing · Incident Response
Device Code Phishing: The Microsoft 365 Attack That Walks Right Past MFA
The email came from a real partner, the sign-in page was really Microsoft's, and the employee really did approve the MFA prompt. The attacker still ended up with the account. This is device code phishing: how it works, what it looked like in an incident we were recently asked to help contain, and the handful of Microsoft 365 settings that stop it.
Microsoft 365
The short version#
- Device code phishing gets around MFA by design. The victim signs in on Microsoft's real page and approves their own MFA prompt, but the sign-in goes to the attacker's computer.
- It often arrives from someone you know. The email in our case came from a real partner organization whose account had already been taken over, so it passed every authenticity check.
- The attacker moves fast and digs in. Within two minutes they registered their own computer in the victim's Microsoft 365 and added their own sign-in key, so a password change alone wouldn't have locked them out.
- One Conditional Access policy shuts the door. Blocking the device code sign-in flow stops the attack outright for most businesses, which never use it. It needs Microsoft Entra ID P1, included in Microsoft 365 Business Premium.
- Check whether it has already happened. The Entra sign-in logs record every device code sign-in, so you can look today.
What is device code phishing?#
Device code phishing is an attack that abuses a legitimate Microsoft sign-in method. The method, called the device code flow, exists for devices with no proper keyboard or browser: smart TVs, conference-room systems, printers and command-line tools. The device shows a short code, and you enter it at Microsoft's sign-in page from your phone or computer. In the attack, the "device" is the attacker's own computer.
The device code flow is a published standard (RFC 8628), and if you've ever signed in to a streaming app on a TV by typing a code on your phone, you've used it. Microsoft supports it for Microsoft 365 and Entra ID accounts. Nothing about it is broken. The attack works because the person typing the code can't see whose device asked for it.
Microsoft has been warning about this technique since at least February 2025, when it described a campaign it tracks as Storm-2372. Since then it has spread well beyond that one group.
How does the attack work, step by step?#
The attacker starts a sign-in on their own computer, which gives them a code valid for 15 minutes. They get the victim to enter that code at Microsoft's real sign-in page, usually by presenting it as the step needed to open a shared document. The victim signs in and approves MFA as normal, and Microsoft completes the sign-in for the attacker.
In more detail:
- The attacker requests a code. Their computer asks Microsoft to start a device code sign-in. Microsoft returns a short code and starts a 15-minute clock. Modern kits generate a fresh code the moment the victim opens the lure, so the clock is rarely a problem for them.
- The lure. An email, Teams message or text asks the victim to view a document, join a meeting or "verify" something. The link leads to a page that shows the code and a button to Microsoft's sign-in page.
- The victim signs in on the real Microsoft page. They enter the code, their password and their MFA approval. Every page they see is genuine.
- Microsoft hands the session to the attacker. The attacker's computer, which has been waiting, now holds tokens for the victim's account: email, files, Teams, whatever that sign-in allowed.
- The attacker digs in. Using a specific Microsoft app, the attacker can register their own computer as one of your organization's devices and add their own passwordless sign-in key. From then on they can get back in without the password or MFA.
| What the victim sees | What is actually happening |
|---|---|
| A document link from a partner they know | A lure from an account the attacker already controls |
| A page with a short code and a "view document" button | A code the attacker's computer created minutes earlier |
| Microsoft's real sign-in page | Microsoft's real sign-in page, approving the attacker's computer |
| Their usual MFA prompt, which they approve | MFA confirming the right person, for the wrong computer |
| Maybe an error, or a document that never loads | The attacker now has a working session on their account |
What did this look like in a real incident?#
We were recently asked to help contain exactly this attack. A staff member received an email from a long-standing partner organization asking them to review a "project proposal." The partner's own account had already been compromised. The proposal was a PDF whose only content was a "view document" button, and the employee followed it through to Microsoft's sign-in page.
Here's how it unfolded, with details kept general to protect the organization:
| When | What happened |
|---|---|
| Day 1, morning | The lure arrives from the partner's real email account. It passes every sender check (SPF, DKIM and DMARC) because it really was sent by that account. |
| About 40 minutes later | The employee enters the code, signs in and approves their MFA prompt from their own desk. |
| 1 to 2 minutes after that | The attacker registers their own computer in the organization's Microsoft 365 under the employee's name, and adds a Windows Hello sign-in key. |
| Within the hour | The attacker copies the entire mailbox, tens of thousands of messages, through Microsoft's own APIs. |
| The next eight days | The attacker quietly checks the new mail every day. Nothing looks wrong to anyone. |
| Day 9 | The attacker sends more than 2,000 copies of the same kind of lure from the employee's account to the organization's contacts, hides the replies and bounce-backs with an inbox rule, and personally answers people who write back asking whether it's real. |
| Day 9, afternoon | The mass email is spotted, and the account is locked down within the hour. |
A few things stood out.
- The email in the inbox had no link in it. The trap was inside an attached PDF, where email filters look less closely. The PDF had been made on a free design site minutes before it was sent.
- The real damage was done on day one. By the time anyone noticed, the mailbox had been gone for over a week. For most businesses that mailbox is the sensitive part: client records, invoices, passwords people emailed themselves, everything.
- The attacker kept trying. For days after being locked out, they retried the account every 25 minutes or so from the same internet address, using the tokens they'd taken.
Why didn't MFA stop it?#
MFA did its job: it confirmed that the right person was signing in. The employee entered their own password and approved the prompt on their own phone, from their own office, so every MFA check passed. What MFA can't tell is whose computer that approval goes to. Device code phishing is built around exactly that gap, so more prompts don't help. Blocking the sign-in method does.
This isn't a fault in any MFA product. The attack works the same way whether the prompt comes from Microsoft Authenticator, Duo or a text-message code. It's also why "we have MFA, so we're covered" is no longer a safe assumption for Microsoft 365.
Why doesn't a password reset get rid of the attacker?#
Because the attacker never needed the password. Within minutes they had registered their own computer as one of the organization's devices and added their own Windows Hello sign-in key, and both keep working after a password change. Their stolen sessions can also stay valid until someone explicitly revokes them.
To actually get them out, you have to remove everything they added, in this order:
- Revoke every session for the account, so all stolen tokens stop working.
- Delete the attacker's device from Microsoft Entra.
- Remove any sign-in methods the user didn't add themselves, such as an unfamiliar Windows Hello key or authenticator app.
- Remove inbox rules that hide, move or forward mail.
- Disable the account until the cleanup is finished, then reset the password and bring it back.
If your accounts sync from an on-premises Active Directory, disable and reset the account there too. Otherwise the next sync can quietly undo changes you made only in Microsoft 365.
Not sure how your Microsoft 365 would hold up against this? Get a free IT assessment and we'll check.
How do you stop device code phishing in Microsoft 365?#
Block the device code flow with a Conditional Access policy. Most small and mid-sized businesses never use it, so blocking it for everyone costs nothing and stops this attack outright, even when someone is fooled into approving MFA. Then tighten who can register devices, and make sure unusual sending gets noticed quickly. Microsoft documents the policy in its guide to blocking authentication flows.
| Control | What it stops | What you need |
|---|---|---|
| Conditional Access: block device code flow | The attack itself, at the sign-in | Microsoft Entra ID P1 (Business Premium, E3, E5) |
| Require MFA to register or join devices, and limit who can | The attacker adding their own computer | Entra ID settings; P1 for the Conditional Access version |
| Require a managed or compliant device for email and files | Access from any computer you don't manage | Entra ID P1 plus Intune |
| Outbound sending limits and alerts | A hijacked account mailing thousands of people | Included in Exchange Online |
| One simple rule for staff | People entering a code they didn't ask for | Ten minutes of training |
A few practical notes:
- Exclude a break-glass admin account from the block, and any shared device that genuinely signs in with a code, such as a Teams Rooms system or a conference-room display. Microsoft will refuse a block policy that covers literally everyone.
- Run it in report-only mode for a few days first if you're not sure what uses device code sign-in. The sign-in logs will show you anything that would have been blocked.
- No Entra ID P1? Microsoft 365 Business Basic and Business Standard don't include Conditional Access, so you can't build this policy. That gap is one of the strongest reasons we recommend Business Premium for small businesses.
- The staff rule: No real document, invoice or meeting ever asks you to enter a code on a Microsoft page. If opening a file leads to "enter this code," stop and call IT.
We cover the wider set of protections in our small business cybersecurity checklist, and the Microsoft 365 side in our cloud and Microsoft 365 services.
How can you tell if it's already happened?#
Check the Microsoft Entra sign-in logs for any sign-in whose authentication protocol is "device code." For most businesses that list should be empty or limited to a few known devices. Any device code sign-in from a regular office user deserves a phone call to that person today, and a closer look at their account.
Then check, for the same period:
- Audit logs: new device registrations and new Windows Hello for Business keys, especially on accounts that didn't get a new computer.
- Mailbox rules: rules with odd or blank names that mark mail as read, move it to a folder nobody uses (RSS Subscriptions is a favorite) or delete it.
- Sent mail volume: a sudden spike from one mailbox, or replies to a subject the user doesn't recognize.
- Mail access records: Microsoft 365's audit logs record which messages were opened and by which device, which is how you find out what the attacker actually read.
What should you do in the first hour?#
Contain first, investigate second. Lock the account so the attacker can't send or read more mail, then work out what they did. In this incident, once every session was revoked the attacker never got back in, even though they kept trying for days.
- Stop the bleeding. Disable the account, revoke all sessions, and block it from sending (an Exchange mail flow rule that rejects mail from the address works even while you investigate).
- Remove the attacker's footholds. Delete their device, their sign-in key and their inbox rules. Save a copy of the rules as evidence first.
- Block the method for everyone. Turn on the device code block policy, so the next person who gets the same lure is safe.
- Clean up the fallout. Remove the phishing email from other mailboxes in your organization, and warn the people it was sent to, from a different account, with everyone in Bcc.
- Work out what was taken. The mail access records tell you which messages were read. That drives decisions about notifying clients, regulators or insurers.
- Keep watching. Check the account's sign-ins daily for a week after it's back in service.
If you're in the middle of this right now, contact us for help.
Where does CVE response fit in?#
Device code phishing isn't a software bug with a CVE number. It's a legitimate feature turned against you. But defending against it takes the same discipline as patching: knowing what's exposed in your environment, learning about new attack techniques quickly, and closing the gap in days rather than at the next quarterly review.
That's how we run CVE and vulnerability management for the businesses we support. We continuously scan servers and workstations for known vulnerabilities and patch actively exploited ones fast, and we apply the same urgency to cloud configuration: sign-in methods, device registration, mail flow and alerting. A Microsoft 365 tenant can be fully patched and still wide open to this attack.
Get a security review#
If you're not certain that device code sign-in is blocked in your Microsoft 365, that strangers can't register devices, and that a hijacked mailbox would be noticed within minutes, it's worth finding out before an attacker does. Our free IT assessment includes a review of your Microsoft 365 security settings by a senior engineer, and you keep the report whether or not you work with us.
We also offer ongoing cybersecurity services and CVE monitoring and rapid patching for Sacramento-area businesses. And if you think an account has already been compromised, get help now.
References#
- Microsoft Threat Intelligence: Storm-2372 conducts device code phishing campaign (February 2025, including the shift to the Microsoft Authentication Broker and device registration)
- Microsoft Learn: Block authentication flows with Conditional Access
- Microsoft Learn: Microsoft identity platform and the OAuth 2.0 device authorization grant flow
- IETF: RFC 8628, OAuth 2.0 Device Authorization Grant
Microsoft, Microsoft 365, Microsoft Entra, Outlook, Teams and Windows Hello are trademarks of the Microsoft group of companies. Duo is a trademark of Cisco Systems, Inc. Names and logos are used for identification only.