Threat Overview
Security researchers from Datadog uncovered several malicious Copilot Studio agents that had been set up to look like internal tools. These agents were created inside attacker-controlled tenants and designed to guide victims through an OAuth device code flow. Once the user granted consent and entered the numeric code, the attacker could exchange that code for real access tokens.
Nothing in this process asks for a password. Everything looks legitimate. That is exactly why the technique works.
Technical Analysis:
- How the CoPhish Attack Works
-
- Building the Malicious Copilot Agent
The attacker starts by creating a custom Copilot Studio agent inside their tenant. The agent contains a workflow that triggers the OAuth device code process. Its design imitates corporate assistants or internal support bots. - Delivering the Phishing Link
The attacker then sends the victim a link to the agent. The link points to a real Microsoft domain such as copilotstudio.microsoft.com. Victims usually receive it through email or Teams, often framed as a Copilot demo or a productivity assistant.
Because the domain is trusted, most users click without concern. - Victim Interacts with the Agent
After opening the link, the victim sees a standard Copilot style interface. The bot appears to carry out a normal task and then requests the user to sign in to continue. - OAuth Consent and Device Code
The agent leads the victim into a legitimate Microsoft OAuth consent flow. The user is asked to sign in and approve permissions such as:- offline_access
- Mail.ReadWrite
- Files.Read.All
- Mail.Send
These permissions give broad and long-lasting access to mailbox contents, files, and user data.
After consenting, the victim receives a numeric device code.
- Entering the Code
The victim returns to the Copilot agent and enters the code. They believe this step verifies their identity. Instead, the code is exactly what the attacker needs. - Code Forwarded to Attacker Infrastructure
The malicious agent immediately forwards the numeric code to an attacker controlled system. - Token Exchange
The attacker submits the device code to the Microsoft token service and receives both access and refresh tokens. The scopes match whatever permissions the victim approved. - Persistent Access
With these tokens, the attacker can read emails, access OneDrive files, collect Teams messages, and interact with other Microsoft 365 applications. Since the access is granted through user consent, it often goes unnoticed and does not trigger traditional credential based alerts.
- Building the Malicious Copilot Agent


