%3CLINGO-SUB%20id%3D%22lingo-sub-1720306%22%20slang%3D%22en-US%22%3EIntegrating%20Azure%20Web%20Application%20Firewall%20with%20Azure%20Sentinel%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1720306%22%20slang%3D%22en-US%22%3E%3CP%3EWritten%20in%20collaboration%20with%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F89690%22%20target%3D%22_blank%22%3E%40Chris%20Boehm%3C%2FA%3E%26nbsp%3Band%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F293861%22%20target%3D%22_blank%22%3E%40aprakash13%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1242839350%22%20id%3D%22toc-hId--1242838664%22%20id%3D%22toc-hId--1242838664%22%20id%3D%22toc-hId--1242838664%22%3EIntroduction%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EReaders%20of%20this%20post%20will%20hopefully%20be%20familiar%20with%20both%20Azure%20Sentinel%20and%20Azure%20WAF.%20The%20idea%20we%20will%20be%20discussing%20is%20how%20to%20take%20the%20log%20data%20generated%20by%20WAF%20and%20do%20something%20useful%20with%20it%20in%20Sentinel%2C%20such%20as%20visualize%20patterns%2C%20detect%20potentially%20malicious%20activities%2C%20and%20respond%20to%20threats.%20If%20configured%20and%20tuned%20correctly%20(a%20topic%20for%20another%20post)%2C%20Azure%20WAF%20will%20prevent%20attacks%20against%20your%20web%20applications.%20However%2C%20leaving%20WAF%20alone%20to%20do%20its%20job%20is%20not%20enough%3B%20security%20teams%20need%20to%20analyze%20the%20data%20to%20determine%20where%20improvements%20can%20be%20made%20and%20where%20extra%20action%20may%20be%20required%20on%20the%20part%20of%20response%20teams.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1244673483%22%20id%3D%22toc-hId-1244674169%22%20id%3D%22toc-hId-1244674169%22%20id%3D%22toc-hId-1244674169%22%3ESend%20WAF%20Data%20to%20Sentinel%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20first%20step%20to%20integrating%20these%20tools%20is%20to%20send%20WAF%20logs%20and%20other%20relevant%20data%2C%20such%20as%20access%20logs%20and%20metrics%2C%20to%20Sentinel.%20This%20process%20can%20be%20initiated%20using%20the%20built-in%20Sentinel%20Data%20Connector%20for%20Azure%20WAF%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Anthony_Roman_0-1601299630052.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F222567iBE25448A004664F7%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22Anthony_Roman_0-1601299630052.png%22%20alt%3D%22Anthony_Roman_0-1601299630052.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOnce%20you%20have%20connected%20your%20WAF%20data%20sources%20to%20Azure%20Sentinel%2C%20you%20can%20visualize%20and%20monitor%20the%20data%20using%20Workbooks%2C%20which%20provide%20versatility%20in%20creating%20custom%20dashboards.%20Looking%20inside%20the%20Azure%20Sentinel%20Workbooks%20tab%2C%20look%20up%20the%20default%20Azure%20WAF%20Workbook%20template%20to%20get%20you%20started%20with%20all%20WAF%20data%20types.%3C%2FP%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%20image-alt%3D%22Picture1.gif%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F222575i266626DF2C259900%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22Picture1.gif%22%20alt%3D%22Picture1.gif%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhen%20starting%20out%20with%20the%20Microsoft%20WAF%20Workbook%2C%20you%E2%80%99ll%20be%20faced%20with%20a%20few%20data%20filter%20options%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3ESubscription%20(%20Based%20on%20your%20portal%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Frole-based-access-control%2Frole-assignments-portal%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3ERBAC%20permissions%3C%2FA%3E%20)%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-monitor%2Flearn%2Fquick-create-workspace%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3ELog%20Analytics%20workspaces%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3ETime%20Range%3C%2FLI%3E%0A%3CLI%3EWAF%20Data%20type%20(Example%3A%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fcdn%2Fcdn-overview%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3ECDN%3C%2FA%3E%2C%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fapplication-gateway%2Foverview%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EApplication%20Gateway%3C%2FA%3E%20or%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Ffrontdoor%2Ffront-door-overview%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Front%20Door%3C%2FA%3E)%3C%2FLI%3E%0A%3CLI%3EWAF%20Resources%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EIn%20the%20short%20annotation%20below%2C%20you%E2%80%99ll%20be%20taken%20through%20a%20few%20preconfigured%20filters%2C%20two%20different%20subscriptions%20(across%20two%20different%20tenants)%2C%20while%20having%20preselected%20two%20different%20workspaces.%20The%20annotation%20is%20going%20to%20walk%20through%20a%20SQL%20Injection%20attack%20that%20was%20detected%20and%20how%20you%20can%20filter%20down%20the%20information%20by%20time%20or%20by%20event%20data.%20Like%20an%20IPAddress%20or%20Tracking%20ID%20provided%20by%20the%20diagnostic%20logs.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%E2%80%99re%20unfamiliar%20with%20a%20workbook%2C%20the%20design%20is%20a%20top%20to%20bottom%20filter%20experience.%20If%20you%20filter%20the%20top%20of%20the%20workbook%2C%20it%E2%80%99ll%20filter%20everything%20below%20with%20the%20selected%20filters%20above.%20You%E2%80%99ll%20see%20some%20filters%20that%20were%20not%20selected%2C%20example%20being%20%E2%80%9CBlocked%20or%20Matched%E2%80%9D%20within%20the%20logs%2C%20or%20the%20Blocked%20Request%20URI%20Addresses.%20Both%20could%20have%20been%20selected%20and%20filtered%20across%20the%20workbook.%3C%2FP%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%20image-alt%3D%22WAFWorkbook3.gif%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F222599i820348A2D8A77305%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22WAFWorkbook3.gif%22%20alt%3D%22WAFWorkbook3.gif%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--562780980%22%20id%3D%22toc-hId--562780294%22%20id%3D%22toc-hId--562780294%22%20id%3D%22toc-hId--562780294%22%3EHunting%20Using%20WAF%20Data%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20core%20idea%20of%20Azure%20Sentinel%20is%20that%20relevant%20security%20regarding%20your%20hunting%20or%20investigation%20is%20produced%20in%20multiple%20locations%2Flogs%20and%20being%20able%20to%20analyze%20them%20from%20a%20single%20point%20makes%20it%20easier%20to%20spot%20trends%20and%20see%20patterns%20that%20are%20out%20of%20the%20ordinary.%20The%20logs%20from%20our%20Azure%20WAF%20device%20is%20one%20critical%20part%20of%20this%20puzzle.%20As%20more%20and%20more%20companies%20move%20their%20applications%20to%20the%20cloud%20their%20Web%20Application%20security%20posture%20has%20become%20super%20relevant%20in%20their%20overall%20security%20framework.%20Through%20the%20WAF%20logs%2C%20we%20can%20analyze%20the%20application%20traffic%20and%20combine%20it%20with%20other%20data%20feeds%20to%20uncover%20various%20attack%20patterns%20that%20an%20organization%20needs%20to%20be%20aware%20of.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHowever%2C%20to%20be%20able%20to%20effectively%20use%20the%20telemetry%20from%20WAF%2C%20a%20general%20understanding%20of%20the%20WAF%20logs%20is%20critical.%26nbsp%3B%20It%20is%20very%20hard%20to%20focus%20on%20the%20hunting%20mission%2C%20be%20productive%20and%20effective%20if%20we%20don%E2%80%99t%20understand%20the%20data.%26nbsp%3B%20WAF%20data%20is%20collected%20in%20Azure%20Sentinel%20under%20the%20%3CEM%3E%3CSTRONG%3EAzureDiagnostics%20%3C%2FSTRONG%3E%3C%2FEM%3Etable.%20Depending%20on%20whether%20the%20Azure%20WAF%20policy%20is%20applied%20to%20web%20applications%20hosted%20on%20Application%20Gateway%20or%20Azure%20Front%20Doors%20the%20category%20under%20which%20the%20logs%20are%20collected%20are%20a%20little%20different.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhile%20we%20don%E2%80%99t%20cover%20this%20thoroughly%20in%20this%20post%2C%20WAF%20Policies%20can%20be%20applied%20to%20CDN%3B%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fweb-application-firewall%2Fcdn%2Fcdn-overview%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Emore%20information%20here.%3C%2FA%3E%20When%20applied%20to%20CDN%2C%20the%20relevant%20logs%20are%20under%20the%20category%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EWebApplicationFirewallLogs%20(set%20on%20the%20WAF%20Policy)%3C%2FLI%3E%0A%3CLI%3EAzureCdnAccessLog%20(set%20on%20the%20CDN%20Profile)%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EThere%20are%20subtle%20and%20nuanced%20differences%20between%20both%20these%20log%20types%20(Application%20Gateway%20vs%20Front%20Door)%20however%20in%20general%2C%20when%20we%20talk%20about%20the%20Access%20Logs%2C%20they%20give%20us%20an%20idea%20about%20Application%E2%80%99s%20access%20patterns.%20The%20firewall%20logs%20on%20the%20other%20hand%20logs%20any%20request%20that%20matches%20a%20WAF%20rule%20through%20either%20detection%20or%20prevention%20mode%20of%20the%20WAF%20policy.%20These%20logs%20include%20a%20bunch%20of%20interesting%20information%20like%20the%20caller's%20IP%2C%20port%2C%20requested%20URL%2C%20UserAgent%20and%20bytes%20in%20and%20out.%20The%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FAzure-Sentinel%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Sentinel%20GitHub%20repository%3C%2FA%3E%20is%20a%20great%20source%20of%20inspiration%20for%20the%20kind%20of%20hunting%20and%20detection%20queries%20that%20one%20can%20build%20with%20some%20of%20these%20fields.%20However%2C%20let%20us%20go%20through%20a%20couple%20of%20examples%20of%20what%20we%20can%20do%20with%20this%20data.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOne%20of%20the%20techniques%20that%20a%20lot%20of%20threat%20hunters%20have%20in%20their%20arsenal%20is%20count%20based%20hunting%20i.e.%20they%20aggregate%20the%20event%20data%20and%20look%20for%20events%20that%20crosses%20a%20particular%20threshold.%20For%20example%2C%20in%20the%20WAF%20data%20we%20could%20probably%20look%20for%20a%20number%20of%20sessions%20originating%20from%20a%20particular%20client%20IP%20address%20in%20a%20given%20interval%20of%20time.%20Once%20the%20number%20of%20connections%20exceeds%20a%20particular%20threshold%20value%2C%20an%20alert%20could%20be%20triggered%20for%20further%20investigation.%3C%2FP%3E%0A%3CP%3EHowever%2C%20since%20each%20environment%20is%20different%2C%20we%20will%20have%20to%20modify%20the%20threshold%20value%20accordingly.%20Additionally%2C%20IP%20based%20session%20tracking%20have%20their%20own%20challenges%20and%20false%20positives%20due%20to%20various%20dynamic%20factors%20like%20Proxy%2FNAT%20etc.%20that%20we%20would%20have%20to%20be%20mindful%20of%20for%20these%20type%20of%20queries.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-sql%22%3E%3CCODE%3Elet%20Threshold%20%3D%20200%3B%26nbsp%3B%20%2F%2FAdjust%20the%20threshold%20to%20a%20suitable%20value%20based%20on%20Environment%2C%20Time%20Period.%0A%0Alet%20AllData%20%3D%26nbsp%3B%20AzureDiagnostics%0A%0A%7C%20where%20TimeGenerated%20%26gt%3B%3D%20ago(1d)%0A%0A%7C%20where%20Category%20in%20(%22FrontdoorWebApplicationFirewallLog%22%2C%20%22FrontdoorAccessLog%22%2C%20%22ApplicationGatewayFirewallLog%22%2C%20%22ApplicationGatewayAccessLog%22)%0A%0A%7C%20extend%20ClientIPAddress%20%3D%20iff(%20Category%20in%20(%22FrontdoorWebApplicationFirewallLog%22%2C%20%22ApplicationGatewayAccessLog%22)%2C%20clientIP_s%2C%20clientIp_s)%3B%0A%0Alet%20SuspiciousIP%20%3D%20AzureDiagnostics%0A%0A%7C%20where%20TimeGenerated%20%26gt%3B%3D%20ago(1d)%0A%0A%7C%20where%20Category%20in%20(%20%22ApplicationGatewayFirewallLog%22%2C%20%22ApplicationGatewayAccessLog%22%2C%20%22FrontdoorWebApplicationFirewallLog%22%2C%20%22FrontdoorAccessLog%22)%0A%0A%7C%20extend%20ClientIPAddress%20%3D%20iff(%20Category%20in%20(%22FrontdoorWebApplicationFirewallLog%22%2C%20%22ApplicationGatewayAccessLog%22)%2C%20clientIP_s%2C%20clientIp_s)%0A%0A%7C%20extend%20SessionTrackingID%20%3D%20iff(%20Category%20in%20(%22FrontdoorWebApplicationFirewallLog%22%2C%20%22FrontdoorAccessLog%22)%2C%20trackingReference_s%2C%20transactionId_g)%0A%0A%7C%20distinct%26nbsp%3B%20ClientIPAddress%2C%20SessionTrackingID%0A%0A%7C%20summarize%20count()%20by%20ClientIPAddress%0A%0A%7C%20where%20count_%20%26gt%3B%20Threshold%0A%0A%7C%20distinct%20ClientIPAddress%3B%0A%0ASuspiciousIP%0A%0A%7C%20join%20kind%20%3D%20inner%20(%20AllData)%20on%20ClientIPAddress%0A%0A%7C%20extend%20SessionTrackingID%20%3D%20iff(%20Category%20in%20(%22FrontdoorWebApplicationFirewallLog%22%2C%20%22FrontdoorAccessLog%22)%2C%20trackingReference_s%2C%20transactionId_g)%0A%0A%7C%20summarize%20makeset(requestUri_s)%2C%20makeset(requestQuery_s)%2C%20makeset(SessionTrackingID)%2C%20makeset(clientPort_d)%2C%26nbsp%3B%20SessionCount%20%3D%20count()%20by%20ClientIPAddress%2C%20_ResourceId%0A%0A%7C%20extend%20HostCustomEntity%20%3D%26nbsp%3B%20_ResourceId%2C%20IPCustomEntity%20%3D%20ClientIPAddress%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAnother%20way%20to%20leverage%20the%20WAF%20data%20could%20be%20through%20Indicators%20of%20Compromise%20(IoCs)%20matching.%20IoCs%20are%20data%20that%20associates%20observations%20such%20as%20URLs%2C%20file%20hashes%20or%20IP%20addresses%20with%20known%20threat%20activity%20such%20as%20phishing%2C%20botnets%2C%20or%20malware.%20Many%20organizations%20aggregate%20threat%20indicators%20feed%20from%20a%20variety%20of%20sources%2C%20curate%20the%20data%20and%20then%20apply%20it%20to%20their%20available%20logs.%20They%20could%20match%20these%20IoCs%20with%20their%20WAF%20logs%20as%20well.%20For%20more%20details%20check%20out%20this%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-sentinel%2Fbring-your-threat-intelligence-to-azure-sentinel%2Fba-p%2F1167546%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3Egreat%20blog%20post%3C%2FA%3E%20that%20talks%20about%20how%20you%20can%20import%20threat%20intelligence%20(TI)%20data%20into%20Azure%20Sentinel.%26nbsp%3B%20Once%20the%20TI%20data%20is%20imported%20in%20Azure%20Sentinel%20you%20can%20view%20it%20in%20the%20ThreatIntelligenceIndicator%20table%20in%20Logs.%20Below%20is%20a%20quick%20example%20of%20how%20you%20can%20match%20the%20WAF%20data%20with%20the%20TI%20data%20to%20see%20if%20there%20is%20any%20traffic%20that%20is%20originating%20from%20a%20Bot%20Network%20or%20from%20an%20IP%20that%20is%20known%20to%20be%20bad.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-sql%22%3E%3CCODE%3Elet%20dt_lookBack%26nbsp%3B%20%3D%201h%3B%0A%0Alet%20ioc_lookBack%20%3D%2014d%3B%0A%0AThreatIntelligenceIndicator%0A%0A%7C%20where%20TimeGenerated%20%26gt%3B%3D%20ago(ioc_lookBack)%20and%20ExpirationDateTime%20%26gt%3B%20now()%0A%0A%7C%20where%20Active%20%3D%3D%20true%0A%0A%2F%2F%20Picking%20up%20only%20IOC's%20that%20contain%20the%20entities%20we%20want%0A%0A%7C%20where%20isnotempty(NetworkIP)%20or%20isnotempty(EmailSourceIpAddress)%20or%20isnotempty(NetworkDestinationIP)%20or%20isnotempty(NetworkSourceIP)%0A%0A%2F%2F%20As%20there%20is%20potentially%20more%20than%201%20indicator%20type%20for%20matching%20IP%2C%20taking%20NetworkIP%20first%2C%20then%20others%20if%20that%20is%20empty.%0A%0A%2F%2F%20Taking%20the%20first%20non-empty%20value%20based%20on%20potential%20IOC%20match%20availability%0A%0A%7C%20extend%20TI_ipEntity%20%3D%20iff(isnotempty(NetworkIP)%2C%20NetworkIP%2C%20NetworkDestinationIP)%0A%0A%7C%20extend%20TI_ipEntity%20%3D%20iff(isempty(TI_ipEntity)%20and%20isnotempty(NetworkSourceIP)%2C%20NetworkSourceIP%2C%20TI_ipEntity)%0A%0A%7C%20extend%20TI_ipEntity%20%3D%20iff(isempty(TI_ipEntity)%20and%20isnotempty(EmailSourceIpAddress)%2C%20EmailSourceIpAddress%2C%20TI_ipEntity)%0A%0A%7C%20join%20(%0A%0AAzureDiagnostics%20%7C%20where%20TimeGenerated%20%26gt%3B%3D%20ago(dt_lookBack)%0A%0A%7C%20where%20Category%20in%20(%20'ApplicationGatewayFirewallLog'%2C%20'FrontdoorWebApplicationFirewallLog'%2C%20'ApplicationGatewayAccessLog'%2C%20'FrontdoorAccessLog')%0A%0A%7C%20where%20isnotempty(clientIP_s)%20or%20isnotempty(clientIp_s)%0A%0A%7C%20extend%20ClientIPAddress%20%3D%20iff(%20Category%20in%20(%22FrontdoorWebApplicationFirewallLog%22%2C%20%22ApplicationGatewayAccessLog%22)%2C%20clientIP_s%2C%20clientIp_s)%0A%0A%7C%20extend%20WAF_TimeGenerated%20%3D%20TimeGenerated%0A%0A)%0A%0Aon%20%24left.TI_ipEntity%20%3D%3D%20%24right.ClientIPAddress%0A%0A%7C%20project%20TimeGenerated%2C%20ClientIPAddress%2C%20Description%2C%20ActivityGroupNames%2C%20IndicatorId%2C%20ThreatType%2C%20ExpirationDateTime%2C%20ConfidenceScore%2C_ResourceId%2C%20WAF_TimeGenerated%2C%20Category%2C%20ResourceGroup%2C%20SubscriptionId%2C%20ResourceType%2COperationName%2C%20requestUri_s%2C%20ruleName_s%2C%20host_s%2C%20clientPort_d%2Cdetails_data_s%2C%20details_matches_s%2C%20Message%2C%20ruleSetType_s%2C%20policyScope_s%0A%0A%7C%20extend%20IPCustomEntity%20%3D%20ClientIPAddress%2C%20HostCustomEntity%20%3D%20_ResourceId%2C%20timestamp%20%3D%20WAF_TimeGenerated%2C%20URLCustomEntity%20%3D%20requestUri_s%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThreat%20hunters%20could%20even%20leverage%20KQL%20advanced%20modelling%20capabilities%20on%20WAF%20logs%20to%20find%20anomalies.%20For%20example%2C%20they%20could%20do%20the%20Time%20Series%20analysis%20on%20the%20WAF%20data.%20Time%20Series%20is%20a%20series%20of%20data%20points%20indexed%20(or%20listed%20or%20graphed)%20in%20time%20order.%20By%20analyzing%20time%20series%20data%20over%20an%20extended%20period%2C%20we%20can%20identify%20time-based%20patterns%20(e.g.%20seasonality%2C%20trend%20etc.)%20in%20the%20data%20and%20extract%20meaningful%20statistics%20which%20can%20help%20in%20flagging%20outliers.%20The%20different%20Thresholds%20would%20have%20to%20be%20adjusted%20depending%20on%20the%20environment.%20%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EBelow%20is%20an%20example%20query%20demonstrating%20Time%20Series%20IP%20anomaly.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-sql%22%3E%3CCODE%3Elet%20percentotalthreshold%20%3D%2025%3B%0A%0Alet%20timeframe%20%3D%201h%3B%0A%0Alet%20starttime%20%3D%2014d%3B%0A%0Alet%20endtime%20%3D%201d%3B%0A%0Alet%20scorethreshold%20%3D%205%3B%0A%0Alet%20baselinethreshold%20%3D%2010%3B%0A%0Alet%20TimeSeriesData%20%3D%26nbsp%3B%20AzureDiagnostics%0A%0A%26nbsp%3B%20%7C%20where%20Category%20in%20(%20%22ApplicationGatewayFirewallLog%22%2C%20%22ApplicationGatewayAccessLog%22%2C%20%22FrontdoorWebApplicationFirewallLog%22%2C%20%22FrontdoorAccessLog%22)%20and%20action_s%20in%20(%20%22Log%22%2C%20%22Matched%22%2C%20%22Detcted%22)%0A%0A%26nbsp%3B%20%7C%20where%20isnotempty(clientIP_s)%20or%20isnotempty(clientIp_s)%0A%0A%26nbsp%3B%20%7C%20extend%20ClientIPAddress%20%3D%20iff(%20Category%20in%20(%22FrontdoorWebApplicationFirewallLog%22%2C%20%22ApplicationGatewayAccessLog%22)%2C%20clientIP_s%2C%20clientIp_s)%0A%0A%26nbsp%3B%20%7C%20where%20TimeGenerated%20between%20((ago(starttime))..(ago(endtime)))%0A%0A%26nbsp%3B%20%7C%20project%20TimeGenerated%2C%20ClientIPAddress%0A%0A%26nbsp%3B%20%7C%20make-series%20Total%3Dcount()%20on%20TimeGenerated%20from%20(ago(starttime))%20to%20(ago(endtime))%20step%20timeframe%20by%20ClientIPAddress%3B%0A%0Alet%20TimeSeriesAlerts%3DTimeSeriesData%0A%0A%26nbsp%3B%20%7C%20extend%20(anomalies%2C%20score%2C%20baseline)%20%3D%20series_decompose_anomalies(Total%2C%20scorethreshold%2C%201%2C%20'linefit')%0A%0A%26nbsp%3B%20%7C%20mv-expand%20Total%20to%20typeof(double)%2C%20TimeGenerated%20to%20typeof(datetime)%2C%20anomalies%20to%20typeof(double)%2Cscore%20to%20typeof(double)%2C%20baseline%20to%20typeof(long)%0A%0A%26nbsp%3B%20%7C%20where%20anomalies%20%26gt%3B%200%20%7C%20extend%20score%20%3D%20round(score%2C2)%2C%20AnomalyHour%20%3D%20TimeGenerated%0A%0A%26nbsp%3B%20%7C%20project%20ClientIPAddress%2C%20AnomalyHour%2C%20TimeGenerated%2C%20Total%2C%20baseline%2C%20anomalies%2C%20score%0A%0A%26nbsp%3B%20%7C%20where%20baseline%20%26gt%3B%20baselinethreshold%3B%0A%0A%26nbsp%3B%20TimeSeriesAlerts%0A%0A%26nbsp%3B%20%7C%20join%20(%0A%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20AzureDiagnostics%0A%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%7C%20extend%20ClientIPAddress%20%3D%20iff(%20Category%20in%20(%22FrontdoorWebApplicationFirewallLog%22%2C%20%22ApplicationGatewayAccessLog%22)%2C%20clientIP_s%2C%20clientIp_s)%0A%0A%26nbsp%3B%20%7C%20where%20isnotempty(ClientIPAddress)%0A%0A%26nbsp%3B%20%7C%20where%20TimeGenerated%26nbsp%3B%20%26gt%3B%20ago(endtime)%0A%0A%26nbsp%3B%20%7C%20summarize%20HourlyCount%20%3D%20count()%2C%20TimeGeneratedMax%20%3D%20arg_max(TimeGenerated%2C%20*)%2C%20ClientIPlist%20%3D%20make_set(clientIP_s)%2C%20Portlist%20%3D%20make_set(clientPort_d)%20by%20clientIP_s%2C%20TimeGeneratedHour%3D%20bin(TimeGenerated%2C%201h)%0A%0A%26nbsp%3B%20%7C%20extend%20AnomalyHour%20%3D%20TimeGeneratedHour%0A%0A%26nbsp%3B%20)%20on%20ClientIPAddress%0A%0A%26nbsp%3B%20%7C%20extend%20PercentTotal%20%3D%20round((HourlyCount%20%2F%20Total)%20*%20100%2C%203)%0A%0A%26nbsp%3B%20%7C%20where%20PercentTotal%20%26gt%3B%20percentotalthreshold%0A%0A%26nbsp%3B%20%7C%20project%26nbsp%3B%20AnomalyHour%2C%20TimeGeneratedMax%2C%20ClientIPAddress%2C%20ClientIPlist%2C%20Portlist%2C%20HourlyCount%2C%20PercentTotal%2C%20Total%2C%20baseline%2C%20score%2C%20anomalies%2C%20requestUri_s%2C%20trackingReference_s%2C%20_ResourceId%2C%20SubscriptionId%2C%20ruleName_s%2C%20hostname_s%2C%20policy_s%2C%20action_s%0A%0A%26nbsp%3B%20%7C%20summarize%20HourlyCount%3Dsum(HourlyCount)%2C%20StartTimeUtc%3Dmin(TimeGeneratedMax)%2C%20EndTimeUtc%3Dmax(TimeGeneratedMax)%2C%20SourceIPlist%20%3D%20make_set(ClientIPAddress)%2C%20Portlist%20%3D%20make_set(Portlist)%20by%20ClientIPAddress%20%2C%20AnomalyHour%2C%20Total%2C%20baseline%2C%20score%2C%20anomalies%2C%20requestUri_s%2C%20trackingReference_s%2C%20_ResourceId%2C%20SubscriptionId%2C%20ruleName_s%2C%20hostname_s%2C%20policy_s%2C%20action_s%0A%0A%26nbsp%3B%20%7C%20extend%20HostCustomEntity%20%3D%26nbsp%3B%20_ResourceId%2C%20IPCustomEntity%20%3D%20ClientIPAddress%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1924731853%22%20id%3D%22toc-hId-1924732539%22%20id%3D%22toc-hId-1924732539%22%20id%3D%22toc-hId-1924732539%22%3EGenerate%20Incidents%20using%20Azure%20Sentinel%20Analytics%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAzure%20Sentinel%20uses%20the%20concept%20of%20Analytics%20to%20accomplish%20Incident%20creation%2C%20alerting%2C%20and%20eventually%20automated%20response.%20The%20main%20piece%20of%20any%20Analytic%20rule%20is%20the%20KQL%20query%20that%20powers%20it.%20If%20the%20query%20returns%20data%20(over%20a%20configured%20threshold)%2C%20an%20alert%20will%20fire.%20To%20use%20this%20in%20practice%2C%20you%20need%20to%20craft%20a%20query%20that%20returns%20results%20worthy%20of%20an%20alert.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20logic%20used%20can%20be%20complex%2C%20possibly%20adapted%20from%20the%20hunting%20logic%20outlined%20above%2C%20or%20fairly%20basic%20like%20the%20example%20below.%20It%20can%20be%20difficult%20to%20know%20what%20combination%20of%20WAF%20events%20warrant%20attention%20from%20analysts%20or%20even%20an%20automated%20response.%20We%20will%20assume%20the%20WAF%20has%20been%20tuned%20to%20eliminate%20most%20false%20positives%2C%20and%20that%20rule%20matches%20are%20usually%20indicative%20of%20malicious%20behavior.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20Analytic%20Rule%20we%20will%20look%20at%20serves%20the%20purpose%20of%20detecting%20repeated%20attacks%20from%20the%20same%20source%20IP%20address.%20We%20simply%20look%20for%20WAF%20rule%20matches%2C%20which%20amount%20to%20traffic%20being%20blocked%20with%20WAF%20in%20Prevention%20Mode%2C%20and%20count%20how%20many%20there%20have%20been%20from%20the%20same%20IP%20in%20the%20last%205%20minutes.%20The%20thinking%20is%20that%20if%20a%20single%20source%20is%20repeatedly%20triggering%20blocks%2C%20they%20must%20be%20up%20to%20no%20good.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-sql%22%3E%3CCODE%3EAzureDiagnostics%0A%0A%7C%26nbsp%3Bwhere%26nbsp%3BCategory%26nbsp%3B%3D%3D%26nbsp%3B%22FrontdoorWebApplicationFirewallLog%22%0A%0A%7C%26nbsp%3Bwhere%26nbsp%3Baction_s%26nbsp%3B%3D%3D%26nbsp%3B%22Block%22%0A%0A%7C%26nbsp%3Bsummarize%26nbsp%3BStartTime%26nbsp%3B%3D%26nbsp%3Bmin(TimeGenerated)%2C%26nbsp%3BEndTime%26nbsp%3B%3D%26nbsp%3Bmax(TimeGenerated)%2C%26nbsp%3Bcount()%26nbsp%3Bby%26nbsp%3BclientIP_s%2C%26nbsp%3Bhost_s%2C%26nbsp%3B_ResourceId%0A%0A%7C%26nbsp%3Bwhere%26nbsp%3Bcount_%26nbsp%3B%26gt%3B%3D%26nbsp%3B3%0A%0A%7C%26nbsp%3Bextend%26nbsp%3BclientIP_s%2C%26nbsp%3Bhost_s%2C%26nbsp%3Bcount_%2C%26nbsp%3B_ResourceId%0A%0A%7C%26nbsp%3Bextend%26nbsp%3BIPCustomEntity%26nbsp%3B%3D%26nbsp%3BclientIP_s%0A%0A%7C%26nbsp%3Bextend%26nbsp%3BURLCustomEntity%26nbsp%3B%3D%26nbsp%3Bhost_s%0A%0A%7C%26nbsp%3Bextend%26nbsp%3BHostCustomEntity%26nbsp%3B%3D%26nbsp%3B_ResourceId%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENotice%20that%20we%20are%20using%20entity%20mapping%20for%20the%20resource%20ID%20of%20the%20Front%20Door%20that%20blocked%20the%20requests%3B%20this%20becomes%20important%20when%20creating%20response%20actions%20with%20Playbooks.%20The%20full%20details%20of%20our%20example%20analytic%20can%20be%20seen%20in%20the%20screen%20capture%20below%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22WAFAnalytic2.gif%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F222600i3465939307618F49%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22WAFAnalytic2.gif%22%20alt%3D%22WAFAnalytic2.gif%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWith%20this%20Analytic%20active%2C%20any%20source%20IP%20address%20that%20generates%203%20or%20more%20rule%20matches%20in%205%20minutes%20will%20generate%20an%20alert%20and%20incident.%20A%20playbook%20will%20also%20be%20automatically%20triggered%2C%20which%20is%20covered%20in%20the%20next%20section.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-117277390%22%20id%3D%22toc-hId-117278076%22%20id%3D%22toc-hId-117278076%22%20id%3D%22toc-hId-117278076%22%3ERespond%20to%20Incidents%20with%20Playbooks%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EA%20Sentinel%20Playbook%20is%20what%20is%20used%20to%20execute%20actions%20in%20response%20to%20Incidents.%20Playbooks%20are%20mostly%20the%20same%20as%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Flogic-apps%2Flogic-apps-overview%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3ELogic%20Apps%3C%2FA%3E%2C%20which%20are%20mostly%20the%20same%20as%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpower-automate%2Fgetting-started%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EPower%20Automate%3C%2FA%3E.%20Sentinel%20Playbooks%20always%20start%20with%20the%20Sentinel%20trigger%2C%20which%20will%20pass%20dynamic%20content%20into%20the%20Logic%20App%20pipeline.%20Specifically%2C%20we%20are%20looking%20for%20the%20Resource%20ID%20of%20the%20Front%20Door%20(the%20Playbook%20also%20supports%20Application%20Gateway)%20in%20order%20to%20look%20up%20the%20information%20needed%20to%20perform%20the%20remediation%20actions.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFrom%20the%20example%20in%20the%20Analytics%20section%2C%20we%20have%20detected%20multiple%20WAF%20rule%20matches%20from%20the%20same%20IP%20address%2C%20and%20we%20want%20to%20block%20any%20further%20action%20this%20attacker%20attempts.%20Of%20course%20the%20attacker%20could%20just%20keep%20attempting%20to%20exploit%20the%20application%20from%20different%20IP%20addresses%2C%20as%20they%20often%20do%2C%20but%20automatically%20blocking%20each%20IP%20is%20a%20low%20effort%20method%20to%20make%20the%20payoff%20as%20difficult%20as%20possible.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20end%20goal%20of%20this%20Playbook%20is%20to%20create%20or%20modify%20a%20custom%20rule%20in%20a%20WAF%20Policy%20to%20block%20requests%20from%20a%20certain%20IP%20address.%20This%20is%20accomplished%20using%20the%20Azure%20REST%20API%20using%20the%20following%20broad%20steps%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3ESet%20variables%20and%20parse%20entities%20from%20the%20Incident%3C%2FLI%3E%0A%3CLI%3ECheck%20WAF%20type%20%E2%80%93%20Front%20Door%20or%20App%20Gateway%3C%2FLI%3E%0A%3CLI%3EGet%20the%20associated%20WAF%20Policy%3C%2FLI%3E%0A%3CLI%3ERead%20existing%20custom%20rules%20and%20store%20in%20an%20array%3C%2FLI%3E%0A%3CLI%3EIf%20an%20existing%20rule%20called%20%E2%80%9CSentinelBlockIP%E2%80%9D%20exists%2C%20add%20the%20attacking%20IP%20to%20the%20rule%3C%2FLI%3E%0A%3CLI%3EIf%20no%20rule%20exists%20yet%2C%20create%20a%20custom%20rule%20blocking%20the%20attacking%20IP%3C%2FLI%3E%0A%3CLI%3ERe-assemble%20the%20WAF%20Policy%20JSON%20with%20the%20new%20or%20updated%20custom%20rule%3C%2FLI%3E%0A%3CLI%3EInitiate%20a%20PUT%20request%20against%20the%20Azure%20REST%20API%20to%20update%20the%20WAF%20Policy%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EHere%20is%20what%20the%20Playbook%20looks%20like%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22WAFPlaybook.gif%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F222579iB57F93B22776F225%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22WAFPlaybook.gif%22%20alt%3D%22WAFPlaybook.gif%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FAzure-Network-Security%2Ftree%2Fmaster%2FAzure%2520WAF%2FSentinel%2520Playbook%2520-%2520Block%2520IP%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EThis%20playbook%3C%2FA%3E%20can%20be%20deployed%20from%20our%20GitHub%20repository.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20see%20everything%20we%20covered%20in%20this%20post%20and%20more%20in%20video%20format%2C%20%3CA%20href%3D%22http%3A%2F%2Faka.ms%2FSCI_videohub_SCIVOD11%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Echeck%20it%20out%20here%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIt%20is%20our%20hope%20that%20you%20now%20have%20the%20tools%20and%20skills%20needed%20to%20take%20log%20data%20from%20Azure%20WAF%20and%20use%20it%20in%20Azure%20Sentinel%20to%20detect%2C%20investigate%2C%20and%20automatically%20respond%20to%20threats%20against%20your%20web%20applications.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1720306%22%20slang%3D%22en-US%22%3E%3CP%3EAzure%20WAF%20will%20prevent%20attacks%20against%20your%20web%20applications.%20However%2C%20leaving%20WAF%20alone%20to%20do%20its%20job%20is%20not%20enough%3B%20security%20teams%20can%20use%20Sentinel%20to%20do%20much%20more.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1720306%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20Network%20Security%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAzure%20Sentinel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAzure%20WAF%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1767509%22%20slang%3D%22en-US%22%3ERe%3A%20Integrating%20Azure%20Web%20Application%20Firewall%20with%20Azure%20Sentinel%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1767509%22%20slang%3D%22en-US%22%3E%3CP%3E%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%26nbsp%3B%20looks%20like%20something%20to%20have%20on%20the%20long%20term%20goals%20for%20your%20new%20analysts%26nbsp%3B%20%3A)%3C%2Fimg%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Microsoft

