If you run a Microsoft 365 tenant — and if you are reading this, you almost certainly do — there is a good chance attackers are already inside your environment. Not through a brute force attack. Not through a phishing email you missed. Through a feature Microsoft built to help devices that cannot run a browser authenticate to your tenant: the OAuth 2.0 device authorization flow.

Security researchers at eSentire published analysis in late August 2026 of a new phishing kit they are tracking as GhostCode. It is live. It works. And it has already compromised Microsoft 365 tenants by exploiting a flow most IT admins never think about — and may not even know exists.

How GhostCode Works — and Why It Matters for Your Business

Device code authentication was designed for IoT devices, smart TVs, and printers — devices that cannot display a full login page. Instead, the device shows a code, and the user enters that code on a separate browser to authenticate. It is a convenience feature, and like most convenience features in security, it creates a blind spot.

GhostCode weaponizes this flow in four steps:

  1. The attacker poses as an interested buyer or partner — typically reaching out through a web contact form, then moving the conversation to an NDA-themed HTML file.
  2. Opening the file triggers a Microsoft OAuth device code request initiated by the attacker-controlled device. The victim sees a legitimate Microsoft login screen and enters the code shown.
  3. The victim enters their credentials and completes MFA — because everything looks normal. Microsoft is not the attacker. The victim is authenticating the attacker’s device into their own tenant.
  4. The attacker receives valid authentication tokens — including a Primary Refresh Token (PRT) that gives them SSO-equivalent access to your entire M365 environment for up to 14 days by default.

In the campaign eSentire observed, the attackers registered three attacker-controlled devices into the victim tenant within 78 seconds of authentication. One of those devices was enrolled in Microsoft Intune — and critically, Intune enrollment survives token revocation. Even after you realize something is wrong and rotate tokens, the attacker device stays registered until you remove it manually.

Why Q4 Is Prime Time for This Attack

We are entering October. For most businesses, that means:

  • Vendors and contractors flooding in for Q4 projects
  • Procurement reviews and contract negotiations
  • Holiday staffing gaps in IT and security teams
  • Elevated pressure to keep things running, not lock things down

GhostCode-style attacks exploit exactly this chaos. The social engineering preys on procurement workflows — a fake vendor sends an NDA, the recipient clicks, and the attacker is in. Q4 is when your team is least likely to stop and scrutinize an authentication flow that looks legitimate because it is legitimate. Microsoft designed it. Microsoft runs it. The login page is real. The MFA prompt is real. The problem is who is on the other end of that token.

Five Steps to Lock Down Your Tenant This Week

Here is what you can do right now — before GhostCode or something worse finds its way into your tenant:

  1. Restrict device code authentication. Go to your Entra ID Conditional Access policies and block the device code flow for all users except those who genuinely need it. Most organizations have zero users who need it. Block the whole thing.
  2. Audit your device registrations. Check the Device Registration Service in Entra ID for devices registered outside normal business hours, devices with unusual naming patterns, or multiple devices registered from a single non-interactive session.
  3. Monitor for python-requests user agent after device code auth. eSentire observed attackers using the Python requests library for API calls immediately after authentication. If you see device code auth followed by Python-based API activity, treat it as a breach until proven otherwise.
  4. Review Conditional Access policies for device compliance requirements. If a PRT is issued to a non-compliant device, Conditional Access policies that require compliant devices can still block access to sensitive resources. Make sure your policies actually do this.
  5. Create a manual device removal process. Intune-enrolled devices from GhostCode-style attacks survive token revocation. Your incident response plan needs a step to check Device Registration Service and Intune enrolled devices during containment.

The Bottom Line

GhostCode is not exotic. It does not exploit a zero-day vulnerability. It abuses a legitimate feature that Microsoft built, that works exactly as designed, and that most M365 admins have never reviewed. That is what makes it dangerous — and that is also what makes it preventable.

The attacks are automated, cheap for the attacker (eSentire estimates under $100 per targeted company), and they work because device code authentication is wide open in most tenants.

Close it. Audit what is already registered. And do not wait until Q4 chaos gives an attacker the cover they are counting on.

Not sure where to start? Bryce Street can audit your M365 tenant, review your Conditional Access policies, and lock down device authentication flows — usually in half a day. Contact us to schedule a Q4 security posture review.