How a hacker gets into your business with device code phishing: your own employee approves access and the hacker is now in. A hand points at the reader. Hero image with Shawn May, Principal Security Architect.

What Is Device Code Phishing?

December 03, 2026•10 min read

Start here

Welcome. Maybe you’ve seen “device code phishing” in the news or on social media, heard about the enormous financial losses it’s caused businesses, or maybe someone at work brought it up, and now you’re curious how a hacker actually pulls it off. You’ve come to the right place to learn how it works in a Microsoft 365 cloud environment, starting with the basics. If the topic feels a bit nebulous (hazy and hard to pin down) right now, that’s completely normal. It sounds technical, and it can be confusing at first.

In short: Device code phishing is a scam where a hacker gets a sign-in code from Microsoft, then tricks your employee into entering it at microsoft.com/devicelogin. Your employee signs in and approves MFA, but the hacker gets access to their Microsoft 365 account. No fake sign-in page, no stolen password. Your own employee signed the hacker in.

I’ve done my best to keep this simple. We start with the fundamentals here (the light layer, written for owners and leaders). The advanced material comes later in the series, and that’s the part your technologists will want, because they’ll need more detail to protect your business.

We’re focused on one place: your business’s Microsoft 365 account (the email, files and Teams your people sign in to every day). This article will elucidate (make clear) a few questions:

  • How does a hacker get in without ever stealing a password?

  • Why doesn’t MFA (the extra sign-in check on your phone) stop them?

  • What’s the one habit that shuts it down?

You’ll get the basics first, then see who’s involved (the hacker, your employee and Microsoft 365), then press play and watch it happen. Want to see it right now? Skip ahead to the simulator, then come back for the basics anytime.

Jump to the simulatorJump to the beginner simulatorJump to the advanced simulator

Have a question as you read? Contact Shawn to schedule a call.

The basics

How does device code flow work in Microsoft 365?

Every work sign-in to Microsoft 365 goes through Microsoft Entra ID (Microsoft’s sign-in service, the front desk that checks who you are). Usually you sign in on the device in front of you. But some devices can’t show a sign-in page, so they use device code flow (Microsoft’s version of an OAuth 2.0 standard).

At work, that’s a Teams meeting-room console or desk display, or a server with no web browser where your IT staff run the Azure CLI (a command-line tool). When that happens, the device shows a code, and someone signs it in from their own computer. (Work accounts, not the smart TV at home.)

Here’s how it works:

  1. The device asks Microsoft Entra ID for a code.

  2. It then shows you the code and a web address (microsoft.com/devicelogin).

  3. You open that address on your own computer or phone, type the code, sign in and approve MFA (the code expires after 15 minutes).

  4. Then Microsoft Entra ID sends the access to the device that asked for the code, not to the computer you signed in on.

How does device code phishing abuse this flow?

Here’s the catch. Device code phishing flips the roles. The hacker (labeled Attacker in the simulator) requests the code, then sends it to your employee with a believable reason (a Teams invite, a shared file, a voicemail). Your employee then types it on Microsoft’s legitimate page and approves MFA, so step 4 hands the access to the hacker.

That’s the whole trick. Now watch it happen.

What you’ll see

Before you press play

The simulator replays this attack in about 12 seconds (it’s a teaching model, not a live tenant). So here’s what you’re looking at.

Attacker (top left)The criminal’s computer. It starts the sign-in.

Employee (top right)Dana in Finance or Marcus, an admin. You pick who gets phished before you press play.

Microsoft 365 | Entra ID (bottom center)Microsoft’s sign-in service and the data behind it.

The arrows

Blue: the normal device code steps (asking for a code and getting it back)

Red: the attack

Green: the MFA approval

While it plays, watch one thing: which box ends up holding the access token (the digital pass that lets an app back in without a password).

Try it yourself

Watch it happen

Pick who gets phished, then press play and follow the attack one step at a time.

  • Where does the code come from?

  • Why doesn’t MFA stop it?

  • Who ends up with the access?

Open the simulator

How to use the device code phishing simulator

  1. Pick who gets phished: Dana in Finance (data stolen) or Marcus, an admin (admin takeover).

  2. Watch it happen: press the big red button (Watch how the attacker got in) or Play.

  3. Walk it step by step: use Previous and Next, or click any step in the list. Then open View step details to read what happens at each step.

Device code phishing simulator (custom code)

This simulator is an illustration based on documented attacks. Dana and Marcus are made up, and the simulator also assumes nothing in the tenant blocks device code flow.

Not sure whether device code flow is open in your tenant? Then contact Shawn to schedule a call.

Why it works

Why doesn’t MFA stop device code phishing?

MFA checks that it’s really you signing in (your password plus the approval on your phone). But it doesn’t check which device ends up with the access.

Attacker gets a code → sends it to you → you enter it and approve MFA → the attacker’s computer is signed in

So Microsoft Entra ID sends the access to the device that asked for the code (here, the attacker’s computer). From there it can get into your email and files and stay in until its tokens expire or IT cuts them off. It also never needed your password.

Stay safe

The one habit that stops device code phishing