Written in collaboration with @Chris Boehm and @aprakash13 

 

Introduction

 

Readers of this post will hopefully be familiar with both Azure Sentinel and Azure WAF. The idea we will be discussing is how to take the log data generated by WAF and do something useful with it in Sentinel, such as visualize patterns, detect potentially malicious activities, and respond to threats. If configured and tuned correctly (a topic for another post), Azure WAF will prevent attacks against your web applications. However, leaving WAF alone to do its job is not enough; security teams need to analyze the data to determine where improvements can be made and where extra action may be required on the part of response teams.

 

Send WAF Data to Sentinel

 

The first step to integrating these tools is to send WAF logs and other relevant data, such as access logs and metrics, to Sentinel. This process can be initiated using the built-in Sentinel Data Connector for Azure WAF:

Anthony_Roman_0-1601299630052.png

 

Once you have connected your WAF data sources to Azure Sentinel, you can visualize and monitor the data using Workbooks, which provide versatility in creating custom dashboards. Looking inside the Azure Sentinel Workbooks tab, look up the default Azure WAF Workbook template to get you started with all WAF data types.

 

Picture1.gif

 

When starting out with the Microsoft WAF Workbook, you’ll be faced with a few data filter options:

In the short annotation below, you’ll be taken through a few preconfigured filters, two different subscriptions (across two different tenants), while having preselected two different workspaces. The annotation is going to walk through a SQL Injection attack that was detected and how you can filter down the information by time or by event data. Like an IPAddress or Tracking ID provided by the diagnostic logs.

 

