Device code phishing has no fake login page to take down. The victim goes to the real Microsoft or GitHub verification page, types a short code, signs in with their real MFA, and the attacker's client receives the tokens. URL reputation, lookalike-domain detection and AiTM proxy indicators all come back clean, because the authentication itself is legitimate. What gives it away is the protocol: a device code grant for a user who has no reason to use one, followed by token activity from somewhere the user isn't.

This post covers how the technique has changed in 2026, how to detect it in Entra ID sign-in logs, the Conditional Access control that removes it, and what Microsoft's November research on GitHub Copilot CLI means for developer accounts.

Weekly Intelligence Pack · $14.99/mo
A new production detection rule every Tuesday — CrowdStrike, Sentinel, or Splunk
Real incident case study, hunt hypothesis, career tip. Direct Q&A support included.
Join — $14.99/mo →

Why device code phishing works

The OAuth device authorization grant exists for devices without a usable browser: TVs, conference room systems, command-line tools. The device asks the identity provider for a code, shows it to the user, and polls until someone enters that code on a verification page from another device and signs in. The provider then issues tokens to whichever client started the request.

The attacker simply plays the device. They start the flow, send the code to the victim with a pretext, and poll. The victim sees a genuine Microsoft or GitHub page, completes genuine MFA, and approves a request they didn't start. Nothing in the victim's experience looks wrong unless they know that they should only ever enter a code for a sign-in they started themselves.

What changed in 2026

The classic weakness of the technique was timing. A device code is only valid for 15 minutes, so a code generated when the email was sent was usually dead by the time the victim opened it. Microsoft's April 2026 analysis of a campaign aligned with the EvilTokens phishing-as-a-service kit describes how that was solved:

Lures were document sharing, e-signature requests, voicemail notifications, invoices and password expiry notices. Microsoft says in its November 17 post that it disrupted EvilTokens with partners in September. Kits get rebuilt, and the technique doesn't depend on any one of them.

The GitHub Copilot CLI variant

Microsoft's November research applies the same idea to developers. GitHub also supports the OAuth device flow, and AI coding agents like GitHub Copilot CLI use it to sign in. In a lab, Microsoft researchers started a device flow with the Copilot CLI's public client identifier, sent the code to a test user as an "IT request" or Copilot licence check, and received a token when the user approved it on GitHub's own verification page. The requested scopes included repo, read:org, gist and codespace.

With that token, depending on account permissions and enabled features, the researchers could read private repositories, read synced Copilot CLI session history where cloud session storage was enabled, add misleading entries to the agent's memory that could influence later sessions, and, where remote control was enabled and a session was running, steer the user's active Copilot CLI session to run commands on their machine, still subject to the session's approval prompts.

Research, not a campaign

Microsoft is explicit that these are proof-of-concept results and that it hasn't observed them in the wild. Treat them as a forecast: the delivery technique is already mass-market, and developer accounts with access to source code and agent sessions are an obvious next target.

Detection 1: Device code sign-ins in Entra ID

Entra ID records the grant type in the AuthenticationProtocol column of SigninLogs, with the value deviceCode. In most organizations, legitimate device code use is concentrated in a few places: Teams Rooms and other shared devices, some admin tooling, the Azure CLI on headless systems. Start by finding out what yours looks like.

Sentinel KQL — Baseline: who uses device code flow, from where, for which apps
let lookback = 30d;
SigninLogs
| where TimeGenerated > ago(lookback)
| where AuthenticationProtocol == "deviceCode"
| summarize SignIns = count(), Successes = countif(ResultType == "0"), IPs = dcount(IPAddress),
    Apps = make_set(AppDisplayName, 10), Resources = make_set(ResourceDisplayName, 10),
    FirstSeen = min(TimeGenerated), LastSeen = max(TimeGenerated)
    by UserPrincipalName
| order by SignIns desc

That list is your exclusion list for the Conditional Access policy later, and your allowlist for the alert below. For most users the right number of device code sign-ins is zero. Once you know which accounts legitimately use it, alert on everyone else:

Sentinel KQL — Successful device code sign-ins by users outside the known device code population
let lookback = 1d;
let baseline = 30d;
let known_users = SigninLogs
    | where TimeGenerated between (ago(baseline) .. ago(lookback))
    | where AuthenticationProtocol == "deviceCode" and ResultType == "0"
    | distinct UserPrincipalName;
