Employees are often taught to check the web address before entering a work password. That is still good advice. But a Microsoft device code phishing email can send someone to a genuine Microsoft sign-in page and still put the account at risk.
The trick is the sign-in request. An attacker starts an authentication flow on a device or app they control, then persuades an employee to enter the attacker's code. The employee may sign in and complete multifactor authentication (MFA) as usual. In doing so, they can authorize a session the attacker initiated.
In this guide
What is Microsoft device code authentication?
Device code flow is a legitimate Microsoft sign-in method for devices that lack a convenient browser or keyboard. A device displays a short code; the user visits Microsoft's sign-in page on another device, enters the code, and completes the requested authentication.
This is useful for some input-limited devices and administrative or development tools. Microsoft's device authorization flow documentation explains how the process works.
The flow becomes risky when the user did not start it. An attacker can request a code from their own app, then send that code to an employee with a message such as:
- “Your Teams session expired. Sign in again using this code.”
- “IT needs you to verify your Microsoft 365 account.”
- “Use this code to view the shared document.”
The message may arrive by email, Teams, text message or another channel. The employee can see a legitimate Microsoft page, but the code was created for an authentication request that the attacker started.
How device code phishing works
A typical device code attack follows this pattern:
- The attacker starts a device-code sign-in from an app or device they control.
- Microsoft issues a temporary code for that request.
- The attacker sends the code to an employee with a believable prompt.
- The employee opens the genuine Microsoft authentication page and enters the code.
- The employee signs in and may complete MFA.
- The attacker's app can receive the authorization requested in that flow, subject to the account, app, tenant policies and permissions involved.
The precise access varies. A successful sign-in does not automatically mean the attacker can read every company mailbox or file. It can, however, give the attacker access to resources available through the affected account and approved app, so the event should be investigated.
Why a real Microsoft page can still be part of a phishing attack
Traditional phishing often uses a fake website to steal credentials. Device code phishing can use the real Microsoft page. The employee's password may not be typed into a fake site; instead, the employee is persuaded to complete an authentication request they did not initiate.
That is why checking the domain alone is not enough. Employees should also ask:
Did I start this sign-in or device setup, and do I know which app or device I am authorizing?
If the answer is no or unclear, they should stop and verify the request through a known IT contact method. They should not reply to the sender or use contact details supplied in the unexpected message.
Does MFA stop a device code attack?
MFA remains an important account protection and should not be disabled because of this attack. But it does not by itself prevent a user from completing an attacker-initiated flow. The employee may be asked to authenticate normally, including MFA, as part of approving the code.
In that situation, MFA was not necessarily technically bypassed. The employee was misled about what the authentication request would authorize. This is one reason Microsoft 365 security needs to consider both who signs in and which authentication flows are allowed.
This is different from Microsoft 365 session token theft, where an attacker may target an already authenticated session. Both are identity risks, but the attack paths and investigation steps differ.
How Conditional Access can reduce the risk
Microsoft recommends blocking device code flow wherever possible and allowing it only for documented, secured business needs. In Microsoft Entra Conditional Access, an administrator can create a policy that targets Device code flow under Conditions → Authentication flows and applies Block access under Grant controls.
Before enforcement, Microsoft recommends using Report-only mode and reviewing policy impact. Administrators should check sign-in logs for device-code activity, identify the users, apps and resources involved, and confirm whether those sign-ins support a real business process.
A practical rollout is:
1. Review Microsoft Entra sign-in logs for device code flow and identify the owner and purpose of each use. 2. Confirm whether the tenant has a legitimate dependency and whether a safer sign-in method is available. 3. Configure a narrowly scoped Conditional Access policy in Report-only mode. 4. Review report-only results and test the workflows the business needs. 5. Enforce the policy once its impact and any required exceptions are understood. 6. Continue reviewing sign-ins and exceptions after rollout.
Microsoft's Conditional Access guidance for blocking authentication flows recommends getting as close as possible to a broad block, with documented exceptions only where needed. Conditional Access licensing and administrator-role requirements should be checked for the users and tenant in scope.
Check legitimate device use before blocking
A blanket change without an inventory can interrupt real work. Some Teams Rooms and shared Teams devices use device code flow during setup or reauthentication. Azure CLI, developer or administrative tools, and older applications can also depend on it.
Microsoft's current Teams device guidance describes a default-block approach with carefully scoped device-account exceptions and a Device Registration Service resource exclusion for relevant Teams scenarios. Exception groups should contain only approved accounts, have an identified owner, and be reviewed. Avoid broad user exclusions that would leave the flow available to more people and apps than intended.
For other tools, ask whether the workflow can move to browser-based or brokered sign-in, or use an appropriate workload identity for automation. Keep any remaining exception documented with its business purpose and review date.
What employees should do with an unexpected code
Give employees a simple rule: only enter a device code when they personally started the device setup or sign-in and understand what they are authorizing. A genuine Microsoft domain does not confirm that the request itself was expected.
If an employee already entered an unexpected code or approved the related sign-in, they should contact IT promptly using a known channel. The IT team can assess the sign-in and account, revoke access or sessions as appropriate, review account activity and follow the organisation's incident-response process. The right actions depend on the evidence and tenant configuration; don't assume that simply changing a password completes the investigation.
Questions to ask your IT provider
A focused review should establish what is configured and what the evidence shows. Ask your IT provider:
- Is device code flow currently allowed in our Microsoft Entra tenant?
- Have sign-in logs been reviewed to identify users, apps and resources that use it?
- Do any Teams devices, scripts or administrator tools rely on the flow?
- Is a Conditional Access policy available under our current licensing?
- Has the proposed policy been tested in Report-only mode?
- Are exceptions narrowly scoped, documented and reviewed?
- How would the team investigate an employee who approved an unexpected code?
The goal is not to assume the provider missed something. It is to understand whether the risk has been assessed, whether existing Microsoft capabilities are configured appropriately and what happens if a user reports an unexpected sign-in.
This may be a configuration question, not a product purchase
Some businesses are offered another security product before anyone checks the controls they already own. Device code flow is a useful example of a configuration question: the relevant protections may be available through Microsoft Entra Conditional Access, depending on licensing and the tenant's design.
A review should verify current settings, sign-in evidence, required workflows and licensing before recommending a change or purchase. Blocking a flow without understanding dependencies can cause disruption; leaving it broadly available without assessing need can preserve avoidable risk.
How Allegiance IT Advisory can help
Allegiance IT Advisory can independently review agreed Microsoft 365 and Microsoft Entra evidence, including Conditional Access policies, MFA, device-code usage, sign-in monitoring, administrator access and incident-response readiness. We can explain what is configured, what the available evidence shows, and what questions or actions to discuss with your existing provider.
This focused Microsoft 365 Security Review can be standalone or part of our Independent IT Review. Your current IT provider can continue supporting your systems.
If you want an independent view of your Microsoft 365 identity and access controls, book a 20-minute call. We can help you determine whether device-code authentication is needed, how it is controlled, and what to review next.
Check whether device-code sign-in is needed and controlled.
Allegiance IT Advisory can review the agreed Microsoft Entra settings and sign-in evidence, then explain practical next steps in plain language.
Book a 20-minute call