Only enter a device code when you started the sign-in yourself, on a device or machine you’re working on (a Teams device you’re setting up, or a server where you just ran the Azure CLI).

So if a code shows up in an email, a chat or a meeting invite, don’t type it in. Instead, report it to your IT team or service desk. Microsoft’s advice for IT teams goes further: block device code flow wherever possible (in Microsoft Entra ID, that’s done with Conditional Access). The FBI then gave the same advice in May 2026.

Want to learn how to shut device code phishing down in your own tenant? Start with the free lecture, or talk it through with Shawn instead.

Join the free lecture Schedule a call

Frequently asked questions

What is a device code phishing attack?

It’s a scam where a hacker gets a sign-in code from Microsoft, then tricks your employee into typing it at microsoft.com/devicelogin (Microsoft’s legitimate page for signing in a device). The hacker sends the code with a specious (believable, but false) reason, like a Teams invite, a shared file or a voicemail. Your employee signs in and approves MFA (the extra sign-in check on their phone), but the hacker gets access to their Microsoft 365 account. There’s no fake sign-in page and no stolen password.

Should I block device code flow?

Yes. Microsoft advises IT teams to block device code flow (Microsoft’s way to sign in a device that can’t show its own sign-in page) wherever possible. The FBI’s advice in May 2026 hews to (follows closely) Microsoft’s. Device code phishing (a scam that tricks you into typing in a hacker’s sign-in code) abuses that same flow, and MFA (the extra sign-in check on your phone) doesn’t stop it.

How to block device code authentication?

Your IT team blocks device code flow (Microsoft’s way to sign in a device that can’t show its own sign-in page) with Conditional Access (Microsoft’s security controls for anyone entering or using Microsoft 365). They set that up in Microsoft Entra ID (Microsoft’s cloud sign-in service). Microsoft advises IT teams to block it wherever possible.

How to access device code?

On a legitimate sign-in, the device or machine you’re working on shows the device code (a short sign-in code) on its own screen, along with the address microsoft.com/devicelogin. You open that address on your own computer or phone, type the code, sign in and approve MFA (the extra sign-in check on your phone). If a code shows up in an email, a chat or a meeting invite instead, don’t type it in. Report it to your IT team or service desk.

What does device code mean?

A device code is a short code a device shows you, so you can sign that device in at microsoft.com/devicelogin from your own computer or phone. Devices that can’t show a sign-in page use it, like a Teams meeting-room console or a server with no web browser. Microsoft’s codes expire after 15 minutes.

What is device code flow in Microsoft?

It’s Microsoft’s way to sign in a device that can’t show its own sign-in page, like a Teams meeting-room console or a server with no web browser. The device asks Microsoft Entra ID (Microsoft’s cloud sign-in service) for a code, then shows you the code and the address microsoft.com/devicelogin. You type the code there on your own computer or phone, sign in and approve MFA (the extra sign-in check on your phone). Microsoft Entra ID then sends the access to the device that asked for the code, not to the computer you signed in on.

Glossary

  • Conditional Access: Microsoft’s security controls for those entering or interacting with Microsoft 365. It can also block device code flow.

  • Device code: A short code a device shows you so you can sign it in at microsoft.com/devicelogin from your own computer or phone. Microsoft’s codes expire after 15 minutes.

  • Device code flow: Microsoft’s way to sign in a device that can’t show its own sign-in page, like a Teams meeting-room device or a server with no web browser. It’s based on the OAuth 2.0 device authorization standard.

  • Device code phishing: An attack where someone else starts a device code sign-in and tricks you into entering their code, so their computer gets signed in as you.

  • MFA (multifactor authentication): A second check when you sign in, like approving a prompt on your phone.

  • Microsoft Entra ID: Microsoft’s cloud sign-in service. It handles work sign-ins for Microsoft 365 as well as Azure.

  • Passkey: A sign-in method that uses your device (a fingerprint, your face or a PIN) instead of a password.

  • Token: A digital pass a device gets after a successful sign-in. It lets the device back in without your password until it expires or is revoked.

Sources

Microsoft sources:

FBI warning:

Security research:

OAuth standard:

Back to Blog

About the author

Shawn May, Principal Security Architect at Dynamic Technical Solutions

Written by Shawn May, founder of Dynamic Technical Solutions (DTS). Enterprise identity and security architect with over 30 years of IT experience, specializing in Microsoft identity security, IAM, and technical mentoring. LinkedIn · My story · Contact

On This Page

The links to this article’s sections fill in here when the page loads.

Shawn May

Talk to Shawn

Questions about your own tenant?

Disclaimer

This article provides independent educational guidance from Dynamic Technical Solutions (DTS), based on information and Microsoft documentation available at the time of publication or most recent revision. Microsoft may change features, settings, policies, and procedures. Review the linked Microsoft sources for current guidance and confirm applicability to your environment before making changes.

DTS is not affiliated with, endorsed by, or sponsored by Microsoft. Microsoft, Microsoft 365, Microsoft Entra, Microsoft Graph, Microsoft Teams, SharePoint, and OneDrive are trademarks of the Microsoft group of companies. All other product names and trademarks belong to their respective owners.