Microsoft Device Code Phish Steals Tokens, Not Passwords

InfoSec Write-ups · High sophistication
Last updated July 30, 2026

This article demonstrates a phishing method that tricks users into signing in on Microsoft’s real login page and approving access for an attacker-controlled app. Instead of stealing a password, the attacker captures a valid Microsoft access token that can be used to access Microsoft 365 data like email, OneDrive, SharePoint, and Teams.

How the attack worked

The attack begins with an email that claims Microsoft detected unusual sign-in activity and urges the recipient to secure their account immediately. Instead of linking directly to a fake Microsoft login page, the email sends the victim to an attacker-controlled verification site first. That site displays a device code and instructions, along with a button that opens Microsoft's genuine Device Login page at login.microsoftonline.com.

The victim enters the code on Microsoft's real domain and clicks Continue, believing they are verifying or protecting their account. In reality, they are approving an authorization request for an attacker-controlled application. Once approved, the attacker receives a valid Microsoft access token rather than a password, which can be used through Microsoft Graph to reach resources such as email, OneDrive, SharePoint, and Teams, depending on the permissions granted.

Why it succeeded

This technique is effective because it abuses a legitimate Microsoft authentication workflow rather than imitating it. Every critical step, including the sign-in itself, happens on Microsoft's real domain, which removes the usual visual cues people are trained to spot, like misspelled URLs or fake login pages. The attacker-controlled site only handles the initial redirect and code display, while Microsoft's own infrastructure handles the sensitive part of the flow, making it harder for victims to sense anything is wrong.

What to watch for

  • Unexpected emails about unusual sign-in activity that push for immediate action
  • Being sent to a third-party "verification portal" before reaching any Microsoft page
  • A prompt to enter a device code you did not request
  • An authorization or consent screen for an application you don't recognize

Building resistance

Organizations and individuals can reduce risk from this technique by treating any unrequested device-code or authentication prompt as suspicious and verifying it through a separate, trusted channel before proceeding. Employees should be reminded that seeing Microsoft's legitimate domain during a login flow is not proof the overall request is safe, since attackers can trigger real login steps as part of a larger scheme. Regularly reviewing and removing unfamiliar applications connected to a Microsoft account, and revoking sessions and permissions quickly if an unexpected approval occurs, can limit the damage if someone does approve a request by mistake. Security and IT teams should also reinforce awareness of urgency-based lures, such as claims of unusual sign-in activity, since this pressure tactic is central to getting victims to act without pausing to verify.

Key findings

  • The lure is an email claiming Microsoft detected “unusual sign-in activity” and urging immediate action.
  • Victims are sent to an attacker-controlled verification site that shows a device code and instructs them to authenticate via Microsoft’s official device login page.
  • The victim signs in on Microsoft’s legitimate domain and clicks “Continue,” unknowingly authorizing an attacker-controlled application.
  • The attacker captures a Microsoft access token (not a password) and can use it to access Microsoft 365 resources via Microsoft Graph, depending on granted permissions.

Who’s being targeted

  • Commonly targeted roles: All employees, Executives, IT helpdesk / IAM team, Security team.
  • Affected industries: Any organization using Microsoft 365.
  • Attack channels: email, website.
  • Impersonated: Microsoft Security / Microsoft account team, Microsoft verification flow (lookalike portal).

Red flags to watch for

  • Unexpected request to authenticate/verify when the user did not initiate a login
  • Link goes to an attacker-controlled site first (a “verification portal”) before Microsoft sign-in
  • Authorization is being granted to an application the user didn’t intend to connect
  • A third-party page provides the code and instructions (not initiated by the user from a known app/device)
  • The user is asked to authorize an access request they weren’t expecting
  • High trust cues (real Microsoft login) are used to bypass skepticism
Try Mirage

Mirage safely runs attacks like this one against your own team, so you find out what happens before a real adversary does.

Get a demo

Frequently asked questions

What is device code phishing?

It is a phishing technique where a victim is led to enter a code on Microsoft's legitimate device login page, unknowingly authorizing an attacker-controlled application to access their account.

Does device code phishing steal passwords?

No, the attacker captures a valid Microsoft access token rather than a password, which can then be used to access Microsoft 365 resources like email, OneDrive, and Teams.

Why is this attack considered effective?

Because every key step, including the actual sign-in, happens on Microsoft's real login domain, which makes the flow look trustworthy even though the victim is authorizing an attacker's app.

How can someone tell they were targeted by this?

Red flags include receiving an unexpected urgent email about unusual sign-in activity, being sent to a separate verification site before reaching Microsoft, and being asked to approve access to an app the user did not intend to connect.

Read the video transcript

You get an email: “Microsoft detected unusual sign-in activity. Secure your account now.” Looks urgent, looks legit, right? You click. It sends you to a fake ‘Microsoft verification portal’ with a device code and a big button. That button opens the real Microsoft Device Login page at login.microsoftonline.com. You sign in, see Microsoft’s real domain, and click Continue, thinking you’re protecting your account. Aha: you just approved an attacker-controlled app that grabs a Microsoft access token to your email, OneDrive, SharePoint, maybe even Teams. Remember this: if you didn’t start a sign-in or device-code flow yourself, don’t approve it. Close it, then check your Microsoft account security from the official portal instead.

Similar attacks

Malicious CSS Emails Can Hijack Webmail UI

Malicious CSS Emails Can Hijack Webmail UI

PortSwigger research shows how attackers can weaponize HTML/CSS inside emails to cross trust boundaries in webmail, including UI manipulation, token theft, and password theft. The paper highlights real-world weaknesses in email sanitization and gives concrete examples (including an Outlook…

August 6, 2026
Fake Recruiters Target Job Seekers With Malware

Fake Recruiters Target Job Seekers With Malware

Iran-aligned DarkBlinders used convincing recruitment offers while posing as Dubai Airports recruiters to target a high-value job seeker in Iraq. The victim was asked to complete what appeared to be a coding assessment, but the assessment package installed malware. The group also used lookalike…

November 2, 2026
North Korea Scales AI-Powered Job Scams

North Korea Scales AI-Powered Job Scams

Microsoft reports that North Korean threat actors are using AI to make job scams, fake recruiter outreach, fraudulent worker identities, and targeted phishing campaigns faster and more convincing. One group posed as recruiters for a spoofed AI blockchain company and scheduled software-engineer…

October 29, 2026
Fake Anthropic Preview Steals Work Logins

Fake Anthropic Preview Steals Work Logins

Threat actors sent fake invitations to an exclusive Anthropic AI preview to steal Google and Microsoft work credentials. The campaign abused trusted services, including GoTo Webinar and a URL shortener, then used CAPTCHA pages and convincing fake login screens to make detection harder. Employees…

October 29, 2026
GhostAction Phishes Developers With Fake GitHub Alert

GhostAction Phishes Developers With Fake GitHub Alert

GhostAction attackers sent a fake GitHub security alert to an open-source maintainer, claiming a login from Moscow and directing the victim to secure their account. The fake site stole the victim’s password and two-factor code, then silently approved a powerful GitHub OAuth connection that let the…

October 19, 2026
RFQ Emails Used to Trick Staff Into Login Theft

RFQ Emails Used to Trick Staff Into Login Theft

Researchers observed a surge in short "request for quotation" (RFQ) emails that look like routine business inquiries to sales and procurement teams. After the victim replies, attackers send a follow-up link disguised as project documents or a procurement portal that leads to a fake Microsoft…

October 16, 2026