If you’re unfamiliar with a workbook, the design is a top to bottom filter experience. If you filter the top of the workbook, it’ll filter everything below with the selected filters above. You’ll see some filters that were not selected, example being “Blocked or Matched” within the logs, or the Blocked Request URI Addresses. Both could have been selected and filtered across the workbook.

 

WAFWorkbook3.gif

 

Hunting Using WAF Data

 

The core idea of Azure Sentinel is that relevant security regarding your hunting or investigation is produced in multiple locations/logs and being able to analyze them from a single point makes it easier to spot trends and see patterns that are out of the ordinary. The logs from our Azure WAF device is one critical part of this puzzle. As more and more companies move their applications to the cloud their Web Application security posture has become super relevant in their overall security framework. Through the WAF logs, we can analyze the application traffic and combine it with other data feeds to uncover various attack patterns that an organization needs to be aware of.

 

However, to be able to effectively use the telemetry from WAF, a general understanding of the WAF logs is critical.  It is very hard to focus on the hunting mission, be productive and effective if we don’t understand the data.  WAF data is collected in Azure Sentinel under the AzureDiagnostics table. Depending on whether the Azure WAF policy is applied to web applications hosted on Application Gateway or Azure Front Doors the category under which the logs are collected are a little different.

 

While we don’t cover this thoroughly in this post, WAF Policies can be applied to CDN; more information here. When applied to CDN, the relevant logs are under the category:

  • WebApplicationFirewallLogs (set on the WAF Policy)
  • AzureCdnAccessLog (set on the CDN Profile)

