Azure-Sentinel: Successful logon from IP and failure from a different IP - missing code line

Describe the bug The rule name as title states are very noisy in my portal. It seems to be triggering on failed ip and success ip where they actually are the same as well. This is not what the rule is described to do. I therefore added a simple line to avoid this:

| where SuccessIPAddress != FailedIPAddress

Complete rule:

let logonDiff = 10m;
let aadFunc = (tableName:string){
table(tableName)
| where ResultType == "0"
| where AppDisplayName !in ("Office 365 Exchange Online", "Skype for Business Online") // To remove false-positives, add more Apps to this array
| project SuccessLogonTime = TimeGenerated, UserPrincipalName, SuccessIPAddress = IPAddress, AppDisplayName, SuccessIPBlock = strcat(split(IPAddress, ".")[0], ".", split(IPAddress, ".")[1]), Type
| join kind= inner (
    table(tableName)
    | where ResultType !in ("0", "50140")
    | where ResultDescription !~ "Other"
    | where AppDisplayName !in ("Office 365 Exchange Online", "Skype for Business Online") // To remove false-positives, add more Apps to this array
    | project FailedLogonTime = TimeGenerated, UserPrincipalName, FailedIPAddress = IPAddress, AppDisplayName, ResultType, ResultDescription, Type
) on UserPrincipalName, AppDisplayName
| where SuccessLogonTime < FailedLogonTime and FailedLogonTime - SuccessLogonTime <= logonDiff and FailedIPAddress !startswith SuccessIPBlock
| summarize FailedLogonTime = max(FailedLogonTime), SuccessLogonTime = max(SuccessLogonTime) by UserPrincipalName, SuccessIPAddress, AppDisplayName, FailedIPAddress, ResultType, ResultDescription, Type
| extend timestamp = SuccessLogonTime
};
let aadSignin = aadFunc("SigninLogs");
let aadNonInt = aadFunc("AADNonInteractiveUserSignInLogs");
union isfuzzy=true aadSignin, aadNonInt
| extend Name = tostring(split(UserPrincipalName,'@',0)[0]), UPNSuffix = tostring(split(UserPrincipalName,'@',1)[0])
| where SuccessIPAddress != FailedIPAddress

Expected behavior Should avoid triggering on incidents where the failure and the successfull login are from the same IP, rather when a successfull trigger happens and is followed by a failed IP within 10 minutes on the same app.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 18 (11 by maintainers)

Most upvoted comments

Hi @v-vdixit , for security reasons, I would suggest comparing the first 3 sections of an IPv6 at minimum as this will be the site prefix. More information can be found here

Hi @bittib010 Hi we have received a suggestion that we should compare first two parts of IPv6 also and not the entire IP, can you please check and confirm if that works as a resolution for you, thanks!

@best-geek , Hey - thank you for replying! 😃 It seems like IPv6 is the reason behind it, yes. In combination this seem to work, in theory at least. I also adjusted the project in your snippet to fit the rest of the code and then ran it. It ran for more than 7 minutes before i gave up. I havent dug too deep into why this would not work. Any idea?

Do we have to look at ip blocks? The only thing we are looking for is difference in failed and success ip, right?