Microsoft shows how a phished device code could hijack an AI coding agent
Lab research using GitHub Copilot CLI shows a sign-in code trick could expose code, sessions and repositories. Microsoft says it has not seen it used in real attacks.
EDITOR | Tuesday 17 November 2026 | World

Microsoft researchers have shown how device code phishing, a trick that persuades a user to approve a sign-in started by an attacker, could be turned against AI coding agents. They used GitHub Copilot CLI as the example in a controlled lab with a test account.
In the simulated attack, the attacker starts a device sign-in, sends the code and the genuine GitHub verification link as a fake IT request or licence check, and waits for the user to approve it on the real GitHub site. The attacker's own program then signs in automatically. Microsoft says any public client that supports the device flow can be abused the same way.
The researchers found four possible outcomes. With remote control switched on and allowed by policy, an attacker could steer a session and run commands, within approval prompts and local permissions. Entries added through the agent's memory command could mislead later work. Where cloud session storage was on, synced sessions could be read, and private repositories available to the test account could be reached.
Microsoft stresses these are proof-of-concept results and not attacks it has seen in the wild.
Its advice is to enter a device code only for a sign-in you started yourself, and to treat unexpected requests to verify as phishing even when they appear on github.com. Organisations should review Copilot CLI session settings, audit and revoke unexpected authorised OAuth apps, limit repository access and check stored memory entries. Microsoft also describes two Defender detections for suspected Copilot CLI device code phishing by email and Teams, which need the GitHub Enterprise Cloud connector in Defender for Cloud Apps.