Credential Access (TA0006)(external, opens in a new tab or window)
Persistence (TA0003)(external, opens in a new tab or window)
Initial Access (TA0001)(external, opens in a new tab or window)
text code block:sequence by related.user with maxspan=30m [authentication where event.action == "UserLoggedIn" and o365.audit.ExtendedProperties.RequestType == "OAuth2:Authorize" and o365.audit.ExtendedProperties.ResultStatusDetail == "Redirect" and o365.audit.UserType: ("0", "2", "3", "10")] // victim source.ip [authentication where event.action == "UserLoggedIn" and o365.audit.ExtendedProperties.RequestType == "OAuth2:Token" and o365.audit.ExtendedProperties.ResultStatusDetail == "Success"] // attacker source.ip to convert oauth code to token [web where event.dataset == "o365.audit" and event.action == "Add registered users to device."] // user.name is captured in related.user
Install detection rules in Elastic Security
Detect M365 Identity OAuth Flow by User Sign-in to Device Registration 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).