There are subtle and nuanced differences between both these log types (Application Gateway vs Front Door) however in general, when we talk about the Access Logs, they give us an idea about Application’s access patterns. The firewall logs on the other hand logs any request that matches a WAF rule through either detection or prevention mode of the WAF policy. These logs include a bunch of interesting information like the caller's IP, port, requested URL, UserAgent and bytes in and out. The Azure Sentinel GitHub repository is a great source of inspiration for the kind of hunting and detection queries that one can build with some of these fields. However, let us go through a couple of examples of what we can do with this data.

 

One of the techniques that a lot of threat hunters have in their arsenal is count based hunting i.e. they aggregate the event data and look for events that crosses a particular threshold. For example, in the WAF data we could probably look for a number of sessions originating from a particular client IP address in a given interval of time. Once the number of connections exceeds a particular threshold value, an alert could be triggered for further investigation.

However, since each environment is different, we will have to modify the threshold value accordingly. Additionally, IP based session tracking have their own challenges and false positives due to various dynamic factors like Proxy/NAT etc. that we would have to be mindful of for these type of queries.

 

 

 

 

let Threshold = 200;  //Adjust the threshold to a suitable value based on Environment, Time Period.

let AllData =  AzureDiagnostics

| where TimeGenerated >= ago(1d)

