Device code phishing has become a recurring route to account takeover. Instead of stealing a password, an attacker persuades someone to approve a sign-in on a legitimate site simply by entering a code. The resulting access often can reach email, files, or other cloud services, depending on the account and the permissions granted. Notable earlier campaigns such as EvilTokens show how readily this technique can be scaled to do real damage. Microsoft worked hard with partners in industry and law enforcement to disrupt EvilTokens in September 2026.
That led us to a different question: what else can an attacker do with a phished device code authorization? What happens when the same trick targets an AI agent rather than a mailbox?
We used GitHub Copilot CLI as an illustrative example. Depending on its configuration, it can work with code, run commands on a user’s machine, retain context across sessions, and allow an active session to be steered remotely. Like many command-line tools, it supports the OAuth device flow for sign-in. The phishing technique itself is not specific to GitHub or Copilot CLI: any public client that supports the device flow can be abused the same way, and the attacker chooses the requested scopes when starting the flow.
We explored this scenario in a controlled lab simulation. A victim test account approved a GitHub device-code request initiated by an attacker client we controlled. With that approval, we were able to analyze four possible outcomes:
These are proof-of-concept results showing how existing features, working as designed, could be abused after a phished authorization; they are not attacks we have observed in the wild. These outcomes require the victim user to approve a device code request initiated by the attacker; each outcome also depends on the account permissions and enabled features described below.
Later in this post, we show how Microsoft Defender helps detect these attacks by connecting phishing attempts with GitHub authentication activity, and how organizations can disrupt suspicious access to protect affected identities.
The OAuth device flow helps clients such as command-line tools sign in without displaying a full browser. A client requests a short code; the user enters it on the service’s verification page; the requesting client receives access after approval. In device code phishing, the attacker starts the request and persuades someone else to approve it.
Microsoft has reported device code phishing against accounts in several campaigns, including Storm-2372, an AI-enabled campaign in 2026, and EvilTokens. Those cases motivated us to examine a different target: a coding agent that can work with repositories and, when remote control is enabled, expose an active session to remote interaction.
The remainder of this post describes a controlled GitHub Copilot CLI simulation; we have not observed the four outcomes below in those campaigns or in the wild.


The following example shows the initial HTTP request to GitHub’s device authorization endpoint. The Copilot CLI client identifier is public; it is not a client secret. The attacker sends the short code returned by GitHub to the user. Once the user approves it, the requesting client signs in without another manual step.
GitHub Device Code Authentication (Simplified) Endpoint: GitHub Device Authorization Endpoint Client ID:Requested scopes:
The user signs in on the real GitHub site, not a lookalike page. A familiar domain therefore cannot tell the user whether the request was theirs. An authorization also appears under a legitimate application name; the name alone cannot distinguish the attacker-controlled client from an expected sign-in.
The device code approval was only the starting point. What an attacker could do next depended on the account’s permissions, enabled features, memory settings, and whether an active session could be controlled remotely.

Copilot CLI supports remote steering of an active interactive session when the user has enabled remote control for that session and organization policy allows it. In our lab, the attacker-controlled client used the test account’s authorization to interact with a remotely controllable session. The agent ran a command on the test machine, subject to the session’s approval prompts and local operating-system permissions. This demonstrates misuse of an authorized remote-session capability working as designed; it is not unauthenticated remote code execution and does not apply when remote control is disabled, the session is not running, or the machine is offline.


Copilot Memory can retain repository facts and user preferences. In the simulation, we added misleading entries using the agent’s /memory command. If those entries are used in later interactions, the effects can outlast the initial sign-in. The behavior depends on which memory features and policies are enabled.

Where cloud session storage is enabled, we could read the test account’s synced Copilot CLI sessions, including sessions from before the simulation. They may contain code snippets, file paths, architecture discussions, and other work context. For Copilot Business and Enterprise, availability depends on the organization’s session-storage policy; syncing a session does not itself enable remote control.
In the lab, the authorization let us access private repositories available to the test account. The request included the repo scope along with read:user, read:org, gist, and codespace. These scopes are chosen by the client that starts the flow; the resulting repository access reflects the requested scopes and the account’s permissions, not a property of Copilot CLI itself. The potential exposure is bounded by the account’s repository access, which can include application code and infrastructure definitions.
A phishing message, a click, and a GitHub authorization can each look unremarkable on their own. The challenge for defenders is recognizing when they belong to the same attempted takeover. The legitimate verification page is part of the story, not evidence that the request was safe.
Microsoft Defender helps organizations detect and respond to device code phishing targeting GitHub accounts. With the GitHub Enterprise Cloud connector enabled in Microsoft Defender for Cloud Apps, organizations gain visibility into GitHub activity that can support investigations of suspicious authorization patterns.
As part of our research, we developed two detections for suspected GitHub Copilot CLI device code phishing, covering attacks delivered through email and Microsoft Teams.
These detections correlate suspicious messages and clicks with subsequent GitHub OAuth token creation and regeneration events, helping identify potentially unauthorized Copilot CLI authorizations that might otherwise appear legitimate. Microsoft Defender XDR customers can refer to the list of applicable detections below.
Beyond detection, we also developed a disruption action for GitHub Enterprise Managed Users (EMU). This action suspends the affected managed identity through the organization’s identity provider, interrupting the attacker’s access. We validated this capability in our research environment.
Responders should also review and revoke unexpected OAuth authorizations, verify that access is blocked, and investigate potentially affected sessions, repositories, and saved memory.
Together, these capabilities help security teams move from identifying a potential phishing attempt to containing the affected identity. Detection and disruption availability depend on the supported configuration, required telemetry, identity integration, and deployment prerequisites.


The most striking part of this simulation was how little needed to look suspicious. The user visited the real GitHub site and approved a normal-looking request. Yet the approval belonged to a client the user had not started. From there, the consequences depended on what that identity could access and which Copilot CLI capabilities were enabled.
That is why this is more than a story about a code. As AI agents gain access to repositories, session history, and local tools, the impact of a phished authorization increasingly depends on what those agents can reach.
A legitimate verification page does not mean the request is safe. Users should approve only device-code requests they initiated. Organizations should regularly review and revoke unexpected GitHub OAuth authorizations, restrict Copilot session and memory settings to what their workflows require, and validate GitHub activity visibility in Microsoft Defender for Cloud Apps to support investigations.
Ultimately, protecting against device code phishing requires both user awareness and the ability to connect suspicious authorization activity to the phishing attempt that preceded it.
These mappings describe behaviors demonstrated in the proof-of-concept simulation, not an attributed campaign.
For the latest security research from the Microsoft Threat Intelligence community, check out the Microsoft Threat Intelligence Blog.
To get notified about new publications and to join discussions on social media, follow us on LinkedIn, X (formerly Twitter), and Bluesky.
To hear stories and insights from the Microsoft Threat Intelligence community about the ever-evolving threat landscape, listen to the Microsoft Threat Intelligence podcast.
Review our documentation to learn more about our real-time protection capabilities and see how to enable them within your organization.