SigninLogs
| where TimeGenerated > ago(lookback)
| where AuthenticationProtocol == "deviceCode" and ResultType == "0"
| where UserPrincipalName !in (known_users)
| project TimeGenerated, UserPrincipalName, AppDisplayName, ResourceDisplayName, IPAddress, Location,
    UserAgent, ConditionalAccessStatus, RiskLevelDuringSignIn, SessionId, CorrelationId
| order by TimeGenerated desc

False positives are a user's genuine first use of a tool that needs device code, such as a developer setting up the Azure CLI on a remote box. The IPAddress and Location columns usually settle it: in a phish, the sign-in that completes the grant comes from the victim's normal location, but the tokens are then used from the attacker's infrastructure. That's why the next query matters more.

Detection 2: The grant from one place, the tokens used from another

The victim approves the request from their usual network. The attacker's client then redeems and refreshes tokens from its own. Entra ID tracks sessions that started with a device code grant, and the OriginalTransferMethod column records the transfer method used to start a session through all its later requests. Rather than assume the exact value string your tenant writes, this query takes any session that started with a device code sign-in and compares the IPs that session's later non-interactive sign-ins come from.

Sentinel KQL — Device code sessions whose later token activity comes from new IPs
let lookback = 2d;
let dc = SigninLogs
    | where TimeGenerated > ago(lookback)
    | where AuthenticationProtocol == "deviceCode" and ResultType == "0"
    | project GrantTime = TimeGenerated, UserPrincipalName, SessionId, GrantIP = IPAddress, GrantApp = AppDisplayName;
dc
| join kind=inner (
    AADNonInteractiveUserSignInLogs
    | where TimeGenerated > ago(lookback)
    | where ResultType == "0"
    | project TokenTime = TimeGenerated, SessionId, TokenIP = IPAddress, ResourceDisplayName,
        UserAgent, OriginalTransferMethod
    ) on SessionId
| where TokenTime between (GrantTime .. (GrantTime + 1d))
| where TokenIP != GrantIP
| summarize TokenIPs = make_set(TokenIP, 20), Resources = make_set(ResourceDisplayName, 20),
    TransferMethods = make_set(OriginalTransferMethod, 5), UserAgents = make_set(UserAgent, 5),
    FirstUse = min(TokenTime)
    by UserPrincipalName, GrantTime, GrantIP, GrantApp, SessionId
| order by GrantTime desc

Mobile users switching between Wi-Fi and cellular will produce different IPs on legitimate sessions, so review the TokenIPs by owner: a residential or mobile carrier range looks like the user moving, while a hosting or cloud provider range looks like the attacker's poller. Run TransferMethods once to see the exact values your tenant records, and you can then filter directly on it. Note that this query hasn't been tested against live data in every tenant configuration, and very short-lived attacks that only use the first access token won't produce non-interactive sign-ins at all.

Detection 3: Device registration and inbox rules after a device code grant

Microsoft saw new device registrations within minutes of compromise, used to get a Primary Refresh Token that outlives the original session. Device registration shows up in AuditLogs. Correlate it with device code sign-ins for the same user:

Sentinel KQL — Device registered within 1 hour of a device code sign-in by the same user
let lookback = 7d;
let dc = SigninLogs
    | where TimeGenerated > ago(lookback)
    | where AuthenticationProtocol == "deviceCode" and ResultType == "0"
    | project GrantTime = TimeGenerated, UserPrincipalName, GrantIP = IPAddress;
AuditLogs
| where TimeGenerated > ago(lookback)
| where OperationName == "Register device"
| extend Actor = tostring(InitiatedBy.user.userPrincipalName),
    DeviceName = tostring(TargetResources[0].displayName)
| join kind=inner dc on $left.Actor == $right.UserPrincipalName
| where TimeGenerated between (GrantTime .. (GrantTime + 1h))
| project GrantTime, RegisteredAt = TimeGenerated, UserPrincipalName, GrantIP, DeviceName, Result
| order by GrantTime desc

This one has very few false positives, because a user legitimately registering a new device straight after a device code sign-in is unusual outside a desk-side setup. Extend the same join to inbox rule creation and mail access in your Exchange audit data for the delayed-action pattern Microsoft described. Microsoft also lists Defender detections that cover this campaign, including "Suspicious Azure authentication through possible device code phishing", "User account compromise via OAuth device code phishing" and Defender for Identity's "Anomalous OAuth device code authentication activity"; make sure they aren't disabled or auto-closed in your tenant.