| where Category in ("FrontdoorWebApplicationFirewallLog", "FrontdoorAccessLog", "ApplicationGatewayFirewallLog", "ApplicationGatewayAccessLog")

| extend ClientIPAddress = iff( Category in ("FrontdoorWebApplicationFirewallLog", "ApplicationGatewayAccessLog"), clientIP_s, clientIp_s);

let SuspiciousIP = AzureDiagnostics

| where TimeGenerated >= ago(1d)

| where Category in ( "ApplicationGatewayFirewallLog", "ApplicationGatewayAccessLog", "FrontdoorWebApplicationFirewallLog", "FrontdoorAccessLog")

| extend ClientIPAddress = iff( Category in ("FrontdoorWebApplicationFirewallLog", "ApplicationGatewayAccessLog"), clientIP_s, clientIp_s)

| extend SessionTrackingID = iff( Category in ("FrontdoorWebApplicationFirewallLog", "FrontdoorAccessLog"), trackingReference_s, transactionId_g)

| distinct  ClientIPAddress, SessionTrackingID

| summarize count() by ClientIPAddress

| where count_ > Threshold

| distinct ClientIPAddress;

SuspiciousIP

| join kind = inner ( AllData) on ClientIPAddress

| extend SessionTrackingID = iff( Category in ("FrontdoorWebApplicationFirewallLog", "FrontdoorAccessLog"), trackingReference_s, transactionId_g)

