
The risks of device code authentication for AI coding agents
Microsoft researchers have discovered that AI coding assistants like GitHub Copilot CLI can be compromised through device code phishing attacks, potentially giving attackers control over active sessions, access to private repositories, and the ability to manipulate the agent's memory.
Device code phishing has emerged as a significant threat to AI coding agents, allowing attackers to gain unauthorized access through a simple approval process. Microsoft security researchers demonstrated how a victim approving a seemingly legitimate device code request for GitHub Copilot CLI could enable attackers to perform multiple harmful actions, including remote session control, memory manipulation, accessing synced sessions, and reaching private repositories.
Attack Mechanism
The attack follows a familiar pattern: an attacker initiates a device-code sign-in request, lures the victim with the verification code and link, persuades them to approve it on the legitimate GitHub site, and then automatically completes the sign-in. The verification page appears legitimate, making it difficult for users to detect the deception.
Unlike traditional phishing, this method doesn't require stolen credentials but rather exploits the OAuth device flow, where the attacker chooses the requested scopes when initiating the flow. The Copilot CLI client identifier is public, making it accessible for abuse.
Potential Impacts
Once approved, attackers can exploit four main attack vectors. First, they can steer active remote sessions if enabled by the user and allowed by organization policy, potentially running commands on the victim's machine. Second, they can manipulate the agent's memory with misleading entries that could influence future interactions. Third, they can access synced session history containing code snippets and work context. Fourth, they can reach private repositories available to the compromised account.
These are proof-of-concept results showing how existing features, working as designed, could be abused after a phished authorization; they are not attacks we have observed in the wild.
Defense Strategies
Microsoft has developed detection methods within Defender that correlate suspicious messages and clicks with subsequent GitHub OAuth token creation events. For GitHub Enterprise Managed Users, they've created a disruption action that suspends affected identities through the organization's identity provider. Security teams should also review and revoke unexpected OAuth authorizations and investigate potentially compromised sessions and repositories.
The challenge for defenders is recognizing when seemingly separate elements—a phishing message, a click, and a GitHub authorization—belong to the same attack attempt. Microsoft's approach helps connect these dots to identify potentially unauthorized authorizations that might otherwise appear legitimate.