Skip to content
nulltapE-reader edition

← All e-reader articles

4 min read

GitHub Device-Code Approval Exposes Copilot CLI Repositories and Sessions

Microsoft's lab shows how an attacker-initiated GitHub sign-in reaches repositories and enabled Copilot CLI features after approval.

Read on the standard site

A developer laptop with an illuminated, detail-free display on a desk.

A GitHub sign-in page can be genuine while the sign-in belongs to somebody else. In a controlled test published November 17, Microsoft Security Research had a test user approve a GitHub device code requested by an attacker-controlled client. That authorization let the researchers access private repositories available to the account and, when the relevant Copilot CLI features were enabled, read synced sessions, add misleading memory entries, and steer an active remote session.

The user sees GitHub’s real verification page, approves what looks like an ordinary application, and grants the requesting client access under the account’s permissions. Microsoft tested the four Copilot CLI outcomes in a lab; it says it has not observed those outcomes in the wild. Treat an unexpected approval as a credential incident and scope the investigation to what the account could reach and which features were on.

The code belongs to the requester

Device flow lets a command-line client sign in through a separate browser. The client starts an authorization, receives a short code, and waits for a person to enter the code on the service’s verification page. In Microsoft’s simulation, the attacker controlled the requesting client. Microsoft describes an IT request or Copilot license check as possible lures for sending its code to a user. The user approved it on GitHub. The waiting client then received an OAuth token without another manual step. The requesting client chooses the scopes; the account’s own permissions determine the resources available afterward.

Microsoft puts the trust problem plainly: “the legitimate domain alone does not establish who initiated the request.” A GitHub URL or a recognizable application name tells you where an approval happens, not who began the flow. Enter a code only when you just initiated that sign-in in your own client. A code forwarded in email or Teams has a different origin, even if its destination is GitHub.

Account settings shape the reach

In the lab, the token request included repo, read:user, read:org, gist, and codespace. The researchers used the approval to read private repositories accessible to the test account. GitHub’s requested scopes and the test account’s repository roles set the reach of that token, including which private code the researchers could read. A developer with broad repository roles offers a wider path to application code and infrastructure definitions.

The other results depended on separate Copilot features. With cloud session storage enabled, the researchers read synced Copilot CLI sessions, including sessions from before the test. Such history can contain code snippets, file paths, and architecture discussions. They also added misleading Copilot Memory entries that could shape later interactions if the relevant memory features and policies were enabled. Review saved memory as its own artifact during response: switching memory off does not remove entries already stored.

Remote control has a narrower condition. The test account had an active interactive session with remote control enabled and permitted by organization policy. The researchers steered that session, and the agent ran a command on the test machine within its local permissions and approval settings. An offline machine, a stopped session, or disabled remote control cuts off that path. Session syncing alone does not switch remote control on. This was use of an authorized feature after a phished approval, rather than unauthenticated code execution against the developer machine.

Follow messages into token events

Microsoft developed two Defender XDR detections for suspected GitHub Copilot CLI device-code phishing: one for email delivery and one for Microsoft Teams. They correlate suspicious messages or clicks with later GitHub OAuth token creation and regeneration events. Organizations using the GitHub Enterprise Cloud connector in Defender for Cloud Apps can use GitHub activity alongside message telemetry to investigate that sequence. Check that the connector and the relevant email or Teams telemetry are available before relying on those detections.

Ask the affected developer whether they initiated a sign-in at the time of a suspicious token event. Examine the authorized OAuth application, its scopes and the account’s repository roles. Look at any synced sessions, saved memory, and active remote sessions available under that identity; check the organization policy for “Store local sessions in the Cloud” and whether remote control was enabled for the session. Microsoft says detection and disruption depend on supported configuration, telemetry, identity integration, and deployment prerequisites.

Revoke access and verify the block

For an unexpected authorization, review the user’s authorized OAuth apps in GitHub account settings and revoke the authorization. Microsoft also recommends limiting repository permissions to the work the account needs, choosing the least permissive Copilot CLI cloud-session policy that supports the team’s workflow, and removing suspicious saved memory. Its tested disruption for GitHub Enterprise Managed Users suspends the affected managed identity through the organization’s identity provider. Responders can use that route where the integration is deployed.

After revocation or identity suspension, verify the previously authorized client is blocked from accessing the account, then investigate the repositories, sessions, and saved memory that its permissions exposed. Review message and click evidence against OAuth token creation and regeneration; an approval on the real GitHub page can still have been initiated by the attacker. If a remote session was active and enabled, include its local command and approval history in the response. Revocation stops future use of that authorization; copied repository or session content still needs incident scoping. Make the origin of the code the first question whenever a developer reports a surprise verification request.

Primary sources