Entra ID & AiTM Detection · T1528 / T1566

Device Code Flow Phishing Detection in Microsoft Entra ID Sign-In Logs

Direct Answer (Key Forensic Takeaway)

In Microsoft Entra ID Sign-In logs, OAuth Device Code Phishing surfaces explicitly as authenticationProtocol = "deviceCode"—often tied to Microsoft first-party apps like Microsoft Authentication Broker or Azure CLI—where the attacker polling IP differs completely from the victim IP that typed the 8-character code on the genuine microsoft.com/devicelogin page.

Detection Objective & Threat Scope

Unlike fake login pages that have to spoof Microsoft’s branding on an untrusted lookalike domain, Device Code Flow phishing sends victims directly to the legitimate `https://microsoft.com/devicelogin` URL.

An attacker generates a fresh OAuth device authorization code from a VPS, emails or Teams-messages the victim pretending to share an encrypted document or Teams meeting setup, and convinces the employee to enter the 8-character code and approve MFA on Microsoft’s own official domain. The second the victim clicks Accept, Entra hands full OAuth tokens straight to the attacker’s polling script.

Standard third-party OAuth consent restrictions do NOT block Device Code phishing because threat actors specify Microsoft first-party Client IDs (such as `Microsoft Authentication Broker`, `Microsoft Office`, or `Azure CLI`), which are pre-authorized in nearly every tenant.

Fortunately, Entra Sign-In logs mark every device-code authentication unmistakably inside `authenticationProtocol: "deviceCode"`. Pairing `authenticationProtocol = deviceCode` searches with Geo-Velocity (`AV-009`) exposes device-code phishing immediately.

1. RAW TELEMETRY Entra ID & AiTM Detection T1528 / T1566 2. CLIENT-SIDE PARSE AuditVane Engine device code phishing Entra ID logs 0 Bytes Uploaded 3. SOC OUTCOME Scoped Containment IOCs · CSV · KQL
Local browser DFIR workflow for device code phishing Entra ID logs (T1528 / T1566)
AdSense-Ready In-Article Placement

Forensic Telemetry Fields & High-Signal Indicators

Telemetry Field / Pattern Meaning in M365 / Entra High-Signal Threat Indicator
authenticationProtocol = deviceCodeExplicit Entra marker for OAuth device code flowExtremely rare for normal office/HR/finance staff
appDisplayName = Microsoft Authentication BrokerCommon first-party client spoofed in kitsAlso watch Azure CLI & Microsoft Office IDs
resourceDisplayName = Microsoft GraphHigh-privilege scopes requestedGrants mail, Teams, SharePoint & directory APIs
Attacker IP != Victim IPAttacker VPS polls Microsoft token endpointTriggers AV-009 multi-country/IP correlation
userAgent = python-requests / curlPolling script HTTP clientTriggers AuditVane AV-003 Critical
CA Authentication Flows ControlConditional Access policy blocking deviceCodePermanent preventive fix in Entra ID

Hunt Device Code Sign-Ins in Sentinel KQL & Graph PowerShell

// Sentinel KQL hunt for Device Code authentications:
SigninLogs
| where AuthenticationProtocol == "deviceCode"
| project TimeGenerated, UserPrincipalName, IPAddress, AppDisplayName, ResourceDisplayName, Location, UserAgent, ResultType

# PowerShell Microsoft Graph check:
Get-MgAuditLogSignIn -Filter "authenticationProtocol eq 'deviceCode'" -Top 200 |
  Select-Object CreatedDateTime, UserPrincipalName, IpAddress, AppDisplayName, @{N="Err";E={$_.Status.ErrorCode}}

Sample Device Code Hunt Hit

CreatedDateTime      UserPrincipalName          IpAddress      AppDisplayName                Err
---------------      -----------------          ---------      --------------                ---
2026-12-03T11:04:19Z engineer@contoso.invalid   185.220.101.45 Microsoft Authentication Broker 0

Device Code Phishing vs. Standard Third-Party OAuth Consent Phishing

