Description
A Conditional Access policy for All users on All resources blocks the Device code flow authentication flow. The only exceptions are documented accounts that need it on devices without a keyboard or browser, such as Microsoft Teams Rooms resource accounts, scoped to those accounts and ideally to their network location.
The Microsoft-managed policy Block device code flow satisfies this control once it is On with the same scope.
Rationale
Device code phishing needs no fake page: the user signs in on the genuine Microsoft site, passes MFA and hands the session to the attacker. Campaigns using it against Microsoft 365 are frequent, while legitimate use is rare and limited to specific devices.
Impact
Command-line tools and devices that sign in with a device code stop working: Teams Rooms and
other meeting devices, some printers, scripts using az login --use-device-code or similar.
Find them in the sign-in logs (filter Authentication protocol = Device code) and exclude
only those accounts.
Applies when
Requires: Microsoft Entra ID P1
Audit
- Sign in to the Microsoft Entra admin center (https://entra.microsoft.com) as at least a Security Reader.
- Browse to Entra ID > Conditional Access > Policies.
- Find a policy with State set to On where Users includes All users (exclusions limited to emergency access accounts and documented device accounts), Target resources includes All resources, Conditions > Authentication flows selects Device code flow, and Grant is Block access.
- Read-only alternative with Microsoft Graph PowerShell (scope
Policy.Read.All):Get-MgIdentityConditionalAccessPolicy | Where-Object { $_.Conditions.AuthenticationFlows.TransferMethods -match 'deviceCodeFlow' } | Select-Object DisplayName, State, @{n='Grant';e={$_.GrantControls.BuiltInControls}} - Fail if no such policy exists, if it is Report-only or Off, or if it excludes users or applications without a documented reason.
Remediation
- In Entra ID > Monitoring & health > Sign-in logs, filter Authentication protocol on Device code for the last 30 days and list legitimate uses.
- As at least a Conditional Access Administrator, browse to Entra ID > Conditional Access > Policies. Enable the Microsoft-managed Block device code flow policy, or select New policy.
- Users > Include: All users. Exclude: the emergency access accounts and the documented device accounts.
- Target resources > Resources > Include: All resources.
- Conditions > Authentication flows: Configure Yes, select Device code flow.
- Grant: Block access.
- Set Enable policy to Report-only, review, then switch to On.
Graph equivalent:
New-MgIdentityConditionalAccessPolicywithconditions.authenticationFlows.transferMethodsset todeviceCodeFlowandgrantControls.builtInControlsset toblock.
Rollback
Set the policy to Report-only, or exclude the account that needs device code flow.
References
- Block authentication flows with Conditional Access policy Microsoft, vendor-doc, accessed 2026-10-24
- Microsoft-managed policies Microsoft, vendor-doc, accessed 2026-10-24
- CISA SCuBA Microsoft Entra ID baseline CISA, standard, accessed 2026-10-24
Mappings
| Framework | ID | Relation |
|---|---|---|
| NIST SP 800-53 Rev. 55.1.1 | CM-7 | related |
| NIST SP 800-53 Rev. 55.1.1 | IA-2 | related |
| CISA SCuBA Microsoft 365 Secure Configuration Baselines2.0.0 | MS.AAD.3.9v1 | equivalent |
How this control relates to the other framework's: equivalent, stricter, looser, partial or related.
Threats mitigated
| Taxonomy | ID |
|---|---|
| MITRE ATT&CK | T1566.002 |
| MITRE ATT&CK | T1528 |
Related controls
- related
CB-M365-AUTH-023Block authentication transfer - related
CB-M365-ADMIN-002Keep two protected emergency access accounts - related
CB-M365-AUTH-034Keep Conditional Access policies free of broken references and unprotected exclusions
People and lifecycle
| Authors |
|
| Introduced in | v0.1.0 |
| Created, updated | 2026-10-24, 2026-10-24 |
| Translations | fr |