Unmasking EvilTokens: Getting to the root of device code phishing | Microsoft Security Blog
EvilTokens PhaaS platform abuses Microsoft device code authentication to steal tokens from 12,000+ inboxes across 10,000+ organizations, using AI to tailor lures and scan compromised mailboxes. The platform generates live device codes via background scripts and redirects users to the legitimate Microsoft devicelogin portal. Stolen tokens enable email exfiltration, inbox rule persistence, and Microsoft Graph reconnaissance for lateral movement. Access tokens remain active up to one hour after session revocation, requiring account disabling for containment.
Detection / HunterZ.ai
Immediate Actions
- Block device code flow in Conditional Access policies except for Teams device accounts
- Revoke refresh tokens and disable compromised accounts to prevent token persistence
- Enable Safe Links in Defender for Office 365 for high-confidence device code phishing alerts
- Review Entra ID sign-in logs for anomalous device code authentication activity
Key Takeaways
- Sold for $1,500 initial purchase with $500 monthly subscription on Telegram channels
- Uses 44 phishing themes including Adobe Sign, DocuSign, SharePoint, and OneDrive
- AI scans compromised inboxes for financial roles, wire transfers, and executive correspondence
- Access tokens remain active up to one hour after standard session revocation
- Thousands of short-lived Node.js polling nodes deployed via automation platforms in April 2026
Attack Chain
- Initial Access: Phishing email with malicious URL or attachment using one of 44 lure themes
- Execution: Background script generates live device code via Microsoft identity provider
- Credential Access: User enters code at legitimate microsoft.com/devicelogin, authorizing attacker session
- Persistence: Attacker registers new device for PRT or creates malicious inbox rules within minutes
- Discovery: Microsoft Graph API maps organizational structure and identifies sensitive permissions
- Exfiltration: AI scans inboxes for financial data, wire transfers, and high-value targets
Affected Systems
- Microsoft Entra ID tenants with device code flow enabled
- Microsoft 365 and Office 365 email accounts
- Microsoft Teams devices requiring device code authentication
- Organizations using Conditional Access without device code restrictions
Detection Availability
- Published: KQL
- Platforms: Microsoft Defender XDR Advanced Hunting, Microsoft Sentinel
KQL hunting queries provided for Defender XDR; Defender for Identity detections listed for device code auth anomalies.
Detection Engineering Assessment
Hunting Hypotheses
| Hypothesis | Telemetry | Stage | FP Risk |
|---|---|---|---|
| Device code authentication followed by anomalous token exchange from unfamiliar IP or location (T1528) | Entra ID sign-in logs, Defender for Identity alerts | Credential Access | Medium — legitimate device code flow for Teams devices |
| New device registration or PRT issuance within 10 minutes of device code authentication (T1098.005) | Entra ID device registration logs | Persistence | Low — rapid device join after device code auth is uncommon |
| Anomalous volume of Microsoft Graph API POST requests following device code flow sign-in (T1087.004) | Microsoft Graph API audit logs, Defender XDR | Discovery | Low — spike in Graph API calls after device code auth is suspicious |
| Inbox rule creation immediately after device code authentication sign-in event (T1098) | Exchange admin audit logs, Microsoft 365 audit logs | Persistence | Medium — users may legitimately create rules |
Required Log Sources
- Entra ID sign-in audit logs
- Microsoft 365 audit logs
- Defender for Office 365 alerts
- DeviceEvents BrowserLaunchedToOpenUrl
- EmailEvents delivery logs
- Microsoft Graph API activity logs
Control Gaps
- Standard session revocation leaves access tokens active for up to one hour
- Legacy email gateways bypassed by multi-stage redirect chains
- Domain blocklists ineffective against legitimate cloud platform abuse
- Device code flow not blocked by default in Entra ID
- Phishing-resistant MFA not enforced for all users
Recommendations
Infrastructure Hardening
- Configure anti-phishing policies and enforce spoof protections in email gateways
- Enable Zero-hour auto purge and set Advanced Phishing Threshold to 2 or 3
- Block legacy authentication protocols via Conditional Access in Microsoft Entra ID
- Implement sign-in risk policy to automate response to risky authentication events
User Protection
- Require phishing-resistant MFA such as FIDO tokens or Microsoft Authenticator passkeys
- Enable Microsoft Defender SmartScreen on endpoints to block malicious websites
- Centralize identity management and integrate on-premises directories with cloud directories
- Audit privileged account activity and enforce principle of least privilege
MITRE ATT&CK Mapping
- domainsmartviewdevices[.]comEvilTokens infrastructure domain for phishing kit operations