Device Code Phishing Beats MFA. Here’s Where It Breaks

  • Home
  • Device Code Phishing Beats MFA. Here’s Where It Breaks
Device Code Phishing Beats MFA. Here’s Where It Breaks

MFA will not save you from device code phishing. The user does everything your awareness training asked for. They check that the address bar says microsoft.com, they enter their own password on Microsoft’s own page, and they approve the Authenticator prompt. A minute later somebody in another country is reading their mailbox with a perfectly valid token, and your firewall logged nothing worse than an HTTPS session to Microsoft.

The technique is old; the packaging is new. In April 2026 Microsoft’s threat researchers described a campaign that used AI-written lures and generated each code only at the moment the victim clicked, which removes the 15-minute expiry that used to blunt these attacks.

Here is the attack taken apart, with the control that breaks each stage.

The short answer: device code phishing tricks a user into approving an attacker’s sign-in on Microsoft’s genuine device login page, so MFA is completed by the victim on the attacker’s behalf. The control that works is a Conditional Access policy blocking device code flow for everyone except a short, named list of devices, backed by sign-in log alerts and a rehearsed token-revocation routine.

Microsoft’s own login page is the bait in device code phishing

Device code flow (formally, the OAuth 2.0 device authorisation grant) exists for equipment without a proper keyboard: a Teams Rooms console, a smart TV, digital signage, a command-line tool on a server. The device shows a code, you enter it at microsoft.com/devicelogin on your phone, sign in, and the device receives tokens for your account.

Attackers simply play the part of the device. Their server asks Microsoft for a code, they persuade your user to type it in, and Microsoft hands the access and refresh tokens to them. The MFA prompt is real, so it gets approved, and the address bar your training told staff to check is genuine.

That’s why we treat it as an identity attack, though it starts in an inbox. MITRE ATT&CK tracks the goal as Steal Application Access Token (T1528), and the defences that actually hold sit in Entra ID, not on the mail gateway.

Animated flow of device code phishing from lure email to attacker persistence
The five steps of the attack, each on a genuine-looking or genuine page.

Six stages of the attack, and the control that breaks each one

Microsoft’s write-up of the April campaign is detailed enough to map the whole chain.

Stage 1: the address check and the lure

The operators confirmed that target mailboxes existed roughly 10 to 15 days before sending anything, then sent lures themed as invoices, RFPs, e-signature requests and voicemail alerts, written to suit each recipient’s role. In an Indian mid-market firm, accounts payable and the promoter’s office get hit first. Safe Links and a tag on first-time external senders cut the volume, but won’t stop a well-written lure.

Stage 2: a fresh code at the moment of the click

Codes expire after 15 minutes, which used to kill next-morning lures. Newer pages request a code only when the victim lands, copy it to the clipboard, and keep polling the attacker’s backend every few seconds until the victim finishes. Redirects ran through serverless hosting such as Vercel and Cloudflare Workers, which web filters treat as reputable. There’s little to gain at the network layer: blocking whole cloud platforms breaks real business traffic.

Stage 3: the victim signs in on the real page

Training helps least here, because the page genuinely is Microsoft’s. What breaks it is a Conditional Access policy that blocks device code flow, since the sign-in then fails however convinced the user is. Passkeys don’t close this route on their own: the user authenticates on the real site, so the passkey works there too.

Stage 4: the attacker redeems the tokens

The polling script now receives access and refresh tokens. Microsoft’s analysts flagged a useful pattern in the sign-in logs: an interrupted sign-in with error code 50199, followed shortly by a success for the same user, which is the pause while the victim types the code. Alert on any device code sign-in outside your approved list, and add sign-in risk policies if you hold Entra ID P2.

Stage 5: persistence through a registered device and inbox rules

In some intrusions the attacker registered a new device within about ten minutes, which gives them a longer-lived foothold than the original token, so device clean-up has to be part of any response. Malicious inbox rules came next, sometimes named with only special characters. Restrict who can register or join devices in Entra ID, and alert on Device Registration Service events and new inbox rules for anyone in finance or leadership.

Stage 6: the payoff

For finance and executive mailboxes, the attackers searched for wire transfer details and invoices. In India this usually ends with a changed bank account on a vendor invoice, the same fraud we walked through in our breakdown of business email compromise. The control belongs to finance: a callback on a known phone number before any change to vendor bank details is accepted.

Six stages of the device code phishing attack with a control for each
Each stage of the attack paired with the control that breaks it.

Block device code flow first, then make room for the exceptions

If you act on one thing from this post, make it this. Microsoft’s Conditional Access guidance on authentication flows recommends blocking device code flow wherever possible and allowing it only where it’s needed. We’d do it first. The catch: something in your estate probably uses it, and finding out after enforcement means a dead boardroom screen on Monday.

