Microsoft Shows How Device-Code Phishing Could Expose AI Coding Agent Sessions and Repositories

Summary
A controlled lab simulation found that approved GitHub device-code phishing could expose Copilot CLI sessions and private repositories, steer enabled remote sessions, or alter agent memory. Microsoft also described Defender detections and response guidance.
Key points
- In a controlled lab, a test user approved an attacker-initiated GitHub device-code request; the reported outcomes were proof-of-concept results, not attacks observed in the wild.
- Depending on account permissions and settings, the authorization could enable remote steering of an active Copilot CLI session, access to synced sessions and private repositories, or misleading entries in agent memory.
- Remote-session command execution required remote control to be enabled and remained subject to local permissions and approval prompts; repository access was limited by the requested OAuth scopes and the account’s permissions.
- Microsoft developed Defender detections correlating suspicious email or Teams activity with GitHub OAuth token events, and validated an identity-suspension action for GitHub Enterprise Managed Users in its research environment.
- Recommended defenses include approving only device-code requests initiated by the user, reviewing and revoking unexpected OAuth authorizations, limiting repository access, and reviewing Copilot session and memory settings.
Article Details
- Attack Vectors
- In a controlled lab simulation, an attacker-controlled client initiated a GitHub device-code sign-in request and persuaded a test user to approve it, for example through a pretext involving IT support or a Copilot license check.
- After approval, the client could obtain an OAuth token and act within the requested scopes and the test account's permissions.
- In the simulation, the authorization enabled access to private repositories available to the test account and to its cloud-synced Copilot CLI sessions, where session storage was enabled.
- If remote control was enabled and organization policy allowed it, the attacker-controlled client could steer an active Copilot CLI session and have the agent run a command on the test machine, subject to local permissions and approval settings.
- The simulation added misleading entries to Copilot Memory using the agent's /memory command; those entries could influence later interactions if the relevant memory features and policies were enabled.
- Microsoft described these outcomes as proof-of-concept misuse of existing features, not attacks observed in the wild.
- Defensive Notes
- Tell users to enter a device code only for a sign-in they initiated; treat unsolicited verification or Copilot activation requests as phishing even when the page is hosted by GitHub.
- Review and revoke unexpected or unnecessary GitHub OAuth authorizations, verify that access is blocked, and investigate potentially affected sessions, repositories, and saved memory.
- Limit repository permissions to what users require, and configure Copilot CLI session storage and remote control to the least permissive settings that support organizational workflows.
- If Copilot Memory is enabled, review and remove suspicious saved facts or preferences; disabling memory does not automatically delete existing entries.
- Configure Safe Links for email and verify protection for Microsoft Teams, while recognizing that a legitimate GitHub verification URL does not itself make an unsolicited device-code request safe.
- Connect GitHub Enterprise Cloud to Defender for Cloud Apps and validate that the required activity telemetry and integrations are available before relying on it for investigations.
- Use Microsoft Defender detections that correlate suspicious email or Teams activity with subsequent GitHub OAuth token creation or regeneration, and use the validated disruption action for GitHub Enterprise Managed Users when applicable.
MITRE ATT&CK
T1528 · Steal Application Access TokenAfter the test account approved the device-code request, the attacker-controlled client obtained an OAuth access token.T1566.002 · Spearphishing LinkIn the email-delivery lab test, a link led the user to the device authorization page and prompted approval of an attacker-initiated request.
Threat Actors
Vendors
Products
Copilot MemoryCopilot Memory can retain repository facts and user preferences.GitHub Copilot CLIWe used GitHub Copilot CLI as an illustrative example.GitHub Enterprise CloudWith 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.GitHub Enterprise Managed UsersBeyond detection, we also developed a disruption action for GitHub Enterprise Managed Users (EMU).Microsoft Defender for Cloud AppsWith 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.Microsoft Defender for Office 365Configure Safe Links policies in Microsoft Defender for Office 365 for email and verify Safe Links protection for Microsoft Teams.Microsoft Defender XDRMicrosoft Defender XDR customers can refer to the list of applicable detections below.