| summarize makeset(requestUri_s), makeset(requestQuery_s), makeset(SessionTrackingID), makeset(clientPort_d),  SessionCount = count() by ClientIPAddress, _ResourceId

| extend HostCustomEntity =  _ResourceId, IPCustomEntity = ClientIPAddress

 

 

 

 

Another way to leverage the WAF data could be through Indicators of Compromise (IoCs) matching. IoCs are data that associates observations such as URLs, file hashes or IP addresses with known threat activity such as phishing, botnets, or malware. Many organizations aggregate threat indicators feed from a variety of sources, curate the data and then apply it to their available logs. They could match these IoCs with their WAF logs as well. For more details check out this great blog post that talks about how you can import threat intelligence (TI) data into Azure Sentinel.  Once the TI data is imported in Azure Sentinel you can view it in the ThreatIntelligenceIndicator table in Logs. Below is a quick example of how you can match the WAF data with the TI data to see if there is any traffic that is originating from a Bot Network or from an IP that is known to be bad.

 

 

 

let dt_lookBack  = 1h;

let ioc_lookBack = 14d;

ThreatIntelligenceIndicator

| where TimeGenerated >= ago(ioc_lookBack) and ExpirationDateTime > now()

| where Active == true

// Picking up only IOC's that contain the entities we want

