Device-code phishing abuses a legitimate Microsoft sign-in flow meant for TVs and command-line tools. The attacker sends the victim a real microsoft.com/devicelogin link and a code; the victim signs in on the genuine Microsoft page, completes MFA, and unknowingly hands the attacker access and refresh tokens. Block the device code flow with a Conditional Access Authentication flows policy (with narrow exceptions), alert on sign-ins where the authentication protocol is deviceCode, and revoke sessions quickly when it happens.
Most phishing training tells people to check the URL. Device-code phishing passes that test: the victim types the code on the real Microsoft login page and completes their real MFA prompt. Microsoft publicly described a large campaign of this kind (tracked as Storm-2372) in February 2025, aimed at governments, NGOs and companies through fake Teams and WhatsApp meeting invitations, and the technique has since become common in Microsoft 365 account takeover.
What the device code flow is for
The OAuth 2.0 Device Authorization Grant (RFC 8628) lets a device with no browser or keyboard (a smart TV, a conference-room display, a CLI tool such as Azure CLI) sign a user in. The device shows a short code and asks the user to enter it at a URL on their phone or laptop. Once the user signs in there, the device receives tokens.
The weakness is simple: nothing ties the device that asked for the code to the person who enters it. Whoever started the flow gets the tokens.
How the attack works (at a high level)
- The attacker starts a device code request against Microsoft Entra ID, choosing a familiar first-party application, and receives a code that is valid for about 15 minutes.
- They send the code to the victim with a pretext: “Join the meeting: enter code ABCD-EFGH at microsoft.com/devicelogin”, or “Verify your account to view the shared file”.
- The victim goes to the genuine Microsoft page, enters the code, signs in and approves MFA.
- The attacker’s session receives an access token and a refresh token. They can now read mail, Teams chats and OneDrive files, and keep refreshing access for weeks unless the session is revoked.
Because the victim really completed MFA, the sign-in log shows a successful, MFA-satisfied sign-in, often from an unfamiliar IP address.
Why it beats the usual advice
- The domain is genuinely Microsoft’s, so “check the link” does not help.
- Push, OTP and number-matching MFA all succeed, because the user is really signing in.
- No password is stolen, so password resets alone do not remove the attacker; the refresh token keeps working until it is revoked.
- Even phishing-resistant methods such as FIDO2 keys do not stop it on their own, because the key is used on the legitimate page.
The fix: block device code flow with Conditional Access
Most organisations have no business need for device code sign-in apart from a few meeting-room devices and admin tools. Microsoft Entra Conditional Access has an Authentication flows condition for exactly this.
- In the Entra admin centre go to Protection → Conditional Access → New policy.
- Users: All users. Exclude your break-glass accounts and a dedicated group for approved devices or accounts that genuinely need the flow (for example, Teams Rooms resource accounts).
- Target resources: All resources.
- Conditions → Authentication flows: select Device code flow.
- Grant: Block access.
- Start in Report-only for a week, review who would have been blocked, then turn it On.
For the excluded group, add other conditions: allow the flow only from your office’s named locations or only from compliant devices.
Detection
Entra sign-in logs record the protocol used. In Microsoft Sentinel or Log Analytics:
SigninLogs
| where TimeGenerated > ago(30d)
| where AuthenticationProtocol == "deviceCode"
| summarize Count = count(), IPs = make_set(IPAddress, 20), Apps = make_set(AppDisplayName, 10)
by UserPrincipalName, ResultType
| order by Count desc
Things that should raise an alert:
- Any successful
deviceCodesign-in by a user who is not in your approved exception group. - A device code sign-in from an IP address or country the user has never used before.
- A device code sign-in followed shortly by mailbox rule creation, mass file downloads, or new device registration (attackers sometimes register a device to get a longer-lived Primary Refresh Token).
Without Sentinel, you can filter the sign-in logs in the Entra portal by Authentication protocol = Device code, or export them to your SIEM.
Response when it happens
- Revoke sessions for the user (Entra admin centre → user → Revoke sessions, or
Revoke-MgUserSignInSession). This invalidates refresh tokens. - Check for and remove any devices the attacker registered, new MFA methods, inbox forwarding or delete rules, and OAuth app consents.
- Review the unified audit log for what was read or downloaded during the attacker’s session, which matters for breach-notification decisions.
- Reset the password as well, and check whether the same lure went to other users.
Other hardening that helps
- Token protection (Conditional Access session control, where supported) binds sign-in tokens to the device they were issued to, which limits replay.
- Restrict device registration to compliant devices or require MFA to register.
- Continuous Access Evaluation lets critical events (password change, user disabled) cut off active sessions in near real time.
- Teach one rule: “Never enter a code at microsoft.com/devicelogin unless you are setting up a device you are holding.” Meeting invitations never need it.
For Indian organisations
Microsoft 365 is the email and file platform for a large share of Indian mid-size companies, banks’ vendors and government contractors. A device-code compromise gives full mailbox access, which usually means personal data and possibly payment instructions. That is a CERT-In reportable incident (6 hours) and may be a personal data breach under the DPDP Act. Blocking the flow takes about 15 minutes of admin work.
RingSafe’s Microsoft 365 security review checks this policy along with the other common Entra ID gaps. Book a review.
Get a cloud posture review
IAM hardening, public-exposure mapping, IaC review, K8s audit. We map your actual blast radius — not what a CSPM dashboard guesses at.