The order we follow on a client tenant:

  1. Filter the Entra ID sign-in logs by authentication protocol for device code flow, and export everything the portal still holds. List each user, app and device that appears.
  2. Sort the results into three piles: meeting room and signage devices, admin tools used by IT (the Azure CLI and some PowerShell modules can sign in this way), and everything else. The last pile holds either a forgotten script or a compromise.
  3. Create a Conditional Access policy under Conditions, Authentication flows, targeting device code flow with the block control. Exclude only a named group of room accounts and, where possible, limit that exclusion to your office network locations.
  4. Run it in report-only mode for one to two weeks, read what it would have blocked, then switch it on.
  5. Write the exception list down with an owner beside each line. Your auditor will ask who approved what.

Two Indian realities to plan for. Conditional Access needs Entra ID P1, and plenty of mid-market tenants we see run Microsoft 365 Business Standard, which doesn’t include it (Business Premium does). This one control justifies pricing the upgrade, at least for finance and leadership. Second, multi-site firms often have meeting rooms at plants and branches on different ISP links. Named locations must include every one of those public addresses.

Who uses device code flow What we would do
Teams Rooms consoles, meeting displays Exclude a room account group, limited to office locations
Digital signage, smart TVs Exclude per device account, review every quarter
Azure CLI or PowerShell on admin laptops Switch to interactive browser sign-in, no exclusion
Users or apps nobody recognises Treat as a possible compromise until explained
Conditional Access policy allowing device code flow for room accounts only
Block device code flow by default and allow only a named list.

Where device code phishing shows up in your logs

Blocking the flow stops new attempts. It does nothing about a token issued last Tuesday, so you still need detections. The raw material exists in most tenants, but it rarely sits beside your firewall logs, and Entra keeps sign-in logs for only 30 days on P1 and P2 (less on the free tier), so the portal is not your archive.

These are the checks we put into any SIEM, roughly in order of value:

  • A successful sign-in using device code flow by a user outside the approved room and admin groups. With the block policy on, this should read zero; one hit is an incident.
  • Error 50199 followed within minutes by a successful sign-in for the same user, especially from an address or provider that user has never used.
  • A Device Registration Service event within an hour of an unusual sign-in for the same user.
  • New Exchange Online inbox rules that forward, delete or move mail, weighted higher when the rule name is only symbols.
  • MailItemsAccessed activity from an internet provider your organisation doesn’t use.

Where it usually goes wrong: the alert lands in a queue owned by the network team, and nobody with Entra admin rights sees it until morning. Decide now who owns identity alerts at 2 a.m. If the answer is your MSSP, read the managed SOC SLA clauses that fail under pressure and check the contract actually lets them disable a user.

The first hour after a token is stolen

Resetting the password first feels natural, and it’s the wrong first move, because existing access tokens can stay valid for up to an hour. Microsoft’s own advice for immediate containment is to disable the account temporarily and revoke its sessions.

  1. Minutes 0 to 10: disable the account in Entra ID and revoke sign-in sessions. Tell the user by phone, not by email.
  2. Minutes 10 to 25: remove devices registered to that user in the last 48 hours, and delete inbox rules and forwarding set up during the window.
  3. Minutes 25 to 40: look for app consents and mailbox delegation the user didn’t grant. Search sent items for mail to vendors and the finance team.
  4. Minutes 40 to 60: reset the password and MFA methods, re-enable the account with the block policy in force, and preserve the sign-in and audit logs.

Then comes the reporting question. CERT-In’s April 2022 directions require specified cyber incidents to be reported within six hours of noticing them, and the listed types include unauthorised access to IT systems or data. Whether one compromised mailbox crosses that line is a call for legal and compliance to make early. Our hour-by-hour plan for the CERT-In six-hour clock covers who does what. If customer personal data was exposed, keep DPDP breach duties in view too; most apply from May 2027.

Running the six-stage defence on PrahiX Uni

Microsoft’s tools cover much of this if you hold the right licences. The gap is the join: Entra sign-ins in one portal, mail clicks in another, firewall logs in a third, and a response needing three admins awake at once. PrahiX Ora, the unified SecOps platform built by PrahiX Tech Pvt Ltd, is the platform we deploy and operate for clients to close that join. For this attack the part that matters is PrahiX Uni with its SIEM and SOAR integration. Your firewalls, EDR and Microsoft 365 tenant stay exactly where they are.

Where the Fortinet stack stops, and what PrahiX adds

FortiGate web filtering catches known phishing hosts, and FortiAnalyzer gives clean firewall logs and reports. The limits appear once the attack moves into cloud identity.

With Fortinet alone With PrahiX
Correlating Entra sign-ins with firewall logs means FortiSIEM, a separate product with its own licence and sizing Cloud and SaaS audit logs land on the same engine as firewall syslog, endpoint telemetry and DNS
Automated containment needs FortiSOAR, another product and licence, joined by Security Fabric connectors Detection and response share one data model, so a playbook can revoke a token in the same beat as the alert
FortiAnalyzer retention depends on its storage and licensed log volume, and reports are per product Logs kept 180 days on tiered hot, cold and archive storage, searchable across sources
Deepest context is on Fortinet telemetry, with network and security work in different consoles Every signal tied to its asset, site and user, network health beside identity and endpoint
CERT-In incident submissions are usually assembled by hand CERT-In 2022 mapping with submission-ready reports, and an incident narrative written by RAYA AI
Comparison of the Fortinet stack alone and with PrahiX for cloud identity attacks
Where the Fortinet stack stops on cloud identity, and what PrahiX adds.

