Attackers do not always need to steal a password or plant malware to take over an account. In a device code phishing attack, they abuse a legitimate OAuth login process to sign in as the victim. The target is tricked into entering a one-time code on a real, official login page, and the attacker, who generated that code, receives a valid session token in return. The attacker never touches a password. They complete a real login by having someone else finish it for them. From the identity provider’s point of view, everything looks normal: the user passed MFA and landed on the genuine site. That is exactly what makes the technique effective.
What Is Device Code Phishing?
The OAuth 2.0 device authorization grant, standardized in RFC 8628, is a login method built for devices or tools with limited input or no browser, such as smart TVs, streaming boxes, printers, or command-line tools like the Azure CLI. In this flow, the device requests access from the identity provider and receives a short alphanumeric code along with a verification URL. The user opens that URL on a separate device, phone or laptop, and enters the code. Once the user completes normal authentication (password and MFA), the identity provider issues an access token to the requesting device. Microsoft, Google, and other identity providers support this flow because it lets constrained devices sign in without ever handling or storing a password.
Device code phishing repurposes this convenience. Instead of a legitimate device starting the flow, the attacker starts it and generates a valid device code themselves. They then send that code to a target, usually by email, chat, or a fake meeting invite, often posing as IT support or a routine security notification. The victim is told to visit the real login page, for example microsoft.com/devicelogin, and enter the code. When the victim authenticates and completes MFA, they are unknowingly authorizing the attacker’s session rather than their own. The identity provider issues the resulting access and refresh tokens to whichever party initiated the original request, which is the attacker.
MITRE ATT&CK classifies this under sub-technique T1566.002, Spearphishing Link, noting that a malicious link can direct a victim to a device-authorization page where they are tricked into entering a code that produces a device token. No software vulnerability is involved. The technique relies entirely on social engineering against a legitimate protocol feature.
How the Attack Works
- The attacker initiates the flow. They call the identity provider’s device authorization endpoint (for example, Microsoft Entra ID’s device code endpoint) to generate a valid code and verification URL.
- The attacker delivers the code to the target. This usually arrives by email, a Teams or Slack message, or SMS, styled to look like an IT request, a meeting invite, or a security alert.
- The victim opens the legitimate sign-in page. The link points to the identity provider’s real domain, so there is no fake portal to spot.
- The victim signs in and enters the code. They complete their normal password and MFA steps, then type in the code supplied by the attacker.
- The identity provider issues tokens. Because everything about the login looks legitimate, the provider issues an access token, and typically a refresh token, for the session.
- The attacker retrieves the token. Since the attacker generated the original request, their system polls the token endpoint and receives the tokens as soon as the victim finishes authenticating.
Why Traditional Defenses Miss It
Device code phishing is difficult to catch because the victim genuinely signs into the real service on a real, HTTPS-protected page. There is no cloned login portal and no malicious domain for URL filtering or email security tools to flag. The link is to a trusted domain, so secure email gateways and anti-phishing training built around spotting lookalike URLs do not help. The attacker is not breaking the authentication system. They are convincing a legitimate user to perform a login on their behalf. To the identity provider, it looks exactly like a normal, successful sign-in.
A Realistic Attack Scenario
Consider a finance manager who receives an urgent message, apparently from “IT Support,” about a security check on her Microsoft 365 account. The message includes a short code and a link to the official device login page. She follows the link, which genuinely points to microsoft.com/devicelogin, signs in, and approves an MFA prompt on her phone. The page shows a success message, and she closes the browser believing her account is secure.
In reality, the attacker generated that code and was waiting on the other end of the request. The moment she authenticated, the attacker’s system received a valid access token for her account. From her side, nothing looked wrong. She used the official page and her normal login steps, so she may never realize the account has been compromised. The attacker, now signed in with her privileges, can read her mailbox, browse files in SharePoint or OneDrive, send messages as her, or set up mail-forwarding rules. If her role includes approving payments or accessing financial systems, the scope of damage grows accordingly, since the attacker’s access is bounded only by what her account is permitted to do.
Real-World Campaigns
Device code phishing moved from a research curiosity to an active, large-scale threat starting in 2024. Microsoft’s threat intelligence team reported in February 2025 that a group it tracks as Storm-2372, assessed with moderate confidence to align with Russian state interests, had been running device code phishing campaigns since August 2024 against government agencies, NGOs, defense, telecom, healthcare, and energy organizations across Europe, North America, Africa, and the Middle East. Volexity independently tracked multiple Russian threat actors using the same technique around the same period.
Through 2025 and into 2026, the technique was industrialized by phishing-as-a-service (PhaaS) platforms. Barracuda detected more than 7 million device code phishing attempts in a single four-week period in April 2026, driven largely by a kit called EvilTokens. In May 2026, the FBI issued a public service announcement about a second kit, Kali365, warning that it gave lower-skilled attackers access to AI-generated lures and automated OAuth token capture. Independent reporting has since attributed waves of these attacks to several Russia-aligned clusters, including Storm-2372, APT29, UTA0304, UTA0307, and UNK_AcademicFlare, with one analysis citing more than 340 affected Microsoft 365 organizations across five countries.
Business Impact
The impact of a successful device code phishing attack is functionally the same as any other account takeover, without the attacker ever needing a stolen password:
- Data exposure. The attacker can read email, search mailboxes, and access files in OneDrive or SharePoint tied to the compromised account.
- Business email compromise. With control of a legitimate mailbox, the attacker can send convincing invoice fraud or wire transfer requests to colleagues and vendors, since the messages originate from a real, trusted address.
- Token abuse and lateral movement. Stolen OAuth tokens can be used directly against Microsoft Graph or similar APIs to enumerate the organization’s directory, search other mailboxes, and identify further targets.
- Persistence. Attackers frequently register a new trusted device, add an authentication method, or grant themselves a new OAuth application consent, all of which extend access well beyond the original token’s lifetime and survive a simple password reset.
If the compromised account has elevated privileges, in finance, HR, or IT, the consequences can extend to fraud, data exfiltration, or a foothold for further intrusion.
Why MFA Alone Does Not Stop It
It is tempting to assume that a successful MFA challenge proves a login is legitimate. In device code phishing, the victim does complete MFA, but the second factor is approving the attacker’s session, not their own. The cryptography behind MFA works exactly as designed. What fails is the assumption that the person approving the login is the same person who initiated it.
This is also why phishing-resistant methods such as FIDO2 hardware keys, Windows Hello, and passkeys do not fully close this gap. These methods are highly effective against reverse-proxy and adversary-in-the-middle attacks because they cryptographically bind the credential to the website’s origin, so a lookalike domain cannot capture a usable assertion. Device code phishing sidesteps that protection entirely, because the attack does not depend on tricking the user into visiting a fake site. It exploits the fact that the device code flow and the authentication method are two separate mechanisms. The user authenticates to the real site with a legitimate credential; the only thing that has been manipulated is which session that authentication gets applied to.
None of this means MFA or phishing-resistant authentication is not worth deploying. They remain essential against the far more common categories of credential and session theft. But they need to be paired with controls that specifically target the device code flow itself, since that is where this attack actually happens.
Detection
Because the login itself looks normal, detection depends on correlating the authentication event with what happens immediately before and after it:
- Device code sign-in patterns. Entra ID sign-in logs often show error code 50199 (“user confirmation required”) immediately followed by a successful device code sign-in. A device-code authentication for a user who normally signs in through a browser or mobile app is worth investigating.
- Unusual sign-in properties. Microsoft Entra ID Protection risk detections, such as sign-ins from anonymous IP addresses, unfamiliar sign-in properties, or impossible travel, are useful correlating signals.
- Unexpected client applications. A sign-in log entry showing “Azure CLI” or “PowerShell” for a user who has never used either is a strong indicator, since these tools commonly rely on the device code flow.
- Post-login activity. New inbox rules that auto-forward or auto-delete mail, unusual bulk mailbox searches, or large-scale Microsoft Graph API reads following a device-code sign-in often indicate an attacker consolidating access.
- New OAuth consent grants. Any new application consent or elevated permission grant around the time of a suspicious sign-in should be reviewed.
A simple starting query for Microsoft Sentinel or Log Analytics to identify device code sign-in activity looks like this:
SigninLogs
| where TimeGenerated > ago(30d)
| where AuthenticationProtocol == "deviceCode"
| project TimeGenerated, UserPrincipalName, AppDisplayName, IPAddress, ResultType, ClientAppUsed
Security teams should treat a normal-looking login as inconclusive on its own and instead build detections around the outcome of authentication, such as new token issuance combined with abnormal data access.
Prevention and Remediation
Identity controls
- Restrict the device code flow. Microsoft Entra ID includes an “Authentication flows” condition in Conditional Access that can explicitly block the device code grant. The FBI’s Kali365 advisory recommends auditing legitimate device code usage first, then applying a Conditional Access policy that blocks it for all users except a narrow, documented set of accounts or applications that genuinely need it. Microsoft’s own guidance takes the same position: block device code flow wherever it is not required.
- Apply risk-based Conditional Access. Configure sign-in risk conditions to require re-authentication or block access when a login originates from an anonymous IP address, an unfamiliar location, or a risky client.
- Deploy phishing-resistant MFA. FIDO2 keys and passkeys remove entire categories of credential and session theft, even though they do not directly stop a user from entering a code they were told to enter. Reducing the attacker’s other options still narrows the overall attack surface.
- Block legacy authentication protocols, which often bypass modern Conditional Access and MFA enforcement entirely.
- Centralize identity monitoring by feeding Entra ID sign-in and audit logs into a SIEM or MDR platform so anomalies across cloud and on-premises identities are visible in one place.
- Enforce least privilege on high-value accounts, so that if a session is stolen, the blast radius is limited.
User awareness
Generic phishing training is not enough here, because the page the user visits is genuinely legitimate. The rule to teach is simple: if a login or MFA prompt was not something the user initiated, they should not complete it, and should verify the request with IT through a separate channel before entering any code.
Incident response
If a device code phish is suspected:
- Revoke active sessions immediately. Microsoft Graph’s revokeSignInSessions endpoint invalidates a user’s refresh tokens and browser session cookies, forcing a fresh sign-in.
- Reset the account’s password and re-register MFA methods, removing any unrecognized authentication method or trusted device.
- Audit and remove persistence. Review OAuth application consents and remove anything unrecognized. Check the mailbox for new forwarding or auto-delete rules.
- Review sign-in and audit logs around the suspected time of compromise, including the error 50199 event, IP addresses, and any Microsoft Graph API activity such as mass mailbox reads.
- Contain and notify. Depending on what the attacker accessed, this may include notifying affected parties, disabling compromised devices, and checking whether other users received the same phishing lure.
Sources
1. Microsoft Security Blog, “Storm-2372 conducts device code phishing campaign,” February 13, 2025
2. Microsoft Security Blog, “Defending against evolving identity attack techniques,” May 29, 2025
3. Volexity, “Multiple Russian Threat Actors Targeting Microsoft Device Code Authentication,” February 13, 2025
4. MITRE ATT&CK, T1566.002 Phishing: Spearphishing Link
5. IETF, RFC 8628: OAuth 2.0 Device Authorization Grant
6. FBI / Internet Crime Complaint Center, “Kali365 Phishing-as-a-Service Kit Hijacks Microsoft 365 Access Tokens,” May 2026
7. Barracuda Networks, “Threat Spotlight: Device code phishing is on the rise with 7 million attacks in four weeks,” April 23, 2026
8. The Hacker News, “OAuth Device Code Phishing Hits 340+ Microsoft 365 Organizations,” March 2026
9. Microsoft Learn, “Block authentication flows with Conditional Access policy”
10. Microsoft Learn, Microsoft Graph API: user: revokeSignInSessions
11. Huntress, “We Need to Talk About Device Code Phishing”
