Home
%3CLINGO-SUB%20id%3D%22lingo-sub-1041500%22%20slang%3D%22en-US%22%3EAzure%20Sentinel%20correlation%20rules%3A%20the%20join%20KQL%20operator%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1041500%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3EIn%20the%20SIEM%20world%2C%20rules%20are%20often%20called%20correlation%20rules.%20While%20this%20is%20not%20always%20the%20case%2C%20and%20therefore%20I%20prefer%20the%20term%20detection%20rules%2C%20it%20conveys%20the%20importance%20of%20correlation%20for%20SIEM.%20What%20makes%20SIEM%20different%20from%20specialized%20security%20controls%20is%20the%20ability%20to%20correlate%20between%20events%20from%20multiple%20sources.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3ELast%20time%2C%20I%20presented%20the%26nbsp%3B%3C%2FSPAN%3E%3CA%20class%3D%22_e75a791d-denali-editor-page-rtfLink%22%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FAzure-Sentinel%2FAzure-Sentinel-correlation-rules-Active-Lists-out-make-list-in%2Fba-p%2F1029225%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3Euse%20of%20the%20make_list()%20KQL%20aggregation%20function%20to%20implement%20a%20correlation%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3E.%20It%20corresponds%20to%20the%20use%20of%20an%20explicit%20state%20machine%20for%20correlation%20in%20traditional%20SIEMs%20using%20%22Active%20Lists%22%20or%20%22reference%20sets%22.%20The%20Azure%20Sentinel%20version%20avoids%20the%20state%20machine%20and%20is%2C%20therefore%2C%20much%20simpler%20to%20build%20and%20maintain.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3EIn%20this%20post%2C%20I%20will%20describe%20implicit%20correlation%20rules%20and%20implementing%20them%20using%20the%20KQL%20operator%20join.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%225%22%3EImplicit%20correlation%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3ETraditional%20SIEMs%20offer%20an%20additional%20option%3A%20implicit%20correlation.%20Such%20a%20correlation%20rule%20relates%20two%20or%20more%20events%20and%2C%20if%20matching%2C%20would%20trigger%20an%20alert.%20Behind%20the%20scenes%2C%20the%20SIEM%20would%20maintain%20a%20state%3A%20once%20one%20of%20the%20events%20is%20received%2C%20let's%20call%20it%20the%20anchoring%20event%2C%20a%20context%20is%20created%20to%20%22remember%22%20this%20occurrence.%20In%20the%20ArcSight%20Jargon%2C%20this%20is%20called%20%22partial%20match%22.%20This%20context%20would%20be%20retained%20for%20the%20period%2C%20or%20%22window%22%2C%20stated%20for%20the%20correlation.%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3EThose%20implicit%20correlation%20rules%20are%20easier%20to%20create%20and%20maintain%20than%20explicit%20correlations%20but%20are%20very%20costly%20in%20terms%20of%20memory%20to%20keep%20all%20those%20open%20contexts.%20Pick%20a%20too%20common%20anchoring%20event%20(failed%20login%2C%20for%20example)%20and%20a%20long%20window%20(say%20an%20hour)%2C%20and%20your%20SIEM%20would%20saturate.%20This%20is%20why%20explicit%20correlation%20using%20lists%20is%20often%20preferred.%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20style%3D%22color%3A%20inherit%3B%20font-family%3A%20inherit%3B%20font-size%3A%2024px%3B%22%3EThe%20account%20added%20and%20deleted%20use%20case%20example%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3ETo%20illustrate%20a%20correlation%20that%20often%20uses%20implicit%20correction%20rules%2C%20I%20will%20use%20the%20account%20created%20and%20deleted%20within%20a%20day%20scenario.%20This%20well-known%20attack%20technique%20utilizes%20creating%20an%20account%2C%20presumably%20with%20elevated%20permissions%2C%20abusing%20it%2C%20and%20then%20deleting%20it%20to%20cover%20tracks.%20You%20can%20find%20many%20SIEM%20implementations%20of%20a%20rule%20to%20detect%20such%20a%20pattern%20(%3C%2FSPAN%3E%3CA%20class%3D%22_e75a791d-denali-editor-page-rtfLink%22%20href%3D%22https%3A%2F%2Fcommunity.microfocus.com%2Ft5%2FArcSight-User-Discussions%2FRule-Windows-account-created-and-deleted-within-1-Hr%2Ftd-p%2F1550518%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3EArcSight%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3E%2C%26nbsp%3B%3C%2FSPAN%3E%3CA%20class%3D%22_e75a791d-denali-editor-page-rtfLink%22%20href%3D%22https%3A%2F%2Fgosplunk.com%2Faccounts-deleted-within-24-hours-of-creation%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3ESplunk%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3E).%20Since%20this%20use%20case%20requires%20matching%20an%20account%20create%20to%20an%20account%20delete%20event%2C%20it%20is%20an%20excellent%20example%20of%20a%20correlation%20rule.%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20style%3D%22color%3A%20inherit%3B%20font-family%3A%20inherit%3B%20font-size%3A%2024px%3B%22%3ESelecting%20the%20events%20to%20correlate%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3ELet's%20start!%20Before%20we%20use%20join%20to%20correlate%2C%20we%20need%20to%20select%20the%20events%20to%20correlate.%20The%20first%20part%20of%20the%20query%20does%20just%20that%2C%20and%20names%20the%20relevant%20account%20creation%20and%20account%20deletion%20events%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3Eaccount_created%3C%2FSPAN%3E%3C%2FSTRONG%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3E%26nbsp%3Band%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3Eaccount_deleted%3C%2FSPAN%3E%3C%2FSTRONG%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3E%2C%20respectively.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3Elet%20timeframe%20%3D%2010m%3B%3CBR%20%2F%3Elet%20lookback%20%3D%201d%3B%3CBR%20%2F%3Elet%20account_created%20%3D%3CBR%20%2F%3ESecurityEvent%20%3CBR%20%2F%3E%3CSTRONG%3E%3CFONT%20color%3D%22%230000FF%22%3E%7C%20where%20TimeGenerated%20%26gt%3B%20ago(lookback%2Btimeframe)%3C%2FFONT%3E%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%230000FF%22%3E%7C%20where%20EventID%20%3D%3D%20%224720%22%20%2F%2F%20A%20user%20account%20was%20created%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%230000FF%22%3E%7C%20where%20AccountType%20%3D~%20%22User%22%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF00FF%22%3E%7C%20project%20creationTime%20%3D%20TimeGenerated%2C%20CreateEventID%20%3D%20EventID%2C%20Activity%2C%20Computer%2C%20%3CBR%20%2F%3E%20%20TargetUserName%2C%20UserPrincipalName%2C%20%3C%2FFONT%3E%3CFONT%20color%3D%22%23FF00FF%22%3EAccountUsedToCreate%20%3D%20SubjectUserName%2C%20TargetSid%2C%20%3CBR%20%2F%3E%20%20SubjectUserSid%3B%3C%2FFONT%3E%3CBR%20%2F%3Elet%20account_deleted%20%3D%3CBR%20%2F%3ESecurityEvent%3CBR%20%2F%3E%3CFONT%20color%3D%22%230000FF%22%3E%3CSTRONG%3E%7C%20where%20TimeGenerated%20%26gt%3B%20ago(timeframe)%3C%2FSTRONG%3E%20%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%230000FF%22%3E%7C%20where%20EventID%20%3D%3D%20%224726%22%20%2F%2F%20A%20user%20account%20was%20deleted%20%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%230000FF%22%3E%7C%20where%20AccountType%20%3D%3D%20%22User%22%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF00FF%22%3E%7C%20project%20deletionTime%20%3D%20TimeGenerated%2C%20DeleteEventID%20%3D%20EventID%2C%20Activity%2C%20Computer%2C%20%3CBR%20%2F%3E%20%20TargetUserName%2C%20UserPrincipalName%2C%20%3C%2FFONT%3E%3CFONT%20color%3D%22%23FF00FF%22%3EAccountUsedToDelete%20%3D%20SubjectUserName%2C%20TargetSid%2C%20%3CBR%20%2F%3E%20%20SubjectUserSid%3B%3C%2FFONT%3E%3C%2FPRE%3E%0A%3CP%3EThe%20%22%3CFONT%20color%3D%22%230000FF%22%3Ewhere%3C%2FFONT%3E%22%20clauses%20select%20the%20relevant%20events%2C%20while%20the%20%22%3CFONT%20color%3D%22%23FF00FF%22%3Eproject%3C%2FFONT%3E%22%20clauses%20prepare%20the%20relevant%20events%20fields%20needed%20for%20the%20correlation.%20The%20%22project%22%20clauses%20are%20not%20strictly%20needed%2C%20but%20help%20readability%3A%20since%20the%20two%20selected%20event%20sets%20come%20from%20the%20same%20table%2C%20the%20field%20names%20would%20be%20the%20same.%20The%20%22project%22%20clause%20assigns%20different%2C%20easy%20to%20understand%20names%2C%20to%20the%20fields%2C%20designating%20them%20as%20belonging%20to%20the%20add%20or%20delete%20events%2C%20making%20the%20join%20statement%20below%20much%20more%20readable.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3EOf%20interest%20is%20the%26nbsp%3B%3C%2FSPAN%3E%3CFONT%20color%3D%22%230000FF%22%3E%3CSTRONG%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3Etime%20selection%20part%20(bolded)%3C%2FSPAN%3E%3C%2FSTRONG%3E%3C%2FFONT%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3E%26nbsp%3Bof%20the%20where%20clauses%20that%20use%20different%20periods.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3E%20The%20anchoring%20event%2C%20in%20this%20case%2C%20the%20delete%20event%2C%20is%20checked%20for%20in%20the%20last%2010%20minutes%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CFONT%20color%3D%22%230000FF%22%3E%3CSTRONG%3Ewhere%20TimeGenerated%20%26gt%3B%20ago(timeframe)%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FPRE%3E%0A%3CP%3E%22Timeframe%22%20should%20match%20the%20alert%20rule%20scheduling.%3CBR%20%2F%3E%3CBR%20%2F%3EThe%20reference%20event%2C%20in%20this%20case%2C%20the%20add%20event%2C%20can%20be%20queried%20over%20a%20longer%20period%2C%20to%20match%20the%20use%20case%20goal%2C%20one%20day%20in%20this%20case%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CFONT%20color%3D%22%230000FF%22%3E%3CSTRONG%3Ewhere%20TimeGenerated%20%26gt%3B%20ago(lookback%2Btimeframe)%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FPRE%3E%0A%3CP%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3EThe%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3Etimeframe%3C%2FSPAN%3E%3C%2FSTRONG%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3E%26nbsp%3Bis%20added%20to%20the%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3Elookback%3C%2FSPAN%3E%3C%2FSTRONG%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3E%26nbsp%3Bperiod%20to%20implement%20a%20sliding%20window.%20It%20ensures%20that%20alerts%20that%20occur%20across%20time%20frames%20are%20not%20missed.%20For%20example%2C%20if%20the%20anchoring%20event%20happened%209%20minutes%20before%20the%20rule%20schedule%2C%20and%20the%20reference%20event%2024%20hours%20and%205%20minutes%2C%20an%20alert%20is%20due%2C%20but%20would%20not%20trigger%20without%20this%20time%20selection%20fix.%20It%20creates%20a%20risk%20of%20duplicate%20alerting%2C%20which%20is%20handled%20later%20on%20as%20part%20of%20the%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3Ejoin%3C%2FSPAN%3E%3C%2FSTRONG%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3E%26nbsp%3Bpart%20of%20the%20query.%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20time%20framing%20ensures%20the%20accuracy%20(i.e.%2C%20no%20duplicates%20or%20omissions)%20as%20well%20as%20timeliness%20of%20the%20alert%2C%20regardless%20of%20the%20correlation%20window%20length.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1441159992%22%20id%3D%22toc-hId--1441159992%22%20id%3D%22toc-hId--1441159992%22%20id%3D%22toc-hId--1441159992%22%3ECorrelating%20using%20Join%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CFONT%20color%3D%22%23008000%22%3Eaccount_created%20%7C%20join%20kind%3D%20inner%20(account_deleted)%20on%20Computer%2C%20TargetUserName%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%23FF00FF%22%3E%7C%20where%20deletionTime%20-%20creationTime%20%26lt%3B%20lookback%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20color%3D%22%230000FF%22%3E%7C%20where%20tolong(deletionTime%20-%20creationTime)%20%26gt%3B%3D%200%3C%2FFONT%3E%3CBR%20%2F%3E%7C%20project%20TimeDelta%20%3D%20deletionTime%20-%20creationTime%2C%20creationTime%2C%20CreateEventID%2C%20Computer%2C%20TargetUserName%2C%20UserPrincipalName%2C%20AccountUsedToCreate%2C%20%3CBR%20%2F%3EdeletionTime%2C%20DeleteEventID%2C%20AccountUsedToDelete%3CBR%20%2F%3E%7C%20extend%20timestamp%20%3D%20creationTime%2C%20AccountCustomEntity%20%3D%20AccountUsedToCreate%2C%20HostCustomEntity%20%3D%20Computer%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3EThe%20%22where%22%20clause%20serves%20to%20implement%20the%20time%20framing%20correctly%3A%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3EThe%20%3CFONT%20color%3D%22%23FF00FF%22%3Epurple%3C%2FFONT%3E%20condition%20ensures%20that%20no%20more%20than%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3Elookback%3C%2FSPAN%3E%3C%2FSTRONG%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3E%26nbsp%3Btime%20separated%20the%20two%20events%2C%20compensating%20on%20the%20fact%20that%20we%20query%20the%20reference%20event%20for%20slightly%20more%20than%2024%20hours.%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3EThe%20%3CFONT%20color%3D%22%230000FF%22%3Eblue%3C%2FFONT%3E%20condition%20ensures%20that%20user%20deletion%20happened%20after%20the%20user%20addition.%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3EBoth%20of%20these%20are%20required%20for%20rule%20accuracy%2C%20but%20actually%20do%20not%20enhance%20security.%20Arguably%2C%2024.05%20hours%20between%20the%20events%20are%20still%20a%20reason%20to%20be%20concerned.%20Likewise%2C%20deletion%20and%20then%20addition%20might%20be%20just%20as%20suspicious%20as%20the%20reverse%20order%20of%20events.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3EBy%20setting%20the%20If%20the%20join%20and%20additional%20conditions%20return%20results%2C%20an%20alert%20is%20triggered.%20The%20last%20two%20lines%20in%20green%20prepare%20the%20data%20for%20investigation%20and%20assign%20entities%20which%20will%20be%20discussed%20in%20a%20future%20post.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3ENow%20that%20you%20learned%20about%20the%20Sentinel%20way%20of%20writing%20a%20correlation%20rule%2C%20you%20may%20want%20to%20go%20back%20and%20compare%20to%20the%20ArcSight%20and%20Splunk%20implementations.%20My%20take%20is%20that%20while%20the%20explicit%20handling%20of%20the%20sliding%20time%20window%20takes%20getting%20used%20to%2C%20in%20general%2C%20the%20rule%20is%20very%20transparent%20and%20explicit%2C%20allowing%20for%20easier%20development%20and%20maintenance.%20Being%20query-based%2C%20it%20also%20eliminates%20the%20large%20memory%20requirements%20that%20implicit%20correlations%20put.%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3EWant%20to%20learn%20more%20about%20writing%20Azure%20Sentinel%20alert%20rules%3F%20Here%20are%20some%20resources%20to%20explore%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CA%20class%3D%22_e75a791d-denali-editor-page-rtfLink%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkusto%2Fquery%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3EKQL%20documentation%3C%2FSPAN%3E%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20class%3D%22_e75a791d-denali-editor-page-rtfLink%22%20href%3D%22https%3A%2F%2Fwww.pluralsight.com%2Fcourses%2Fkusto-query-language-kql-from-scratch%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3EKQL%20Pluralsight%20free%20course%3C%2FSPAN%3E%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20class%3D%22_e75a791d-denali-editor-page-rtfLink%22%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FAzure-Sentinel%2FAzure-Sentinel-correlation-rules-Active-Lists-out-make-list-in%2Fba-p%2F1029225%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3E%3CSPAN%20data-preserver-spaces%3D%22true%22%3EAzure%20Sentinel%20correlation%20rules%3A%20Active%20Lists%20out%3B%20make_list()%20in%2C%20the%20AAD%2FAWS%20correlation%20example%3C%2FSPAN%3E%3C%2FA%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F159538i81C8BBBBBC8E4355%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Beach-Footprints-Sand-Dogs-Footprint-Holiday-4417556.jpg%22%20title%3D%22Beach-Footprints-Sand-Dogs-Footprint-Holiday-4417556.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1041500%22%20slang%3D%22en-US%22%3E%3CP%3EIn%20the%20SIEM%20world%2C%20rules%20are%20often%20called%20correlation%20rules%20to%20stress%20the%20role%20of%20a%20SIEM%20to%20correlate%20signals%20from%20different%20sources.%20In%20this%20blog%20post%2C%20I%20will%20explain%20how%20to%20implement%20correlation%20rules%20in%20Sentinel%20using%20the%20join%20KQL%20operator.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1050042%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20Sentinel%20correlation%20rules%3A%20the%20join%20KQL%20operator%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1050042%22%20slang%3D%22en-US%22%3E%3CP%3EI%20think%20in%20the%20line%20%22%3CSPAN%3EBy%20setting%20the%20If%20the%20join%20and%20additional%20conditions%20return%20results%2C%20an%20alert%20is%20triggered.%26nbsp%3B%22%2C%20the%20first%203%20words%20should%20not%20be%20there.%26nbsp%3B%20This%20is%20in%20the%203rd%20paragraph%20under%20the%20%3CSTRONG%3ECorrelating%20using%20Joins%3C%2FSTRONG%3E%20header%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1050093%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20Sentinel%20correlation%20rules%3A%20the%20join%20KQL%20operator%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1050093%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F46875%22%20target%3D%22_blank%22%3E%40Gary%20Bushey%3C%2FA%3E!%20fixed.%20I%20really%20need%20to%20get%20an%20exception%20to%20run%20Grammarly%20in%20Chrome.%20Corporate%20policy%20does%20not%20allow%20me%20which%20means%20I%20am%20cutting%20and%20pasting%20parts%20back%20and%20forth%2C%20and%20those%20are%20the%20results%20%3A(%3C%2Fimg%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Microsoft

In the SIEM world, rules are often called correlation rules. While this is not always the case, and therefore I prefer the term detection rules, it conveys the importance of correlation for SIEM. What makes SIEM different from specialized security controls is the ability to correlate between events from multiple sources.

 

Last time, I presented the use of the make_list() KQL aggregation function to implement a correlation. It corresponds to the use of an explicit state machine for correlation in traditional SIEMs using "Active Lists" or "reference sets". The Azure Sentinel version avoids the state machine and is, therefore, much simpler to build and maintain.

 

In this post, I will describe implicit correlation rules and implementing them using the KQL operator join.

 

Implicit correlation

Traditional SIEMs offer an additional option: implicit correlation. Such a correlation rule relates two or more events and, if matching, would trigger an alert. Behind the scenes, the SIEM would maintain a state: once one of the events is received, let's call it the anchoring event, a context is created to "remember" this occurrence. In the ArcSight Jargon, this is called "partial match". This context would be retained for the period, or "window", stated for the correlation.  

 

Those implicit correlation rules are easier to create and maintain than explicit correlations but are very costly in terms of memory to keep all those open contexts. Pick a too common anchoring event (failed login, for example) and a long window (say an hour), and your SIEM would saturate. This is why explicit correlation using lists is often preferred. 

 

The account added and deleted use case example

To illustrate a correlation that often uses implicit correction rules, I will use the account created and deleted within a day scenario. This well-known attack technique utilizes creating an account, presumably with elevated permissions, abusing it, and then deleting it to cover tracks. You can find many SIEM implementations of a rule to detect such a pattern (ArcSightSplunk). Since this use case requires matching an account create to an account delete event, it is an excellent example of a correlation rule. 

 

Selecting the events to correlate

Let's start! Before we use join to correlate, we need to select the events to correlate. The first part of the query does just that, and names the relevant account creation and account deletion events account_created and account_deleted, respectively.

 

let timeframe = 10m;
let lookback = 1d;
let account_created =
SecurityEvent
| where TimeGenerated > ago(lookback+timeframe)
| where EventID == "4720" // A user account was created
| where AccountType =~ "User"
| project creationTime = TimeGenerated, CreateEventID = EventID, Activity, Computer,
TargetUserName, UserPrincipalName,
AccountUsedToCreate = SubjectUserName, TargetSid,
SubjectUserSid;

let account_deleted =
SecurityEvent
| where TimeGenerated > ago(timeframe)
| where EventID == "4726" // A user account was deleted
| where AccountType == "User"
| project deletionTime = TimeGenerated, DeleteEventID = EventID, Activity, Computer,
TargetUserName, UserPrincipalName,
AccountUsedToDelete = SubjectUserName, TargetSid,
SubjectUserSid;

The "where" clauses select the relevant events, while the "project" clauses prepare the relevant events fields needed for the correlation. The "project" clauses are not strictly needed, but help readability: since the two selected event sets come from the same table, the field names would be the same. The "project" clause assigns different, easy to understand names, to the fields, designating them as belonging to the add or delete events, making the join statement below much more readable.

 

Of interest is the time selection part (bolded) of the where clauses that use different periods.

 

The anchoring event, in this case, the delete event, is checked for in the last 10 minutes:

 

where TimeGenerated > ago(timeframe)

"Timeframe" should match the alert rule scheduling.

The reference event, in this case, the add event, can be queried over a longer period, to match the use case goal, one day in this case:

 

where TimeGenerated > ago(lookback+timeframe)

The timeframe is added to the lookback period to implement a sliding window. It ensures that alerts that occur across time frames are not missed. For example, if the anchoring event happened 9 minutes before the rule schedule, and the reference event 24 hours and 5 minutes, an alert is due, but would not trigger without this time selection fix. It creates a risk of duplicate alerting, which is handled later on as part of the join part of the query. 

 

This time framing ensures the accuracy (i.e., no duplicates or omissions) as well as timeliness of the alert, regardless of the correlation window length.

 

Correlating using Join

 

account_created | join kind= inner (account_deleted) on Computer, TargetUserName
| where deletionTime - creationTime < lookback
| where tolong(deletionTime - creationTime) >= 0
| project TimeDelta = deletionTime - creationTime, creationTime, CreateEventID, Computer, TargetUserName, UserPrincipalName, AccountUsedToCreate,
deletionTime, DeleteEventID, AccountUsedToDelete
| extend timestamp = creationTime, AccountCustomEntity = AccountUsedToCreate, HostCustomEntity = Computer

 

The "where" clause serves to implement the time framing correctly: 

  • The purple condition ensures that no more than lookback time separated the two events, compensating on the fact that we query the reference event for slightly more than 24 hours.
  • The blue condition ensures that user deletion happened after the user addition.

 

Both of these are required for rule accuracy, but actually do not enhance security. Arguably, 24.05 hours between the events are still a reason to be concerned. Likewise, deletion and then addition might be just as suspicious as the reverse order of events.

 

If the join and additional conditions return results, an alert is triggered. The last two lines in green prepare the data for investigation and assign entities which will be discussed in a future post.

 

Now that you learned about the Sentinel way of writing a correlation rule, you may want to go back and compare to the ArcSight and Splunk implementations. My take is that while the explicit handling of the sliding time window takes getting used to, in general, the rule is very transparent and explicit, allowing for easier development and maintenance. Being query-based, it also eliminates the large memory requirements that implicit correlations put. 

 

Want to learn more about writing Azure Sentinel alert rules? Here are some resources to explore:

 

Beach-Footprints-Sand-Dogs-Footprint-Holiday-4417556.jpg

2 Comments
Contributor

I think in the line "By setting the If the join and additional conditions return results, an alert is triggered. ", the first 3 words should not be there.  This is in the 3rd paragraph under the Correlating using Joins header

Microsoft

Thanks @Gary Bushey! fixed. I really need to get an exception to run Grammarly in Chrome. Corporate policy does not allow me which means I am cutting and pasting parts back and forth, and those are the results :(