Query Details
//This query detects successful risky sign-ins followed by MFA registration
//Helps identify potential adversaries trying to achieve persistence through security info registration
let Threshold = 1440;
let signinEvents =
SigninLogs
| where TimeGenerated >= ago(1d)
| where ResultType == 0
| where RiskLevelDuringSignIn in ("high","medium","low") // Risky sign-ins only
| extend
PWResult = tostring(parse_json(AuthenticationDetails)[0].authenticationStepResultDetail),
MFAResult = tostring(parse_json(AuthenticationDetails)[1].authenticationStepResultDetail)
| project SignInTime = TimeGenerated, UserId = tolower(UserPrincipalName), RiskLevelDuringSignIn, SignInIPAddress = IPAddress, SignInLocation = Location, PWResult, MFAResult;
let authRegEvents =
AuditLogs
| where TimeGenerated >= ago(1d)
| where OperationName contains "User registered security info"
| where Result == "success"
| extend TargetUser = tostring(parse_json(TargetResources)[0].userPrincipalName)
| extend AuthRegIPAddress = parse_json(tostring(InitiatedBy.user)).ipAddress
| project AuthRegTime = TimeGenerated, UserId = tolower(TargetUser), OperationName, AuthRegResult = Result, AuthRegIPAddress;
signinEvents
| join kind=inner authRegEvents on UserId
| where AuthRegTime > SignInTime
| extend ["Minutes between actions"] = datetime_diff('minute', AuthRegTime, SignInTime)
| where ["Minutes between actions"] <= Threshold This query is designed to detect potentially suspicious behavior by identifying cases where a user has a successful risky sign-in followed by a multi-factor authentication (MFA) registration within a short time frame (less than or equal to 1440 minutes, or 24 hours). Here's a simplified breakdown of what the query does:
Define a Time Threshold: The query sets a time threshold of 1440 minutes (24 hours) to filter events.
Identify Risky Sign-ins:
ago(1d)).ResultType == 0) that are considered risky (risk levels: high, medium, or low).Identify MFA Registrations:
Join and Filter Events:
The purpose of this query is to help identify potential adversaries who might be trying to establish persistence in a system by registering security information shortly after a risky sign-in.

Robbie James
Released: November 10, 2024
Tables
Keywords
Operators