# Block Device Code Flow

Octiga documentation > Baselines > Conditional Access Policy > Block Device Code Flow
URL: https://docs.octiga.io/baselines/conditional-access-policy/cap-block-device-code-flow/

Scope: Tenant · Role: L1 Read to view · L1 Read/Write to act · Surface: Microsoft Graph · Licence: Entra ID P1 or P2

This Conditional Access Policy blocks the device code authentication flow. The flow is legitimate — it exists for devices with no keyboard or browser — but it is ideally shaped for phishing: an attacker starts the flow, sends the victim a code, and the victim enters it on the genuine Microsoft sign-in page, completing MFA themselves while the resulting tokens go to the attacker. Microsoft classifies it as a high-risk authentication flow and recommends blocking it wherever it is not needed. Exclude Teams device resource accounts and the Device Registration Service so device enrolment keeps working.

## Settings this baseline controls

| Setting              | What it does                                                                                                                                                                           |
| -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Display Name         | Specifies a display name for the Conditional Access Policy                                                                                                                             |
| State                | Specifies the state of the conditional Access Policy. Possible values are: enabled, disabled, enabledForReportingButNotEnforced. Required.                                             |
| Transfer Methods     | The authentication flow the policy applies to. Set to deviceCodeFlow to block device code authentication.                                                                              |
| Include Users        | User IDs in scope of policy                                                                                                                                                            |
| Exclude Users        | User IDs excluded from scope of policy. Exclude Teams device resource accounts, which legitimately rely on device code flow.                                                           |
| Exclude Groups       | Group IDs excluded from scope of policy. Commonly used to exclude a group of Teams device resource accounts.                                                                           |
| Include Applications | Applications in scope of policy                                                                                                                                                        |
| Exclude Applications | Applications excluded from scope of policy. Exclude the Device Registration Service so device enrolment continues to work.                                                             |
| Built In Controls    | List of values of built-in controls required by the policy. Possible values: block, mfa, compliantDevice, domainJoinedDevice, compliantApplication, passwordChange, unknownFutureValue |

Learn more: <https://learn.microsoft.com/en-us/entra/identity/conditional-access/policy-block-authentication-flows>

[Adding a baseline](https://docs.octiga.io/baselines/adding-a-baseline/) — Add, configure or remove a single baseline on a tenant, a user or a group, without deploying a whole scheme.

## Configure it

Add this baseline to check that the device code flow is blocked everywhere the tenant doesn't need it. The flow lets a device with no keyboard or browser, such as a meeting-room panel or a command-line tool, sign in by showing a code that someone enters on another device. Attackers abuse it for phishing: they start the flow and send the victim the code, and the victim enters it on Microsoft's real sign-in page and completes MFA while the tokens go to the attacker's device. Microsoft classifies it as a high-risk authentication flow.

1. **Add the baseline.** Add it to the tenant (see [Adding a baseline](https://docs.octiga.io/baselines/adding-a-baseline/)), or to a scheme you deploy to every tenant you manage (see [Creating a scheme](https://docs.octiga.io/baselines/creating-a-scheme/) and [Deploying a scheme](https://docs.octiga.io/baselines/deploying-a-scheme/)). Its settings are fixed, so there's nothing to set on it in Octiga: a policy named CAP012 - Block Device Code Flow, enabled, that blocks the device code flow for all users and all resources. The settings table above lists them.
2. **Check what still needs the flow.** Teams Rooms, Teams panels and other shared Teams devices use it to sign in and to register. Microsoft's guidance for those is to exclude the devices' resource accounts (or a group of them) and the Device Registration Service from the policy, so they keep working.
3. **Create the policy in Microsoft Entra.** In the Microsoft Entra admin centre, create a policy named CAP012 - Block Device Code Flow that blocks the device code flow for all users and all resources. Exclude your emergency access accounts, as Microsoft recommends for every blocking policy, and any Teams device resource accounts and the Device Registration Service from step 2. Octiga finds the policy by its name and doesn't check its exclusions.

> **Caution:** Remediation writes the policy from the baseline: enabled, not in report-only, and with no user, group or role exclusions, so it would drop the account and group exclusions from step 3. Leave **Auto** off for this baseline and fix any deviation in Microsoft Entra rather than remediating it.

> **Licence: Entra ID P1 or P2:** Microsoft offers Conditional Access only on tenants with Entra ID P1 or P2, so this baseline needs one of them on the tenant. See [Licence requirements](https://docs.octiga.io/reference/licence-requirements/).

## Check it worked

Open CAP012 - Block Device Code Flow in the Microsoft Entra admin centre under **Entra ID > Conditional Access > Policies**. It should be on, cover all users and all resources, list the device code flow under its authentication flows (authentication transfer may be listed too), and block access.

Sign-ins that use the device code flow are refused, such as signing in to a command-line tool with a code, or a shared device that isn't excluded. Every other sign-in carries on as before.

**Doing this for every tenant?** Step through the deploy wizard to apply a scheme to a tenant, groups or users, and see what Managed and Direct do at deploy time. [Deploying a scheme](https://docs.octiga.io/baselines/deploying-a-scheme/)