Detection 4: The GitHub side

GitHub's OAuth device flow doesn't produce an Entra ID sign-in, so none of the queries above see it. Microsoft's two new detections, "Suspected GitHub Copilot CLI device code phishing via email" and "via Microsoft Teams", correlate message clicks with GitHub OAuth token events and need the GitHub Enterprise Cloud connector in Defender for Cloud Apps. If you run GitHub Enterprise Cloud and Defender, connect it.

Outside Defender, the GitHub Enterprise Cloud audit log doesn't list the per-user OAuth authorization events; those appear in each user's own security log as oauth_authorization.create. What the enterprise log does record, per GitHub's event reference, is OAuth app access requests and approvals for your organizations and credential authorizations for SAML or OIDC single sign-on. If you stream the audit log to Splunk, review those for unexpected apps and bursts:

Splunk SPL — GitHub org OAuth app access and SSO credential authorizations
index=github earliest=-30d
    action IN ("org.oauth_app_access_requested", "org.oauth_app_access_approved", "org_credential_authorization.grant")
| eval app=coalesce(oauth_application_name, application_name)
| stats count min(_time) as first max(_time) as last values(action) as actions values(org) as orgs by actor, app
| convert ctime(first) ctime(last)
| sort - last

Field names follow GitHub's documented audit log schema; adjust index and any renamed fields to match your ingestion, and treat this as a hunt rather than a tested alert. A credential authorization for a coding agent app by a user who doesn't hold a Copilot seat, or many authorizations in a short window, is worth a conversation with the user.

Shut it off: Conditional Access authentication flows

Detection is the backstop. The fix is a Conditional Access policy using the authentication flows condition, which Microsoft describes as covering device code flow and authentication transfer. Microsoft's guidance is to block device code flow wherever possible.

  1. Use Detection 1 to build the exception list. Typically shared devices like Teams Rooms, some admin tooling, and specific service scenarios. Scope exceptions narrowly: Microsoft's own example policy blocks device code everywhere except Android devices in a specific network location.
  2. Deploy in report-only mode first and review what it would have blocked for a week or two.
  3. Exclude Device Registration Service if the policy targets all resources. Microsoft enforces authentication flows policies on it; exclude it in the portal or by client ID 01cb2876-7ebd-4aa4-9cc9-d28bd4d359a9 through the API.
  4. Enforce, and expect AADSTS530036. Sessions that started with a device code grant are protocol tracked, so refresh attempts from those sessions get blocked too. That's intended, and it also cuts off attacker sessions established before enforcement.

For GitHub, the controls are narrower. Review the Copilot CLI organization policy for storing local sessions in the cloud and choose the least permissive setting your developers can live with, keep remote control off unless it's needed, limit repository access with organization roles, and use Safe Links for email and Teams so Microsoft's correlation detections have click data to work with.

Response

  1. Revoke sessions and disable the account. Revoke refresh tokens with revokeSignInSessions. Microsoft notes that access tokens already issued can remain valid for up to an hour, so disable the account temporarily as well rather than relying on a password reset.
  2. Remove what the attacker added. Devices registered after the grant, inbox rules, forwarding settings, MFA methods and any OAuth consents.
  3. Scope the data access. Review mail and file access and Graph activity from the attacker IPs in Detection 2 for the whole period between the grant and revocation.
  4. For GitHub accounts, revoke the unexpected OAuth authorization, confirm access is actually blocked, then review repositories accessed, Copilot CLI session history and the agent's saved memory. Disabling memory doesn't delete existing entries, so remove suspicious ones explicitly.

Device code phishing succeeds because every component the user sees is genuine. That makes it a protocol problem rather than a content problem, and protocol problems have clean fixes: know who needs the grant, block it for everyone else, and alert when it shows up anyway. Do the Entra side this week. For GitHub, assume the same lure is coming for your developers and their agents, and make sure a stolen token there can reach as little as possible.

Weekly Intelligence Pack
Production detections like these, every Tuesday

Every issue includes a full detection rule for Sentinel, CrowdStrike or Splunk, with investigation steps, false positive guidance and MITRE mapping. Platforms rotate so you get broad coverage over time.

Join — $14.99/mo See a Sample Issue
Founding member pricing locked for life · 30-day money back