AttributeThird-Party OAuth Consent PhishOAuth Device Code Flow Phish
Client App UsedAttacker-registered multi-tenant AppIdMicrosoft first-party Client IDs (Broker, Office, Azure CLI)
Blocked by User Consent Lock?Yes — "Do not allow user consent" stops itNO — First-party Microsoft apps bypass third-party consent locks
Key Sign-In Log FieldConsent to application / OAuth2PermissionGrantauthenticationProtocol = "deviceCode"
Preventive CA ControlEnterprise App User Consent settingsConditional Access -> Authentication flows -> Block Device code

Entra Device Code Flow Sign-In JSON Sample

{
  "createdDateTime": "2026-12-03T11:04:19Z",
  "userPrincipalName": "engineer@contoso-demo.invalid",
  "appDisplayName": "Microsoft Authentication Broker",
  "resourceDisplayName": "Microsoft Graph",
  "authenticationProtocol": "deviceCode",
  "ipAddress": "185.220.101.45",
  "userAgent": "python-requests/2.32.3",
  "conditionalAccessStatus": "success",
  "status": { "errorCode": 0 }
}

Notice the combination of authenticationProtocol: "deviceCode", Microsoft Authentication Broker, and python-requests/2.32.3—confirming a polling script captured the token remotely.

Real-World Incident Walkthrough

A threat actor messages three engineers via external Teams chat posing as "Enterprise Collaboration Upgrade" and instructs them to verify their device at `microsoft.com/devicelogin` using code `C8V9K2M1`. One engineer completes the prompt from Chicago, approving their own MFA.

Within 2 seconds, the attacker’s Python script in Amsterdam (`185.220.101.45`) finishes polling the token endpoint and receives a valid Microsoft Graph refresh token—recorded in Entra Sign-In JSON with `authenticationProtocol: "deviceCode"`, `appDisplayName: "Microsoft Authentication Broker"`, and `ipAddress: "185.220.101.45"`.

Step-by-Step Triage, Containment & Verification

  1. Export Entra Interactive and Non-Interactive Sign-In JSON and drop into AuditVane.
  2. Type `deviceCode` into AuditVane’s Search bar (this matches `authenticationProtocol: deviceCode` inside the flattened Event Inspector).
  3. Inspect every IP address, UserAgent (`AV-003`), and downstream Graph/Exchange event tied to that `sessionId`.
  4. Run `Revoke-MgUserSignInSession` immediately to invalidate the attacker’s issued refresh token.
  5. Deploy a Conditional Access policy targeting **All Users -> All Resources -> Condition: Authentication flows -> Device code flow -> Grant: Block access** (excluding only explicitly vetted IoT/meeting-room service accounts if any exist).

How to Verify Containment Completed Cleanly

  • Zero unexpected authenticationProtocol = deviceCode successes in the past 30 days.
  • Conditional Access policy blocking Device Code flow enabled and confirmed blocking test attempts (error 53003).
  • Compromised user sessions revoked and Purview UAL swept for mail/SharePoint access.

Analyst Blind Spots, Licensing Quirks & False Positives

Because the employee enters the device code on the genuine `microsoft.com/devicelogin` URL and satisfies MFA themselves, MFA notifications show the employee’s own approval—never assume an approved MFA prompt proves the session wasn’t phished via Device Code.

Even Conditional Access policies requiring FIDO2/Passkeys will succeed during Device Code phishing unless you explicitly block the Device Code authentication flow or enforce Compliant Device.

Frequently Asked Questions

Does standard MFA or FIDO2 stop Device Code Phishing?

No! The victim happily completes their own MFA or FIDO2 login on microsoft.com/devicelogin, which hands the resulting token directly to the attacker’s remote poller.

Can you block Device Code flow completely in Microsoft Entra ID?

Yes. Entra Conditional Access includes a dedicated "Authentication flows" condition allowing you to block "Device code flow" tenant-wide.

How do I check for Device Code phishing inside AuditVane?

Load your Entra Sign-In JSON file into AuditVane and type `deviceCode` in the Search bar to inspect all matching events.

Why didn’t restricting User OAuth Consent stop this attack?

Because Device Code kits impersonate Microsoft’s own pre-authorized first-party client IDs (such as Azure CLI or Microsoft Office).

Related Forensics Guides