M365 Identity Device Code Grant by an Unusual User (Non-Compliant Device)

Last updated 18 days ago on 2026-06-02
Created 18 days ago on 2026-06-02

About

Identifies a Microsoft 365 user completing an OAuth device code grant ("Cmsi:Cmsi") from a non-compliant device for the first time within the rule's historical window, regardless of the requesting application or target resource. Device code phishing kits complete the full login (password and MFA) at the genuine Microsoft endpoint and harvest the resulting token by polling, so MFA does not stop them. Because the victim authorizes the flow in their own browser, the grant is frequently completed on a personal or attacker-controlled device that is not enrolled or compliant with the organization's device policies. A user appearing with this device code flow on a non-compliant device for the first time in the lookback window is a strong early indicator of device code phishing, and removing the application and target constraints catches grants against any first-party application, not just the Microsoft Authentication Broker.
Tags
Domain: CloudDomain: SaaSDomain: IdentityData Source: Microsoft 365Data Source: Microsoft 365 Audit LogsUse Case: Identity and Access AuditUse Case: Threat DetectionTactic: Initial AccessLanguage: kuery
Severity
medium
Risk Score
47
MITRE ATT&CK™

Initial Access (TA0001)(external, opens in a new tab or window)

Defense Evasion (TA0005)(external, opens in a new tab or window)

False Positive Examples
A user legitimately using the device code flow for the first time on a personal or otherwise non-compliant device, such as a smart TV, kiosk, IoT device, conference room device, or a personal laptop for a CLI or headless developer workflow. Review the source ASN, geolocation, application, and the user's device posture to confirm whether the activity is expected before escalating.
License
Elastic License v2(external, opens in a new tab or window)

Definition

Rule Type
New Terms Rule
Integration Pack
Prebuilt Security Detection Rules
Index Patterns
logs-o365.audit-*
Related Integrations

o365(external, opens in a new tab or window)

Query
text code block:
event.dataset: "o365.audit" and o365.audit.ExtendedProperties.RequestType: "Cmsi:Cmsi" and o365.audit.Actor.Type: (0 or 2 or 3 or 5 or 10) and o365.audit.DeviceProperties.Value: "False"

Install detection rules in Elastic Security

Detect M365 Identity Device Code Grant by an Unusual User (Non-Compliant Device) in the Elastic Security detection engine by installing this rule into your Elastic Stack.

To setup this rule, check out the installation guide for Prebuilt Security Detection Rules(external, opens in a new tab or window).