What is Device Code Phishing?
Written by: Lizzie Danielson
Published: 9/25/2026
Key Takeaways
- Device code phishing abuses a legitimate OAuth device authorization flow designed for devices with limited keyboards or browsers, like smart TVs, printers, and consoles.
- The attacker starts the authentication session and generates the code, then prompts the victim to enter it on their device.
- Entering an unexpected device code can authorize an attacker-controlled device.
- MFA may not stop the attack because the victim completes authentication and the resulting token inherits the MFA claim.
- The use of real login URLs and trusted cloud infrastructure can make the attack difficult for traditional email and web defenses to identify.
- The safest rule for users is simple: Never enter a device code unless you personally started the login process.
- Organizations should block device code authentication where it isn’t required, monitor identity telemetry, and quickly revoke sessions and refresh tokens after suspected compromise.
What Is Device Code Phishing?
Device code phishing is a social engineering attack that tricks someone into authorizing an attacker’s device through a legitimate login flow. The attacker generates a real device code, sends it to the victim in a convincing email or message, and directs them to a genuine authentication page—often microsoft.com/devicelogin. When the victim enters the code and completes authentication, they authorize the attacker’s session instead of their own.
Unlike traditional phishing, this attack may not involve a fake login page, stolen password, malware, or a bypassed MFA prompt. The victim can complete MFA successfully while the attacker receives the resulting OAuth tokens.
How does device code authentication normally work?
Device code authentication is a legitimate way to sign in when a device can’t easily display a full browser or accept a username and password.
For example, when setting up a streaming app on a smart television:
- The television displays a short code.
- The user visits an authentication page on another device.
- The user enters the code and signs in.
- The original device receives an access token.
This separates the device displaying the code from the device used to authenticate.
The design is convenient, but it creates an opportunity for attackers to start the authentication process themselves.
How does device code phishing work?
A typical attack follows this sequence:
- The attacker starts a device login session. They request a legitimate device code from the identity provider.
- The attacker creates a lure. The message may impersonate an IT administrator, Teams invitation, document-sharing request, voicemail notification, or security alert.
- The victim visits a real login page. The link may lead to an authentic Microsoft authentication URL.
- The victim enters the attacker’s code. They may then provide their username, password, and MFA response.
- The attacker receives the tokens. The attacker’s device is now authorized as the victim.
- The attacker uses the session. They may access email, files, calendars, or other cloud resources, depending on the token’s permissions.
The crucial detail is that the victim is authenticating the attacker’s pre-existing session, not starting a session for themselves.
Why is device code phishing difficult to detect?
Traditional phishing awareness often teaches people to look for:
- Misspelled domains
- Fake login pages
- Suspicious attachments
- Unexpected password requests
- Unusual MFA prompts
Device code phishing can avoid many of these warning signs. The URL may be legitimate, the code may be valid, and the user may be completing a normal authentication process.
Email security tools can also fall short when attackers use trusted infrastructure. In the EvilTokens campaign, Huntress observed legitimate authentication flows, clean URLs, and infrastructure associated with trusted services, allowing messages to pass through multiple email security controls.
Real-world device code phishing examples
Storm-2372 and fake Teams invitations
In February 2025, the suspected Russian state-sponsored threat actor Storm-2372 used convincing communications through platforms like WhatsApp, Signal, and Microsoft Teams. After building rapport, the attackers directed targets to enter attacker-generated device codes on legitimate Microsoft login pages.
Microsoft 365 users in government, defense, telecommunications, healthcare, energy, and other sectors were targeted. The campaign demonstrates how device code phishing can combine impersonation, social engineering, and legitimate identity infrastructure.
Figure 1: Example of a device code phishing lure.
EvilTokens and the Railway campaign
In March 2026, Huntress investigated a large-scale campaign that affected 344 organizations across the United States, Canada, Australia, New Zealand, and Germany. Attackers used Railway, a legitimate platform-as-a-service provider, as part of the token-harvesting infrastructure.
The campaign used highly personalized lures, including construction bid requests, DocuSign-themed messages, voicemail notifications, and document-sharing prompts. The campaign was later attributed to EvilTokens, a phishing-as-a-service platform that included automated lure generation and dynamic device-code creation.
Kali365 and phishing-as-a-service
Huntress observed Kali365 activity involving Microsoft 365 device-code authentication events from Tencent Cloud infrastructure. The platform included multiple lure templates, token management, mailbox access, and post-compromise capabilities.
In one observed flow, a victim clicked through a document-themed lure, opened a legitimate Microsoft login page, entered the supplied code, and was redirected to an “expired document” page hosted on Canva. Huntress reported that the attacker gained persistent access in as little as 42 seconds.
Figure 2: Canva-hosted phishing website
Does MFA stop device code phishing?
Not necessarily. MFA can still be completed during the attack, but the authentication is applied to the attacker’s device-code session. The resulting token may carry an MFA claim, allowing the attacker to access resources without completing another MFA challenge.
MFA remains important, but organizations should pair it with controls that restrict authentication context, device state, application use, and authentication method.
Phishing-resistant methods like FIDO2 security keys and passkeys can strengthen identity security, but enabling them does not automatically disable device code authentication. Device code flow must be explicitly blocked or restricted where appropriate.
How can organizations prevent device code phishing?
Block or restrict device code flow
Use Microsoft Entra Conditional Access to block device code authentication wherever it isn’t operationally necessary. If certain users or applications require it, restrict the flow to approved identities and use cases.
Monitor identity logs
Look for:
authenticationProtocol == "deviceCode"in interactive sign-in logsoriginalTransferMethod == "deviceCodeFlow"- New or unmanaged device registrations
- Successful sign-ins from unfamiliar IP addresses or hosting providers
- User-agent mismatches between interactive and non-interactive sessions
- Rapid access to multiple Microsoft 365 resources
Interactive logs can identify the initial device-code authentication, while non-interactive logs can help scope later token use.
Revoke sessions and tokens
If a user enters an unexpected code, treat the event as a potential account compromise. Revoke active sessions and refresh tokens, review audit logs, and investigate mailbox, file, and administrative activity.
Train users on the correct rule
Teach employees:
If you didn’t start the login, don’t enter the code.
An unexpected code request through email, Teams, text message, or another chat platform should be reported to IT or security.
What should you do if you entered an unexpected device code?
- Report the incident immediately.
- Stop interacting with the message or webpage.
- Contact your security or IT team through a trusted channel.
- Revoke active sessions and refresh tokens.
- Review sign-in, audit, mailbox, and file-access logs.
- Check for unfamiliar device registrations, OAuth applications, inbox rules, or forwarding settings.
- Reset credentials as part of the incident-response process—but don’t assume a password reset alone removes the attacker.
Password changes may not invalidate every existing token, so session and token revocation is essential.
FAQs
Device code phishing is an attack in which a threat actor tricks a victim into entering an attacker-generated authentication code on a legitimate login page. The victim unknowingly authorizes the attacker’s device.
No. In device code phishing, the attacker generally isn’t intercepting the victim’s live login session. Instead, they start a legitimate device authorization flow and convince the victim to complete it for them.
It may not need to. The primary objective is often to obtain OAuth access and refresh tokens rather than the user’s password.
Because it may be real. Attackers abuse legitimate Microsoft authentication endpoints and direct victims to them with a code the attacker generated.
Yes. Microsoft Entra Conditional Access can block device code flow or restrict it to approved users and scenarios. Organizations should evaluate operational requirements before enforcing the policy.
Not necessarily. Huntress research found that Google’s device-code implementation supports a narrower set of OAuth scopes, which can significantly limit the impact compared with Microsoft’s implementation.
Block device code flow where it isn’t required, monitor identity activity, and teach users never to enter an unexpected code.
Additional Resources
- Read more about What Is a Bot in Cybersecurity? The Complete GuideLearn what bots are in cybersecurity, types of malicious vs good bots, detection methods, and protection strategies. Essential guide for security pros.
- Read more about What Is FISMA? Overview, Security Guidelines & ComplianceWhat Is FISMA? Overview, Security Guidelines & ComplianceLearn about the Federal Information Security Management Act (FISMA), its purpose, compliance steps, and how it strengthens cybersecurity frameworks.
- Read more about Extensible Authentication Protocol (EAP) ExplainedExtensible Authentication Protocol (EAP) ExplainedLearn how extensible authentication protocol EAP secures networks, supports multiple authentication methods, and why it’s key for modern cybersecurity.
- Read more about What is Credential Stuffing and How to Prevent ItWhat is Credential Stuffing and How to Prevent ItLearn everything about credential stuffing, from how it works to real-world examples and prevention techniques for businesses and users.
- Read more about What is CSPM? Cloud Security Posture ManagementWhat is CSPM? Cloud Security Posture ManagementWhat is CSPM? Learn what cloud security posture management is, how it works, and why it matters for finding and fixing cloud misconfigurations.
- Read more about What Is Conti? Understanding Conti Ransomware & Its SpreadWhat Is Conti? Understanding Conti Ransomware & Its SpreadLearn about Conti Ransomware, how it spreads, and its impact on cybersecurity. See key takeaways for protecting against this prominent ransomware threat.
- Read more about What Is Integration in Cybersecurity? Best PracticesWhat Is Integration in Cybersecurity? Best PracticesLearn why integration matters in cybersecurity, including key benefits, challenges, and steps to connect security tools securely.
- Read more about What Is DNS Poisoning? Attacks & Prevention GuideWhat Is DNS Poisoning? Attacks & Prevention GuideLearn what DNS poisoning is, how it works, and ways to detect and prevent attacks. Protect your network from cache poisoning with these expert tips!
- Read more about What Is a Deepfake?What Is a Deepfake?Deepfakes are AI-generated media that can fool anyone. Learn what they are, how to spot one, why threat actors use them, and what to do if you think you're being tricked