laptops

How Device Code Phishing Gets Past Microsoft 365 MFA (and How to Check Your Tenant)

You have MFA on, and your staff know not to type their password into strange websites. So how does someone still end up with access to a Microsoft 365 account?

One answer is device code phishing. The person signs in on Microsoft’s real page and approves MFA, and the attacker still walks away with the tokens. Hornetsecurity reported payment-themed campaigns using this method against Microsoft 365, as NeoTeo summarized. If you run a small business, this is worth twenty minutes of your attention.

What happened, in plain English

The lure in the reported campaigns was a payment document. In one analyzed path, the email carried a ZIP attachment. Inside was a file that looked like HTML but was actually an interactive SVG/XML document. Clicking the apparent security-check area redirected the browser.

The victim then landed on a fake SharePoint-style workspace showing payment documents and a code. The page told them to enter that code on Microsoft’s genuine device-authorization page. They did, and they completed MFA like normal.

Here is the part that trips people up. Device code sign-in is a real Microsoft feature, built for devices that are awkward to type on, like shared devices or digital signage. The device asks for a code, shows it to you, and you enter it on another screen. While you do that, the device keeps checking in the background to collect its tokens.

In this campaign, the attacker was the “device”. They started the request, so they were the ones collecting the tokens for whatever permissions the user approved.

Why a real sign-in page doesn’t save you

We teach people to check that the web address is genuine. That advice is still good, but here it doesn’t help. The page is real. What the page can’t tell you is who started the request.

MFA proved that the right person was present. It did nothing to change where the tokens were sent. A genuine sign-in page can authenticate you while authorizing the wrong client.

How to tell if it affects you

If your business uses Microsoft 365, the flow is available unless someone has restricted it. I can’t tell you from the source whether your tenant allows it by default, so check. Two questions matter:

  • Does anyone in your business legitimately use device code sign-in? For most small offices the honest answer is no. Shared devices and signage are the usual reasons it exists, and you’d know if you had them.
  • Has anyone used it recently? Your sign-in logs will show that.

What a device code sign-in looks like in the logs

This is how an analyst approaches it. The sign-in itself looks ordinary: a real user, a real Microsoft page, a successful MFA prompt. Nothing about it looks like a failed or blocked attempt. That’s why it’s easy to miss if you only look for failures.

The useful details are in how the sign-in was done. Microsoft’s guidance points to two fields in the Microsoft Entra sign-in logs:

  1. Filter by Authentication protocol to find device code sign-ins.
  2. Inspect Original transfer method. According to the source, this detail can preserve the device-code origin through later token refreshes, even when later activity uses another flow.

That second point matters. An attacker holding tokens doesn’t have to keep using device code. Later activity may look like something else, but the original transfer method can still point back to how it started.

If you send Entra sign-in logs into Microsoft Sentinel, the same information is available there and you can search across many users at once. If you don’t use Sentinel, the Entra admin center’s sign-in logs work for a small tenant.

Once you have a list of device code sign-ins, the standard questions apply. Does this person ever set up shared devices? Did the sign-in happen around the time they opened a payment email? Is the application one they’d normally use? A device code sign-in from someone who has never touched a shared device deserves a conversation with that person.

What to do today

  1. Audit legitimate use first. Microsoft recommends this before blocking anything. Check the logs for device code sign-ins and work out which, if any, are real.
  2. Build a Conditional Access policy. Under Authentication flows, choose Device code flow, and set the control to Block access. Microsoft recommends blocking the flow where possible.
  3. Start in Report-only mode. This shows what the policy would have blocked without blocking it. Review the results, then enforce.
  4. Review your exclusions. Microsoft advises checking them, including those for emergency-access accounts.
  5. Check device registration. If the policy targets all resources and your organization uses device code flow for device registration, the Device Registration Service may need to be excluded. Skipping this check could break something you rely on.
  6. Tell your staff one new rule. If a web page or email asks you to enter a code on a Microsoft page and you didn’t start setting up a device yourself, stop and ask. A payment document that needs a code before you can see it is not normal.

Ru Campbell’s January 2025 tutorial, mentioned in the source, walks through device code attacks and Conditional Access, including Report-only testing. It’s a good reference if you want to see the policy setup step by step.

Signs something may already have gone wrong

  • Device code sign-ins in your logs for people who don’t use shared devices or signage.
  • A user who remembers entering a code from an email or a document page, even if nothing seemed wrong afterward.
  • Sign-ins where Original transfer method shows device code, but later activity looks like a different flow.
  • A user who received a payment-themed email with a ZIP attachment and opened it.

Because the attacker holds tokens, not just a password, changing the password may not be enough. As general practice, an analyst would also revoke the user’s active sessions and review what the account did after the sign-in. The source doesn’t cover those steps in detail, so I’m leaving the specifics to Microsoft’s own documentation.

When to get help

If your audit finds device code sign-ins you can’t explain, treat the account as compromised until proven otherwise. Look at what that account could reach: email, files, anything connected to payments. If you can’t answer that confidently, bring in someone who investigates Microsoft 365 sign-in activity for a living.

Sources

Featured image: Image by StartupStockPhotos from Pixabay.

Leave a Comment

Your email address will not be published. Required fields are marked *