Skip to content

Device Code Phishing Blocker

Build the Conditional Access policy that blocks device code flow in Microsoft Entra ID: the Microsoft Graph JSON, the same policy as admin center steps, KQL hunting queries for device code sign-ins and a warning for staff. Then check a sign-in log export for device code use you cannot explain. Runs in your browser. Nothing you paste is sent to PlayCISO.

Runs in your browser. Nothing you paste is sent to PlayCISO. Account IDs, group IDs and sign-in logs stay in this tab. Your form choices are remembered in this browser only.

1. Your tenant

Microsoft Entra ID P1 (or Microsoft 365 Business Premium)?

Conditional Access needs it.

Start in

Optional: check a sign-in log export

In the Entra admin center, open the sign-in logs, filter Authentication Protocol to Device code (or leave it unfiltered to compare countries), then Download as CSV or JSON. Paste it here or upload the file. Device code sign-ins are found by the authentication protocol or original transfer method fields.

Loading…

Sample report · illustrative data

Sample report: blocking device code flow at a 400-seat firm

Entered: Entra ID P1 = yes, one break-glass account, a "Meeting room devices" exception group, report-only mode, and a 7-day sign-in log export.

Policy built

Request
POST /v1.0/identity/conditionalAccess/policies
Condition
authenticationFlows.transferMethods = deviceCodeFlow
Users
All users, minus 1 break-glass account and the exception group
Resources
All resources
Grant
Block access
State
enabledForReportingButNotEnforced (report-only)

Device code sign-ins found in the export

Time (UTC)UserAppLocationResultReview
18 Nov 09:14dana.lee@Microsoft Authentication BrokerLagos, NGSuccessNot an expected user; country not seen in her other sign-ins
18 Nov 11:30priya.nair@Microsoft OfficeAmsterdam, NLFailureNot an expected user; country not seen before
18 Nov 10:05room4@Microsoft TeamsSydney, AUSuccessExpected user (meeting room)
17 Nov 22:41sam.ortiz@Microsoft Azure CLIMelbourne, AUSuccessExpected user (CLI admin)

Next steps

  • Revoke Dana Lee's sessions and refresh tokens now, then check mailbox rules, app consents and file access since 09:14.
  • Run the "phishing email then device code sign-in" KQL for the last 14 days to find anyone else.
  • Leave the policy in report-only for a week, check which sign-ins it would have blocked, then switch it On.
  • Send the "never enter a code someone sent you" message to all staff, finance first.

Made-up example data. Your own run uses your inputs. Downloads of the full report need Pro.

TL;DR

What this tool is

5 points
  • Device code phishing gets a person to type an attacker's sign-in code into Microsoft's real device sign-in page. They complete MFA, and the attacker's client receives the tokens.
  • Microsoft recommends blocking device code flow wherever possible, with a Conditional Access policy that uses the Authentication flows condition.
  • This tool builds that policy as a Microsoft Graph request body (transferMethods "deviceCodeFlow", grant "block", report-only or on), with your break-glass accounts and exception group excluded.
  • It also writes the matching Entra admin center steps, four KQL hunting queries for Microsoft Sentinel, and a short warning for staff.
  • Optional: paste or upload an Entra sign-in log export (CSV or JSON) to list device code sign-ins and flag unexpected users and new countries. Runs in your browser. Nothing you paste is sent to PlayCISO.

How device code phishing works

The device code flow lets you sign in on something without a proper keyboard or browser: a TV, a meeting-room screen, a command-line tool. The device shows a short code, and you enter it on Microsoft's sign-in page on another device. An attacker can start that flow themselves and send the code to a victim inside a lure, such as a "payment advice" or a shared document. The victim enters it on the real Microsoft page and completes MFA, and Microsoft issues tokens to the attacker. Microsoft calls device code flow a high-risk authentication method that can be part of a phishing attack, and recommends blocking it wherever possible. Our news post on the November 2026 payment-themed campaigns has the details.

What the policy does

  • Condition: authenticationFlows.transferMethods = deviceCodeFlow, the Graph form of Conditions > Authentication flows > Device code flow.
  • Scope: all users and all resources, minus break-glass accounts and an exception group for the devices and admins that really need device code.
  • Control: block access, starting as enabledForReportingButNotEnforced (report-only) so you can see what it would block.
  • Protocol tracking: a session that began with device code stays marked, so once the policy is on, its later token refreshes are blocked too. Expect some signed-in devices to need a fresh sign-in.

Device registration: since September 2024 Microsoft enforces authentication flows policies that target all resources on the Device Registration Service too. If you register devices with device code, exclude that app (the tool adds its client ID when you tick the box).

Microsoft facts on this page come from Microsoft Learn, read 2026-11-20: Block authentication flows, Authentication flows condition, conditionalAccessAuthenticationFlows, SigninLogs and Conditional Access licensing. PlayCISO is not affiliated with Microsoft.

Frequently asked questions

How do I block device code flow in Microsoft Entra ID?

Create a Conditional Access policy in the Microsoft Entra admin center (Entra ID > Conditional Access > Policies > New policy). Include all users, exclude your emergency access accounts, target all resources, set Conditions > Authentication flows > Configure to Yes and select Device code flow, then set Grant to Block access. Microsoft advises creating it in report-only mode first, checking the impact, then switching it on. Through Microsoft Graph the same policy is a POST to /identity/conditionalAccess/policies with conditions.authenticationFlows.transferMethods set to deviceCodeFlow.

What licence do I need to block device code flow?

Conditional Access needs Microsoft Entra ID P1 licences. Microsoft also states that customers with Microsoft 365 Business Premium can use Conditional Access.

Does MFA stop device code phishing?

Not on its own. The victim signs in and completes MFA on Microsoft's genuine page, for a sign-in the attacker started, so the attacker's client is issued valid tokens. Blocking the flow where it is not needed, and teaching people never to enter a code someone sent them, are the controls that address it.

How do I find device code sign-ins in the Entra sign-in logs?

In the admin center, filter the sign-in logs by Authentication Protocol = Device code. In Microsoft Sentinel or Log Analytics, query SigninLogs and AADNonInteractiveUserSignInLogs where AuthenticationProtocol == "deviceCode". The OriginalTransferMethod field shows sessions that began with device code even when later token refreshes used another flow. The Defender XDR EntraIdSignInEvents table has no authentication protocol column, so use the Entra tables for this hunt.

What about meeting-room devices and the Azure CLI?

Device code flow exists for devices without a keyboard or browser, such as shared screens and digital signage, and for command-line tools: `az login --use-device-code` forces it in the Azure CLI. Put the accounts that genuinely need it in a group, exclude that group from the policy, and audit it. Microsoft's example is allowing device code only for specific devices in a specific network location.

What is authentication transfer, and should I block it too?

Authentication transfer lets a user move their signed-in state from a PC to a phone, for example by scanning a QR code shown in desktop Outlook. It is a separate option in the same Authentication flows condition. Microsoft suggests blocking it if you do not want users moving sign-ins to mobile devices, for instance when Outlook on personal devices is not allowed. This tool builds it as a second, separate policy.

The tools people use most on PlayCISO.

All tools