Device-code phishing could expose GitHub Copilot CLI sessions and repositories
A successful device-code phishing attempt against a developer’s GitHub account could expose more than repository access. In a controlled lab simulation, Microsoft researchers used an attacker-controlled client to obtain authorization after a test user approved a GitHub device-code request. They then demonstrated several possible consequences involving GitHub Copilot CLI, subject to the account’s permissions and the features enabled.
The researchers emphasized that these were proof-of-concept results, not activity they had observed in the wild. The scenario illustrates how an established OAuth sign-in method can become a route to sensitive development resources when a user is tricked into approving a request they did not initiate.
How the device-code lure works
OAuth’s device flow lets command-line applications sign in without presenting a full browser-based authentication experience. The client requests a short code, and the user enters it on the service’s verification page. Once the user approves the request, the requesting client receives authorization.
In a phishing attempt, an attacker starts the request and sends the code and verification link to a target, perhaps under a pretext such as an IT request or a Copilot license check. The user may visit GitHub’s genuine site and see a legitimate-looking application name. Neither the real domain nor a familiar name establishes that the user initiated the sign-in.
Microsoft’s simulation used GitHub Copilot CLI as an example, but the technique is not specific to that product: the researchers noted that any public client supporting device flow could be abused in a similar way. The client initiating the flow selects requested scopes, while the resulting access is constrained by those scopes and the account’s permissions.
Four possible effects in the lab
After approval by a test account, the researchers demonstrated four potential outcomes. Each depended on the relevant settings, permissions or available data:
-
Remote session interaction: If remote control is enabled, organization policy permits it, and an interactive session is active, an attacker could steer that session. In the test, the agent ran a command subject to local operating-system permissions and approval controls. This was misuse of an authorized feature, not unauthenticated remote code execution.
-
Misleading saved memory: The researchers added deceptive entries through Copilot CLI’s memory feature. If later interactions use those entries, they could influence the agent’s responses. The impact depends on memory settings and policies.
-
Access to synchronized sessions: Where cloud session storage is enabled, the test authorization exposed synced Copilot CLI sessions, including earlier context. Session history could contain code snippets, file paths and architecture discussions. For Copilot Business and Enterprise, availability depends on the organization’s session-storage policy. Session synchronization does not itself enable remote control.
-
Private repository access: The test authorization allowed access to private repositories available to the test account. The request included the scopes repo, read:user, read:org, gist and codespace. Exposure therefore followed the account’s access and the scopes requested, rather than being an inherent property of Copilot CLI.
The researchers also linked the technique to earlier device-code phishing campaigns, including Storm-2372 and EvilTokens. The described Copilot CLI outcomes, however, were not attributed to those campaigns or reported as observed attacks.
Detection and containment considerations
Microsoft said its Defender capabilities can help connect suspicious email or Microsoft Teams activity with subsequent GitHub OAuth token creation and regeneration events. The detections are intended to identify suspected Copilot CLI device-code phishing that might otherwise resemble ordinary authentication. Visibility depends on the supported configuration and telemetry; Microsoft described using the GitHub Enterprise Cloud connector in Defender for Cloud Apps.
For GitHub Enterprise Managed Users, Microsoft also described a disruption action that suspends an affected managed identity through the organization’s identity provider. In an incident, responders should review and revoke unexpected OAuth authorizations, confirm that access has been blocked, and investigate potentially exposed sessions, repositories and saved memory.
Reduce the risk of unauthorized approval
Organizations should make a simple rule clear to developers: enter a device code only when they initiated the sign-in themselves. A genuine GitHub verification page does not make an unsolicited code request safe. Users should treat requests to verify an account or activate Copilot as suspicious if they did not start the process.
Administrators can review Copilot CLI session policies and choose the least permissive cloud-storage and remote-control settings that support their workflows. They should also limit repository access to job requirements and periodically review authorized OAuth applications. If memory is enabled, responders should inspect and remove suspicious saved entries; disabling memory does not automatically delete information already stored.
Microsoft recommends connecting GitHub Enterprise Cloud to Defender for Cloud Apps and validating the activity available in the organization before relying on it during investigations. Safe Links protections for email and Teams can support defenses and investigations, but they cannot by themselves establish whether a legitimate device-code request was initiated by the user. The central control remains careful approval, combined with restricted permissions and the ability to investigate OAuth activity.