Device code phishing has one property that makes it nasty: the victim never visits a fake site. They type a code into the real Microsoft or GitHub sign-in page, complete their real MFA, and the sign-in quietly lands in an attacker's hands. There's no lookalike domain to spot and no proxy to block.

On November 17, Microsoft's security researchers published research applying the technique to an AI coding agent, GitHub Copilot CLI. The result is worth reading because it shows what changes when the stolen sign-in belongs to a tool that can read your code, run commands and remember things. Meanwhile, the same technique has been used at scale against Entra ID all year.

Written November 19, 2026. Details below are from Microsoft's AI coding agents research, its write-ups on EvilTokens and Storm-2372, and the Conditional Access documentation on authentication flows, as of that date.

How Device Code Phishing Works

The device code flow exists for devices that can't show a normal sign-in page - a conference room system, a smart TV, a command-line tool. The device shows a short code, you enter it on another device, sign in there, and the device gets its tokens. The attacker simply plays the part of the device:

The attacker's client requests a device code from the real sign-in service, sends the code to the victim in a lure, the victim enters it on the real sign-in page and completes MFA, and the tokens are issued to the attacker's client, which then acts as the user.
Every page the victim sees is genuine. That's the whole trick.

Two things make it hard to stop. The lure only needs to be plausible for the few minutes the code is valid. And because the victim completes their own MFA on the real page, MFA doesn't help - even phishing-resistant MFA. A passkey checks that it's talking to the real site, and it is. The problem is who ends up with the session.

What Microsoft Found With GitHub Copilot CLI

Microsoft's researchers ran this in a lab against a test account. The attacker started a GitHub device sign-in using the Copilot CLI's client, sent the code with a pretext like an IT request or a "Copilot license check", and the test user approved it on the genuine GitHub page. The attacker's client received an OAuth token with the scopes the attacker chose - in their example, repo, read:user, read:org, gist and codespace.

From there they demonstrated four outcomes:

OutcomeOnly possible when
Steer the user's live Copilot CLI session remotelyThe user turned on remote control and org policy allows it. Commands still hit the session's approval prompts and local OS permissions.
Plant misleading entries in agent memory, which can shape later answersMemory is enabled.
Read cloud-synced Copilot CLI sessions, including ones from before the compromiseSession storage in the cloud is allowed.
Read private repositories the user can accessThe user has that access - which is usually the point.

Microsoft is careful to say these are proof-of-concept results, not attacks seen in the wild, and that remote steering is "not unauthenticated remote code execution". It also stresses the technique isn't specific to Copilot CLI: any public client that supports device flow can be abused the same way.

My take: agents are a new place for sensitive data to pile up

Private repo access is the obvious loss, and it isn't new - any stolen GitHub token gets you that. The agent-specific outcomes are what I'd pay attention to:

It's Already Happening in Entra ID

The GitHub scenario is a lab result. Device code phishing against Microsoft 365 is not:

The PRT step is why I treat a successful device code phish as more than a mailbox compromise. Revoking sessions doesn't unregister a device: an attacker-registered device stays in your directory, looking like a legitimate endpoint, until someone finds it and removes it.

Two separate doors. Entra Conditional Access controls sign-ins to Entra ID. GitHub's device flow is GitHub's own sign-in, and nothing in Microsoft's research says an Entra policy blocks it. Blocking device code flow in Entra closes the Microsoft 365 door; the GitHub door needs GitHub-side controls. You need both.

What I'd Do in Entra ID

1. Find out who actually uses device code flow

In the Entra admin center, filter the sign-in logs on Authentication protocol: Device code. If you send sign-in logs to Log Analytics or Sentinel:

SigninLogs | where TimeGenerated > ago(30d) | where AuthenticationProtocol == "deviceCode" | summarize SignIns = count(), Users = dcount(UserPrincipalName), FirstSeen = min(TimeGenerated), LastSeen = max(TimeGenerated) by AppDisplayName, ResultType | sort by SignIns desc

The list is usually short - typically a few admins running Azure CLI or PowerShell on a machine without a browser, and some meeting-room devices. That short list is your exclusion list.

2. Block it with Conditional Access

This needs Entra ID P1. Create a policy:

Microsoft's own guidance is to get "as close as possible to a unilateral block". Two behaviors to know before you flip it on:

3. Watch for the PRT play

A device registration shortly after a device code sign-in, for the same user, is worth an alert. Something like this (check the activity name against your own audit log):

let dc = SigninLogs | where TimeGenerated > ago(14d) | where AuthenticationProtocol == "deviceCode" and ResultType == "0" | project DcTime = TimeGenerated, UserPrincipalName, IPAddress, AppDisplayName; AuditLogs | where TimeGenerated > ago(14d) and OperationName == "Register device" | extend UserPrincipalName = tostring(InitiatedBy.user.userPrincipalName) | join kind=inner dc on UserPrincipalName | where TimeGenerated between (DcTime .. (DcTime + 1h)) | project DcTime, RegisteredAt = TimeGenerated, UserPrincipalName, IPAddress, AppDisplayName, Device = tostring(TargetResources[0].displayName)

Defender for Identity also has an "Anomalous OAuth device code authentication activity" detection if you're licensed for it.

4. Know your response before you need it

Revoking sessions (revokeSignInSessions) kills refresh tokens, but Microsoft notes access tokens can stay valid for up to an hour. So disable the account while you work, revoke sessions, and then check for devices registered to the user around the time of the sign-in - delete or disable any you don't recognize. Then the usual: inbox rules, mail forwarding, app consents and anything sent from the account.

What I'd Do for GitHub and AI Agents

These come from Microsoft's recommendations, in the order I'd do them:

  1. Teach one rule: only enter a device code for a sign-in you started, on a device in front of you. An unexpected "verify your Copilot license" is phishing even though the page is really github.com. This is the only control that works for every app.
  2. Turn down cloud session storage. For organization seats, review the Copilot CLI policy for storing local sessions in the cloud, and pick the least permissive setting you can live with. Leave remote control off unless someone needs it.
  3. Clean up agent memory. Review Copilot Memory entries. Disabling memory doesn't delete what's already there.
  4. Review authorized OAuth apps on developer accounts and revoke anything unexpected. Keep private repo access scoped through org roles, so one token doesn't reach everything.
  5. Get visibility. Connect GitHub Enterprise Cloud to Defender for Cloud Apps. Microsoft's two new Defender XDR detections - Copilot CLI device code phishing via email and via Teams - depend on it. With Enterprise Managed Users, Microsoft also describes suspending the user through the identity provider as a disruption step.
  6. Turn on Safe Links for email and Teams, since both lures in Microsoft's detections arrive that way.

The Bottom Line

Device code phishing beats MFA because it doesn't fight it; it borrows it. In Entra ID you can mostly make the problem go away: measure who uses device code flow, exclude those few, block it for everyone else and watch for device registrations. On the GitHub and AI agent side there's no single switch yet, so it comes down to user habits and to limiting what a stolen token can reach - less session history in the cloud, less memory, narrower repo access. And when you build your next AI tool rollout, ask early which sign-in flow it uses. If the answer is "device code", plan for it being phished.