AI Security
Device Code Phishing: The AI Coding Agent Risk
Codesprint Consulting
By,Codesprint Consulting
  • 18 November 2026

Device code phishing tricks someone into approving a sign-in they did not start, and Microsoft describes it as a recurring route to account takeover. On November 17, 2026, Microsoft Security Research published a simulation asking a sharper question: what happens when the approval lands on an AI coding agent instead of a mailbox? Using GitHub Copilot CLI as an illustrative example, its researchers showed that one phished authorization could reach private repositories, cloud-synced sessions and agent memory, and, under specific settings, allow an active session on the user's machine to be steered remotely. Microsoft stresses these are proof-of-concept results from a controlled lab, not attacks observed in the wild. They still reset what a single approval can cost. Source: The risks of device code authentication for AI coding agents, Microsoft Security Blog

What the device code flow is

The OAuth device flow exists so tools without a full browser, such as command-line applications, can sign a user in. The client requests a short code, the user enters that code on the service's verification page, and the requesting client receives access after approval. GitHub's documentation describes this device flow as the sign-in route for headless applications such as CLI tools and the Git Credential Manager. Source: Authorizing OAuth apps, GitHub Docs

That convenience carries a cost when an approval is phished. GitHub says that when an app uses expiring access tokens, the access token expires after eight hours and the refresh token expires after six months without use. A stolen token is therefore not a momentary leak; it can act as a standing credential that an attacker refreshes quietly. Source: Authorizing OAuth apps, GitHub Docs

Microsoft Entra's own documentation classifies the device code flow as a high-risk authentication method that can be part of a phishing attack or used to reach corporate resources from unmanaged devices. Its recommendation is direct: allow the flow only where necessary and block it wherever possible. When the vendor maintaining the identity platform says that about its own flow, defenders should treat the default as exposure, not convenience. Source: Authentication flows, Microsoft Learn

How a device code phishing attack unfolds

Microsoft's researchers break the attack into five steps. The attacker initiates a device-code sign-in request using a public client identifier, which is not a secret, and chooses the requested scopes at that moment. The attacker then sends the short code and the verification link to the target under a pretext, such as an IT request or a Copilot license check. Source: The risks of device code authentication for AI coding agents, Microsoft Security Blog

The victim opens the verification page, which is genuinely hosted by the service, signs in if needed, and approves the request. The attacker-controlled client completes the sign-in automatically and can then operate within the permissions granted to the application and the resources available to the affected account. The uncomfortable detail is that the legitimate domain proves nothing: the page being real does not establish who initiated the request. Source: The risks of device code authentication for AI coding agents, Microsoft Security Blog

Why an AI coding agent raises the stakes

In the controlled simulation, a victim test account approved a GitHub device-code request initiated by an attacker-controlled client. From that single approval, the researchers analyzed four possible outcomes: steering an active Copilot CLI session remotely, where the user has enabled remote control and organization policy allows it, and, subject to local permissions and approval settings, having the agent run commands on the user's machine; adding misleading entries to the agent's memory that could influence later interactions; reading Copilot CLI sessions synchronized to the cloud; and accessing private repositories available to the affected account. Source: The risks of device code authentication for AI coding agents, Microsoft Security Blog

Two qualifiers matter. First, each outcome requires the victim to approve a device-code request the attacker initiated, and each depends on account permissions and enabled features. Second, Microsoft says it has not observed these four outcomes in the wild. The technique itself is not specific to GitHub or Copilot CLI: any public client that supports the device flow can be abused the same way. Source: The risks of device code authentication for AI coding agents, Microsoft Security Blog

The reason this research lands is structural. A coding agent is not a mailbox. It can hold repository access, session history, memory about a codebase and, depending on configuration, the ability to act on a developer's machine. As Microsoft puts it, the impact of a phished authorization increasingly depends on what those agents can reach. Source: The risks of device code authentication for AI coding agents, Microsoft Security Blog

Device code phishing is already a working playbook

The AI angle is new; the technique is not. In February 2025, Microsoft reported that a group it tracks as Storm-2372 had run device code phishing campaigns since at least August 2024, targeting governments, NGOs, IT services, defense, telecommunications, health, higher education, and energy organizations across Europe, North America, Africa and the Middle East. Microsoft assesses with moderate confidence that Storm-2372 aligns with Russia's interests and tradecraft. Source: Storm-2372 conducts device code phishing campaign, Microsoft Security Blog

