AI Security
One phished device code can hand over an AI coding agent's session, memory and repos
Microsoft showed in a lab that a single approved device-code request can let an attacker steer a coding agent session, plant false memory, read synced sessions and reach private repos. The fix starts with deciding which sign-in flows your agents are allowed to use.
November 27, 2026 · 6 min read

A single phished device-code approval was enough, in a Microsoft lab, to give an attacker four kinds of reach into an AI coding agent. Microsoft Security's November 17 research used GitHub Copilot CLI as the example and showed that, depending on settings, the attacker could steer an active session, add misleading entries to the agent's memory, read sessions synced to the cloud, and access the account's private repositories.
Two caveats belong up front, because Microsoft puts them there. These are proof-of-concept results, not attacks observed in the wild. And every outcome depends on the victim approving a request the attacker started, plus the account's permissions and which features are turned on.
Those caveats do not make the research less useful. They make it a clean picture of what the agent inherits when a sign-in goes wrong.
Why the real sign-in page does not protect you
The OAuth device flow exists so tools without a full browser, like command-line clients, can sign in. The tool asks for a short code, you type it on the service's verification page, and the tool gets access. In device-code phishing, the attacker starts that request and talks someone else into approving it.
The uncomfortable part, as Microsoft describes it, is that the victim signs in on the genuine github.com page, and the authorization shows up under a legitimate application name. Nothing on screen tells you whether you or someone else started the request. The lure can be as simple as an "IT request" or a "Copilot license check." Microsoft also notes the technique is not specific to GitHub or Copilot CLI: any public client that supports the device flow can be abused the same way, and the attacker picks the requested scopes.
Training people to check the domain does nothing here. The domain is correct.
What the agent adds to a stolen sign-in
Device-code phishing is not new. Microsoft cites earlier device-code phishing campaigns against accounts, including Storm-2372 and EvilTokens, where the stolen access could reach email, files, or other cloud services. The new part is what sits behind the account once an agent is attached to it.
Here is how I read the four outcomes as a defender.
- Remote steering turns an identity compromise into commands on a developer's machine, but only where the user enabled remote control, policy allows it, and the session is live. Local approval prompts and operating system permissions still apply.
- Memory poisoning outlasts the incident. Misleading entries can shape later interactions after the token is revoked, and Microsoft points out that disabling memory does not delete what is already stored.
- Synced sessions are a record of past work. Code snippets, file paths, and architecture discussions from before the phish become readable.
- Repository access follows the account and the scopes requested. In the lab, that included the
reposcope, which can mean application code and infrastructure definitions.
A plain stolen GitHub token already gives code access. The agent adds a working memory and a history of what you were thinking about, and in some configurations a way to act on your laptop.
The control: allowed sign-in flows for agents
I think the useful policy here is short. For each agent and developer tool in use, write down which sign-in flows it is allowed to use, and block the rest where your identity platform lets you.
For Microsoft sign-ins, Entra Conditional Access has an authentication flows condition, and Microsoft's own documentation calls device code flow high risk and says Microsoft recommends blocking it wherever possible. If you need it for a specific device class, allow it there and nowhere else.
For tools like Copilot CLI that sign in to GitHub, the levers are different, and the ones Microsoft lists are worth putting into a standard:
- A one-line rule for everyone who uses developer and AI tools: enter a device code only for a sign-in you started yourself. Microsoft notes that GitHub's own verification page already warns users never to use a code sent by someone else.
- Pick the least permissive setting for storing Copilot CLI sessions in the cloud. For organization seats, that policy determines whether sessions can be stored and remotely controlled.
- Review authorized OAuth apps on a schedule. GitHub documents how to review and revoke them. Anything unexpected or stale goes.
- Limit repository access with organization roles so one compromised account cannot reach more code than the work requires.
- If memory is on, know where to review and remove entries, and put that step in your incident response checklist.
I made this change in my own setup. My accounts now use phishing-resistant sign-in, and I treat any device code I did not start as a phishing attempt.
What detection looks like
Microsoft says it built two Defender XDR detections for suspected Copilot CLI device-code phishing, one for email and one for Microsoft Teams. They correlate the suspicious message and click with the GitHub OAuth token creation that follows. Both require the GitHub Enterprise Cloud connector in Defender for Cloud Apps. Microsoft also describes a disruption action for GitHub Enterprise Managed Users that suspends the affected identity through the identity provider, which it validated in its research environment.
The point I would take away even if you do not run Defender: each step of this attack looks normal by itself. A message, a click, a real GitHub authorization. You only see the takeover if something joins those events together. If your logging cannot connect a user's click on a link to an OAuth grant on GitHub a minute later, you do not have this detection, whatever your tool list says.
What to do this week
Pull the list of agents and developer tools your team signs in with, and next to each one write the sign-in flow it uses. Mark every device-code flow. For each one, decide whether it is needed. If it is not, block it. If it is, scope it, and make sure the "only codes you started" rule has been said out loud to the people using it.
Then open your own GitHub account's authorized apps page and look at what is there. If anything surprises you, that is the first thing to fix.