Microsoft Threat Intelligence published research on 17 November asking a pointed question: what happens when device code phishing, an attack usually aimed at mailboxes, is pointed at an AI coding agent instead?
They used GitHub Copilot CLI as the example, in a controlled lab simulation. Microsoft is careful to say these are proof-of-concept results, not attacks seen in the wild. Anyone rolling out coding agents across an engineering team should still read it.
How the attack works
The OAuth device flow lets command-line tools sign in without a full browser. The tool asks for a short code, the user types it on the service's real verification page, and the tool gets access. In device code phishing, the attacker starts that request and talks someone else into approving it, perhaps posing as IT or as a "Copilot licence check".
The user signs in on the real GitHub site, not a lookalike, so there's nothing on the page to spot. The approval just belongs to a client the user never started. Microsoft notes the technique isn't specific to GitHub or Copilot: any public client that supports the device flow can be abused the same way, and the attacker chooses which scopes to request.
One approval, four outcomes
With a single phished approval from a test account, Microsoft's researchers were able to:
- Steer an active Copilot CLI session remotely, where the user had enabled remote control and org policy allowed it, and have the agent run a command on the test machine, subject to local approval prompts and OS permissions.
- Plant misleading entries in the agent's memory using its /memory command, so the attack could shape later interactions long after the sign-in.
- Read cloud-synced Copilot CLI sessions, including ones from before the simulation, with their code snippets, file paths and architecture discussions.
- Access private repositories available to the account. The request asked for repo, read:user, read:org, gist and codespace scopes.
The memory one worries me most. A stolen session ends when the token is revoked. A poisoned memory entry keeps nudging the agent until someone finds and removes it, and Microsoft points out that disabling memory does not delete entries already stored.
What to do about it
Microsoft's recommendations:
- Teach everyone who uses developer and AI tools one rule: only enter a device code for a sign-in you started yourself. An unexpected request to "verify" GitHub or activate Copilot is phishing, even on github.com.
- Review Copilot CLI session settings, including the "Store local sessions in the Cloud" policy, and pick the least permissive option your workflows allow.
- Audit and revoke unexpected OAuth authorisations, and keep repository access tight with organisation roles.
- If Copilot Memory is on, review stored repository facts and preferences during any incident response.
Microsoft has also built two Defender XDR detections for suspected Copilot CLI device code phishing over email and Teams, plus a disruption action for GitHub Enterprise Managed Users.
Why it matters now
The phishing trick is old. The blast radius is what's new. As coding agents get repository access, persistent memory, session history and the ability to run commands, a phished authorisation is worth much more than a mailbox. Treat agent sign-ins with the same identity hygiene you'd apply to privileged admin accounts. In practice, that's what they've become.
Source: Microsoft Security Blog: The risks of device code authentication for AI coding agents