| where isnotempty(NetworkIP) or isnotempty(EmailSourceIpAddress) or isnotempty(NetworkDestinationIP) or isnotempty(NetworkSourceIP)

// As there is potentially more than 1 indicator type for matching IP, taking NetworkIP first, then others if that is empty.

// Taking the first non-empty value based on potential IOC match availability

| extend TI_ipEntity = iff(isnotempty(NetworkIP), NetworkIP, NetworkDestinationIP)

| extend TI_ipEntity = iff(isempty(TI_ipEntity) and isnotempty(NetworkSourceIP), NetworkSourceIP, TI_ipEntity)

| extend TI_ipEntity = iff(isempty(TI_ipEntity) and isnotempty(EmailSourceIpAddress), EmailSourceIpAddress, TI_ipEntity)

| join (

AzureDiagnostics | where TimeGenerated >= ago(dt_lookBack)

| where Category in ( 'ApplicationGatewayFirewallLog', 'FrontdoorWebApplicationFirewallLog', 'ApplicationGatewayAccessLog', 'FrontdoorAccessLog')

| where isnotempty(clientIP_s) or isnotempty(clientIp_s)

| extend ClientIPAddress = iff( Category in ("FrontdoorWebApplicationFirewallLog", "ApplicationGatewayAccessLog"), clientIP_s, clientIp_s)

| extend WAF_TimeGenerated = TimeGenerated

)

on $left.TI_ipEntity == $right.ClientIPAddress

| project TimeGenerated, ClientIPAddress, Description, ActivityGroupNames, IndicatorId, ThreatType, ExpirationDateTime, ConfidenceScore,_ResourceId, WAF_TimeGenerated, Category, ResourceGroup, SubscriptionId, ResourceType,OperationName, requestUri_s, ruleName_s, host_s, clientPort_d,details_data_s, details_matches_s, Message, ruleSetType_s, policyScope_s

| extend IPCustomEntity = ClientIPAddress, HostCustomEntity = _ResourceId, timestamp = WAF_TimeGenerated, URLCustomEntity = requestUri_s

 

 

 

 

Threat hunters could even leverage KQL advanced modelling capabilities on WAF logs to find anomalies. For example, they could do the Time Series analysis on the WAF data. Time Series is a series of data points indexed (or listed or graphed) in time order. By analyzing time series data over an extended period, we can identify time-based patterns (e.g. seasonality, trend etc.) in the data and extract meaningful statistics which can help in flagging outliers. The different Thresholds would have to be adjusted depending on the environment.  

 

Below is an example query demonstrating Time Series IP anomaly.

 

 

 

let percentotalthreshold = 25;

let timeframe = 1h;

let starttime = 14d;

let endtime = 1d;

let scorethreshold = 5;

let baselinethreshold = 10;