Beyond Fortinet: how the other OEMs compare

Device code phishing happens between your user, Microsoft and the attacker’s server. Each vendor covers its own slice and sells cloud correlation separately.

OEM What you get, and where it stops
Fortinet Strong firewall and web filtering; a full SOC means FortiSIEM, FortiSOAR, FortiEDR and FortiAnalyzer, licensed separately
Palo Alto Networks Panorama manages and logs PAN-OS firewalls; correlation and response sit in Cortex XDR, XSOAR or XSIAM, separate products
Check Point Correlation needs SmartEvent, a separately licensed blade; Infinity XDR/XPR is another subscription
Sophos XDR is built on Sophos telemetry first; third-party sources need integration licences
CrowdStrike Agent-based; Next-Gen SIEM is a module with third-party ingestion licensed by volume
Trellix Helix and Trellix EDR are separate products under the XDR umbrella
PrahiX Sits beside all of them and runs detection and response on one engine, with connectors for each
Six security OEMs that sell cloud detection and response as separate pieces
Each OEM sells cloud correlation and response as a separate module.

Stages 4 and 5, caught as one incident

Uni ingests cloud and SaaS audit logs alongside firewall syslog, Windows events, DNS and endpoint telemetry, within about ten seconds of arrival. The checks from the log section become Sigma-based detections mapped to MITRE ATT&CK, written as version-controlled code. UEBA risk scoring raises the weight of a device code sign-in from a new network for someone in accounts payable.

Check from this post How it runs on Uni
Device code sign-in outside the approved list Sigma rule on Entra sign-in data, approved groups kept in version control
50199 then success from a new provider Correlated with UEBA risk scoring for that user
Device registration, inbox rule, MailItemsAccessed Joined into one graph-based attack storyline with the sign-in
Click in mail logs, then risky sign-in Mail and identity events on the same timeline, tied to one user

The first hour, as a playbook with approval gates

In Uni, the first-hour sequence becomes a drag-and-drop playbook: revoke the user’s token through the Azure AD connector, raise the ticket in ServiceNow or Jira, notify the on-call channel in Teams, and pause at an approval gate before acting on a director’s account. One audit trail covers detection to closure. RAYA AI, the agent inside Ora, links the related events, writes the incident narrative and an executive summary, and acts only within the limits you set. See how it fits on our PrahiX Ora SIEM and SOAR page or on the PrahiX Uni product page.

PrahiX Uni capabilities used against token theft and identity attacks
The PrahiX Uni capabilities that map to this attack.

The rest of the PrahiX family on this attack

PrahiX Data Protection answers “what personal data was in there?” by finding Aadhaar, PAN, bank account and other Indian identifiers in Microsoft 365 and Gmail sent mail, with live breach clocks for CERT-In, RBI, SEBI, IRDAI and the Data Protection Board. PrahiX Guest keeps visitors on their own network with a per-person sign-in record, useful when a suspicious login traces back to your office address; see guest Wi-Fi across FortiGate and Sophos with one portal. The camera monitoring system / video surveillance (VMS) puts access control and video on one timeline if you need to confirm who was physically at a desk.

Frequently asked questions

Does MFA stop device code phishing?

No. The victim completes MFA on Microsoft’s genuine page, so every MFA method passes, including passkeys and FIDO2 keys. MFA still matters against password spraying and credential stuffing, so keep it. For this specific attack, what works is blocking device code flow through Conditional Access and alerting on any device code sign-in that gets through.

How do we check whether device code phishing has already hit us?

Filter Entra ID sign-in logs by the device code authentication protocol for the period the portal still holds, and list every user. Anyone outside meeting rooms and known admin tooling needs a conversation. For those users, look for recently registered devices, new inbox rules and mailbox access from unfamiliar providers, then decide whether to treat it as an incident.

Is a compromised Microsoft 365 mailbox reportable to CERT-In?

It may be. CERT-In’s 2022 directions list unauthorised access to IT systems or data among reportable incidents, with a six-hour window from when you notice it. The judgement depends on what was accessed and your sector regulator’s rules, so get compliance or legal involved in the first hour and record the decision either way.

This week: run the report-only policy and read what it finds

Create the Conditional Access policy that blocks device code flow, set it to report-only, and spend ten minutes a day reading who would have been blocked. By Friday you’ll know your real exceptions.

If you’d like a second pair of eyes on that list, or someone watching identity alerts through the night, our team runs managed SOC services from Delhi for Indian enterprises on Microsoft 365. For an account you think is already compromised, an incident response retainer gets a responder on the call quickly.

Leave a Reply

Your email address will not be published. Required fields are marked *