Storm-2372 built rapport over messaging apps including WhatsApp, Signal and Microsoft Teams, then sent fake meeting invitations carrying an actor-generated device code. Approving the request handed the group access and refresh tokens, which it used for Microsoft Graph API data collection such as email harvesting, and the access persisted while the tokens remained valid. Microsoft also observed the group registering devices inside compromised tenants and using proxies that matched each target's region, two touches that make sign-in activity look ordinary. Separately, Microsoft reported working with industry partners and law enforcement to disrupt another device-code operation, EvilTokens, in September 2026, and it describes Storm-2372 as an AI-enabled campaign. The pattern across these campaigns is consistency: the lure changes, the approval step does not. Source: Storm-2372 conducts device code phishing campaign, Microsoft Security Blog

How to reduce the exposure

The first control is a habit, and it costs nothing. Approve a device code only for a sign-in you initiated yourself. Microsoft's guidance says an unexpected request to verify GitHub or activate Copilot should be treated as a phishing attempt even when the page is hosted on the real domain, and GitHub's own verification page warns users never to use a code sent by someone else. Source: The risks of device code authentication for AI coding agents, Microsoft Security Blog

The second control is administrative. Microsoft Entra Conditional Access can target authentication flows explicitly, and Microsoft recommends blocking the device code flow wherever possible, allowing it only where necessary, for example only for specific devices in a named network location. For organizations whose developers sign in with work identities, this turns a user-awareness problem into a policy decision. Source: Authentication flows, Microsoft Learn

The third control is hygiene around the agent itself. Microsoft advises reviewing authorized OAuth applications in GitHub account settings and revoking unexpected ones, limiting repository access through organization roles, choosing the least permissive Copilot CLI session policy that supports the work, and reviewing stored Copilot Memory entries, because disabling memory does not delete what is already saved. Source: The risks of device code authentication for AI coding agents, Microsoft Security Blog

Microsoft also recommends configuring Safe Links policies in Defender for Office 365 for email and verifying Safe Links protection for Teams. These protections help with malicious links and add investigation context, though a legitimate verification URL still requires the user to recognize an unsolicited code request. For organizations on GitHub Enterprise Cloud, connecting it to Defender for Cloud Apps adds the activity visibility that investigations depend on. Source: The risks of device code authentication for AI coding agents, Microsoft Security Blog

On detection, Microsoft says it developed two Defender XDR detections for suspected Copilot CLI device code phishing delivered through email and through Teams, correlating suspicious messages and clicks with GitHub OAuth token creation and regeneration events. It also validated a disruption action for GitHub Enterprise Managed Users that suspends the affected managed identity through the organization's identity provider. Availability of these capabilities depends on configuration, telemetry, identity integration and deployment prerequisites, so verify them in your own tenant rather than assuming coverage. Source: The risks of device code authentication for AI coding agents, Microsoft Security Blog

Our read: treat every agent sign-in as an attack surface

Our assessment is that this research changes the question security teams ask about device code phishing. The old question was which mailbox or files a phished token could open. The new question is which repositories, sessions, memories and machine actions a phished token can inherit from the agent holding it. Teams adopting coding agents should review OAuth grants, session policies and memory settings as one surface, and fold the flow into conditional access decisions now, while the observed campaigns still target conventional accounts. If you want a second pair of eyes on that review, our cyber security service covers assessing identity and access exposure and agreeing the hardening work. A research blog cannot scope that work for your environment; an assessment can.

FAQ

Device code phishing is an attack where the attacker starts an OAuth device flow sign-in and persuades someone else to approve it. The approval happens on the service's real verification page, but the client that receives access belongs to the attacker, who also chooses the requested scopes. Source: The risks of device code authentication for AI coding agents, Microsoft Security Blog

No. Microsoft used Copilot CLI as an illustrative example and states that any public client supporting the device flow can be abused the same way. The phishing technique itself is not specific to GitHub. Source: The risks of device code authentication for AI coding agents, Microsoft Security Blog

No. Microsoft describes the four outcomes as proof-of-concept results from a controlled lab simulation, not attacks observed in the wild. Device code phishing itself is an observed technique, documented in campaigns such as Storm-2372. Source: Storm-2372 conducts device code phishing campaign, Microsoft Security Blog

Yes. Microsoft Entra Conditional Access lets administrators explicitly target the device code flow, and Microsoft recommends blocking it wherever possible and allowing it only where necessary. Source: Authentication flows, Microsoft Learn

Review the authorized OAuth applications in the account settings and revoke anything unexpected, then report the attempt so responders can investigate sessions, repositories and saved memory. Microsoft says responders should verify that access is blocked and review potentially affected sessions. Source: The risks of device code authentication for AI coding agents, Microsoft Security Blog

Tag:
  • device code phishing
  • ai coding agents
  • oauth security
  • github copilot cli
  • account takeover

Have a project in mind? Let's talk.

Drop Us a Line

Connect with Codesprint Consulting

Ready to take the first step towards unlocking opportunities, realizing goals, and embracing innovation? We're here and eager to connect.

Your Success Starts Here!