let TimeSeriesData =  AzureDiagnostics

  | where Category in ( "ApplicationGatewayFirewallLog", "ApplicationGatewayAccessLog", "FrontdoorWebApplicationFirewallLog", "FrontdoorAccessLog") and action_s in ( "Log", "Matched", "Detcted")

  | where isnotempty(clientIP_s) or isnotempty(clientIp_s)

  | extend ClientIPAddress = iff( Category in ("FrontdoorWebApplicationFirewallLog", "ApplicationGatewayAccessLog"), clientIP_s, clientIp_s)

  | where TimeGenerated between ((ago(starttime))..(ago(endtime)))

  | project TimeGenerated, ClientIPAddress

  | make-series Total=count() on TimeGenerated from (ago(starttime)) to (ago(endtime)) step timeframe by ClientIPAddress;

let TimeSeriesAlerts=TimeSeriesData

  | extend (anomalies, score, baseline) = series_decompose_anomalies(Total, scorethreshold, 1, 'linefit')

  | mv-expand Total to typeof(double), TimeGenerated to typeof(datetime), anomalies to typeof(double),score to typeof(double), baseline to typeof(long)

  | where anomalies > 0 | extend score = round(score,2), AnomalyHour = TimeGenerated

  | project ClientIPAddress, AnomalyHour, TimeGenerated, Total, baseline, anomalies, score

  | where baseline > baselinethreshold;

  TimeSeriesAlerts

  | join (

      AzureDiagnostics

      | extend ClientIPAddress = iff( Category in ("FrontdoorWebApplicationFirewallLog", "ApplicationGatewayAccessLog"), clientIP_s, clientIp_s)

  | where isnotempty(ClientIPAddress)

  | where TimeGenerated  > ago(endtime)

  | summarize HourlyCount = count(), TimeGeneratedMax = arg_max(TimeGenerated, *), ClientIPlist = make_set(clientIP_s), Portlist = make_set(clientPort_d) by clientIP_s, TimeGeneratedHour= bin(TimeGenerated, 1h)

  | extend AnomalyHour = TimeGeneratedHour

  ) on ClientIPAddress

  | extend PercentTotal = round((HourlyCount / Total) * 100, 3)

  | where PercentTotal > percentotalthreshold

  | project  AnomalyHour, TimeGeneratedMax, ClientIPAddress, ClientIPlist, Portlist, HourlyCount, PercentTotal, Total, baseline, score, anomalies, requestUri_s, trackingReference_s, _ResourceId, SubscriptionId, ruleName_s, hostname_s, policy_s, action_s

  | summarize HourlyCount=sum(HourlyCount), StartTimeUtc=min(TimeGeneratedMax), EndTimeUtc=max(TimeGeneratedMax), SourceIPlist = make_set(ClientIPAddress), Portlist = make_set(Portlist) by ClientIPAddress , AnomalyHour, Total, baseline, score, anomalies, requestUri_s, trackingReference_s, _ResourceId, SubscriptionId, ruleName_s, hostname_s, policy_s, action_s

  | extend HostCustomEntity =  _ResourceId, IPCustomEntity = ClientIPAddress

 

 

 

 

Generate Incidents using Azure Sentinel Analytics

 

Azure Sentinel uses the concept of Analytics to accomplish Incident creation, alerting, and eventually automated response. The main piece of any Analytic rule is the KQL query that powers it. If the query returns data (over a configured threshold), an alert will fire. To use this in practice, you need to craft a query that returns results worthy of an alert.

 

The logic used can be complex, possibly adapted from the hunting logic outlined above, or fairly basic like the example below. It can be difficult to know what combination of WAF events warrant attention from analysts or even an automated response. We will assume the WAF has been tuned to eliminate most false positives, and that rule matches are usually indicative of malicious behavior.

 

The Analytic Rule we will look at serves the purpose of detecting repeated attacks from the same source IP address. We simply look for WAF rule matches, which amount to traffic being blocked with WAF in Prevention Mode, and count how many there have been from the same IP in the last 5 minutes. The thinking is that if a single source is repeatedly triggering blocks, they must be up to no good.

 

 

 

AzureDiagnostics

| where Category == "FrontdoorWebApplicationFirewallLog"

| where action_s == "Block"

| summarize StartTime = min(TimeGenerated), EndTime = max(TimeGenerated), count() by clientIP_s, host_s, _ResourceId

| where count_ >= 3

| extend clientIP_s, host_s, count_, _ResourceId

| extend IPCustomEntity = clientIP_s

| extend URLCustomEntity = host_s

| extend HostCustomEntity = _ResourceId

 

 

 

 

Notice that we are using entity mapping for the resource ID of the Front Door that blocked the requests; this becomes important when creating response actions with Playbooks. The full details of our example analytic can be seen in the screen capture below:

WAFAnalytic2.gif

 

With this Analytic active, any source IP address that generates 3 or more rule matches in 5 minutes will generate an alert and incident. A playbook will also be automatically triggered, which is covered in the next section.

 

Respond to Incidents with Playbooks

 

A Sentinel Playbook is what is used to execute actions in response to Incidents. Playbooks are mostly the same as Logic Apps, which are mostly the same as Power Automate. Sentinel Playbooks always start with the Sentinel trigger, which will pass dynamic content into the Logic App pipeline. Specifically, we are looking for the Resource ID of the Front Door (the Playbook also supports Application Gateway) in order to look up the information needed to perform the remediation actions.

 

From the example in the Analytics section, we have detected multiple WAF rule matches from the same IP address, and we want to block any further action this attacker attempts. Of course the attacker could just keep attempting to exploit the application from different IP addresses, as they often do, but automatically blocking each IP is a low effort method to make the payoff as difficult as possible.

 

The end goal of this Playbook is to create or modify a custom rule in a WAF Policy to block requests from a certain IP address. This is accomplished using the Azure REST API using the following broad steps:

  • Set variables and parse entities from the Incident
  • Check WAF type – Front Door or App Gateway
  • Get the associated WAF Policy
  • Read existing custom rules and store in an array
  • If an existing rule called “SentinelBlockIP” exists, add the attacking IP to the rule
  • If no rule exists yet, create a custom rule blocking the attacking IP
  • Re-assemble the WAF Policy JSON with the new or updated custom rule
  • Initiate a PUT request against the Azure REST API to update the WAF Policy

Here is what the Playbook looks like:

WAFPlaybook.gif

 

This playbook can be deployed from our GitHub repository.

 

To see everything we covered in this post and more in video format, check it out here.

 

It is our hope that you now have the tools and skills needed to take log data from Azure WAF and use it in Azure Sentinel to detect, investigate, and automatically respond to threats against your web applications.

1 Comment
Respected Contributor

@Gary Bushey  looks like something to have on the long term goals for your new analysts  :)