%3CLINGO-SUB%20id%3D%22lingo-sub-1811827%22%20slang%3D%22en-US%22%3EExpanding%20Microsoft%20Teams%20Log%20Data%20in%20Azure%20Sentinel%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1811827%22%20slang%3D%22en-US%22%3E%3CP%3E%3CEM%3ETom%20McElroy%2C%20Pete%20Bryan%26nbsp%3B-%20Microsoft%20Threat%20Intelligence%20Center%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPete%20Bryan%20posted%20a%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-sentinel%2Fprotecting-your-teams-with-azure-sentinel%2Fba-p%2F1265761%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3Eblog%3C%2FA%3E%20in%20March%20detailing%20how%20to%20protect%20Microsoft%20Teams%20with%20Azure%20Sentinel.%20Since%20then%20a%20new%20Teams%20connector%20has%20entered%20public%20preview%2C%26nbsp%3Bthis%20allows%20Teams%20data%20to%20be%20accessed%20without%20the%20need%20for%20a%20custom%20log.%20Using%20the%20official%20connector%20means%20you%20will%20be%20able%20to%20take%20advantage%20of%20new%20Teams%20log%20events%20as%20they%20become%20available.%20More%20information%20on%20setting%20the%20connector%20up%20can%20he%20found%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-sentinel%2Fwhat-s-new-microsoft-teams-connector-in-public-preview%2Fba-p%2F1640003%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3Ehere%3C%2FA%3E.%26nbsp%3B%3CEM%3E%3CSTRONG%3ETeams%20logs%20are%20provided%20by%20the%20Office%20365%20connector%20as%20part%20of%20Office%20Activity%20logging%20so%20will%20not%20incur%20additional%20costs%20to%20ingest%20if%20Office%20Activity%20logs%20are%20already%20being%20ingested.%3C%2FSTRONG%3E%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20blog%20post%20will%20cover%20how%20Teams%20logs%20can%20be%20expanded%20to%20provide%20deeper%20security%20insight%20by%20mapping%20additional%20data%20from%20other%20tables%20available%20in%20Azure%20Sentinel%2C%20the%20topics%20covered%20are%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EExtracting%20Teams%20file%20sharing%20information%3C%2FLI%3E%0A%3CLI%3EMapping%20Teams%20logs%20to%20Teams%20call%20records%3C%2FLI%3E%0A%3CLI%3EMerging%20Teams%20logs%20with%20sign%20in%20activity%20to%20detect%20anomalous%20actions%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1214921493%22%20id%3D%22toc-hId--1214921493%22%3EExploring%20Teams%20File%20Sharing%3C%2FH2%3E%0A%3CP%3ETeams%20allows%20users%20to%20share%20files%20in%20conversations%2C%20this%20feature%20is%20commonly%20used%20to%20share%20meeting%20notes%2C%20agendas%20or%20documents%20when%20collaborating%20on%20a%20piece%20of%20work.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhen%20sharing%20a%20file%20on%20Teams%20it%20uses%20underlying%20Office%20technology%20to%20upload%20the%20file%20to%20the%20users%20OneDrive%2C%20it%20then%20shares%20the%20file%20using%20existing%20SharePoint%20operations.%20While%20file%20sharing%20information%20is%20not%20available%20in%20the%20local%20Teams%20Log%2C%20it%20can%20be%20extracted%20from%20the%20Office%20Activity%20log.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETeams%20file%20uploads%20are%20recorded%20in%20the%20Office%20activity%20log%20as%20SharePoint%20file%20operations.%20To%20distinguish%20Teams%20file%20uploads%20from%20other%20services%20the%20column%20%E2%80%9CSourceRelativeURL%E2%80%9D%20is%20populated%20with%20the%20entry%20%E2%80%9CMicrosoft%20Teams%20Chat%20Files%E2%80%9D.%20The%20query%20below%20will%20extract%20Teams%20file%20uploads%20from%20the%20Office%20Activity%20log.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3EOfficeActivity%20%0A%7C%20where%20RecordType%20%3D~%20%22SharePointFileOperation%22%20%0A%7C%20where%20UserId%20!~%20%22app%40sharepoint%22%0A%7C%20where%20SourceRelativeUrl%20has%20%22Microsoft%20Teams%20Chat%20Files%22%20%0A%7C%20where%20Operation%20%3D~%20%22FileUploaded%22%20%0A%7C%20project%20TimeGenerated%2C%20UserId%2C%20ClientIP%2C%20Site_Url%2C%20OfficeObjectId%2C%20SourceFileName%2C%20SourceFileExtension%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20query%20can%20now%20be%20expanded%20to%20find%20suspiciously%20named%20files.%20Either%20a%20list%20of%20potentially%20suspicious%20filenames%20can%20be%20provided%2C%20or%20an%20external%20data%20source%20can%20be%20used.%20In%20the%20below%20query%2C%20matching%20is%20being%20performed%20to%20detect%20users%20sharing%20passwords%20or%20files%20containing%20a%20confidential%20term.%20A%20list%20of%20terms%20can%20be%20passed%20in%20using%20a%20list%2C%20in%20the%20example%20below%20the%20list%20is%20called%20%E2%80%9CsuspiciousFilenames%E2%80%9D.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3Elet%20suspiciousFilenames%20%3D%20dynamic(%5B'password'%2C%20'admin'%2C%20'confidential_term'%5D)%3B%0AOfficeActivity%20%0A%7C%20where%20RecordType%20%3D~%20%22SharePointFileOperation%22%20%0A%7C%20where%20UserId%20!~%20%22app%40sharepoint%22%0A%7C%20where%20SourceRelativeUrl%20has%20%22Microsoft%20Teams%20Chat%20Files%22%20%0A%7C%20where%20Operation%20%3D~%20%22FileUploaded%22%20%0A%7C%20project%20TimeGenerated%2C%20UserId%2C%20ClientIP%2C%20Site_Url%2C%20OfficeObjectId%2C%20SourceFileName%2C%20SourceFileExtension%0A%7C%20where%20SourceFileName%20has_any(suspiciousFilenames)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20query%20can%20be%20modified%20to%20search%20for%20suspicious%20file%20extensions%20instead%2C%20the%20query%20below%20will%20show%20common%20Windows%20executable%20files%20being%20shared%20through%20Teams.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3Elet%20suspiciousExtensions%20%3D%20dynamic(%5B'exe'%2C%20'msi'%2C%20'bin'%2C%20'dll'%5D)%3B%0AOfficeActivity%20%0A%7C%20where%20RecordType%20%3D~%20%22SharePointFileOperation%22%20%0A%7C%20where%20UserId%20!~%20%22app%40sharepoint%22%0A%7C%20where%20SourceRelativeUrl%20has%20%22Microsoft%20Teams%20Chat%20Files%22%20%0A%7C%20where%20Operation%20%3D~%20%22FileUploaded%22%20%0A%7C%20project%20TimeGenerated%2C%20UserId%2C%20ClientIP%2C%20Site_Url%2C%20OfficeObjectId%2C%20SourceFileName%2C%20SourceFileExtension%0A%7C%20where%20SourceFileExtension%20has_any(suspiciousExtensions)%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EJoining%20either%20of%20the%20above%20queries%20back%20to%20the%20Office%20activity%20log%20allows%20the%20query%20to%20extract%20how%20many%20users%20received%20the%20file%20and%20how%20many%20users%20opened%20the%20file%2C%20with%20counts%20for%20each.%20In%20the%20below%20example%20the%20suspicious%20file%20name%20query%20has%20been%20expanded%20to%20collect%20the%20additional%20user%20information.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3Elet%20suspiciousFilenames%20%3D%20dynamic(%5B'password'%2C%20'admin'%2C%20'confidential_term'%5D)%3B%0AOfficeActivity%0A%2F%2FGet%20teams%20files%20where%20the%20file%20is%20being%20uploaded%2C%20teams%20uses%20SharePoint%20and%20OneDrive%20for%20file%20sharing%0A%7C%20where%20RecordType%20%3D~%20%22SharePointFileOperation%22%0A%7C%20where%20SourceRelativeUrl%20contains%20%22Microsoft%20Teams%20Chat%20Files%22%0A%7C%20where%20Operation%20%3D~%20%22FileUploaded%22%0A%2F%2FCheck%20for%20a%20suspicious%20file%20name%2C%20comment%20out%20to%20see%20all%20files%0A%7C%20where%20SourceFileName%20has%20suspiciousFilenames%0A%7C%20summarize%20by%20TimeGenerated%2C%20OfficeObjectId%2C%20UserId%2C%20ClientIP%2C%20SourceFileName%0A%2F%2FCount%20how%20many%20users%20it%20was%20shared%20to%2C%20we%20can't%20get%20who%20it%20was%20shared%20to%20here%0A%7C%20join%20kind%3Dleftouter%20(%0AOfficeActivity%0A%2F%2FWhen%20sending%20a%20file%20in%20teams%20a%20new%20sharepoint%20sharing%20operation%20event%20is%20generated%2C%20teams%20shares%20the%20file%20with%20all%20the%20users%20in%20a%20chat%0A%7C%20where%20RecordType%20%3D~%20%22SharePointSharingOperation%22%0A%7C%20where%20Operation%20%3D~%20%22SharingSet%22%0A%7C%20where%20SourceRelativeUrl%20has%20%22Microsoft%20Teams%20Chat%20Files%22%0A%7C%20where%20UserId%20!~%20%22app%40sharepoint%22%0A%2F%2FOfficeId%20is%20a%20unique%20GUID%20for%20office%20operations%2C%20counting%20this%20provides%20the%20number%20of%20share%20events%20teams%20generated%0A%7C%20summarize%20dcount(OfficeId)%2C%20SentTo%3Dmake_list(UserId)%20by%20OfficeObjectId%20%0A)%20on%20OfficeObjectId%0A%7C%20project-away%20OfficeObjectId1%0A%2F%2FJoin%20data%20that%20shows%20who%20accessed%20the%20file%0A%7C%20join%20kind%3Dleftouter%20(%0AOfficeActivity%0A%2F%2FAgain%2C%20teams%20generated%20sharepoint%20events%20for%20users%20downloading%20or%20accessing%20the%20file%0A%7C%20where%20RecordType%20%3D~%20%22SharePointFileOperation%22%0A%7C%20where%20Operation%20%3D~%20%22FileDownloaded%22%20or%20Operation%20%3D%3D%20%22FileAccessed%22%0A%7C%20where%20UserId%20!~%20%22app%40sharepoint%22%0A%7C%20extend%20userBag%20%3D%20pack(tostring(TimeGenerated)%2C%20UserId)%0A%7C%20summarize%20make_bag(userBag)%2C%20dcount(UserId)%20by%20OfficeObjectId%20%0A)%20on%20OfficeObjectId%20%0A%7C%20project%20TimeGenerated%2C%20SourceFileName%2C%20Uploader%3DUserId%2C%20UploaderIP%3DClientIP%2C%20UsersSentCount%3Ddcount_OfficeId%2C%20UsersOpenedCount%3Ddcount_UserId%2C%20AccessedBy%3Dbag_userBag%2C%20SentTo%2C%20OfficeObjectId%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhile%20the%20above%20examples%20use%20a%20fixed%20list%20of%20suspicious%20filenames%20for%20matching%2C%20the%20Kusto%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdata-explorer%2Fkusto%2Fquery%2Fexternaldata-operator%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eexternal%20data%20operator%3C%2FA%3E%20can%20be%20used%20to%20import%20a%20list%20of%20known-bad%20filenames.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EMatching%20malicious%20filenames%20is%20often%20unreliable%20as%20attackers%20will%20name%20files%20to%20blend%20in%20with%20their%20target%20environment%2C%20however%2C%20this%20query%20could%20be%20used%20situationally%20in%20a%20response%20scenario%20to%20search%20of%20malicious%20documents%20that%20may%20have%20been%20passed%20between%20users.%20While%20uncommon%2C%20attacker%20spear%20phishing%20lures%20can%20prove%20so%20interesting%20that%20users%20share%20the%20lure%20beyond%20the%20initial%20recipient.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1272591340%22%20id%3D%22toc-hId-1272591340%22%3EMapping%20Teams%20log%20to%20Teams%20Call%20Records%3C%2FH2%3E%0A%3CP%3EAs%20well%20as%20providing%20key%20administrative%20and%20user%20activity%20logs%20via%20the%20new%20Teams%20connector%20we%20can%20also%20access%20specific%20call%20record%20logs.%20These%20logs%20provide%20details%20about%20calls%20and%20meetings%20made%20via%20Teams%2C%20and%20provide%20details%20about%20who%20organized%20them%2C%20who%20participated%2C%20and%20what%20technologies%20were%20used.%20These%20logs%20need%20to%20be%20collected%20separately%20from%20the%20main%20Teams%20logs%20collected%20by%20the%20connector%2C%20for%20more%20details%20about%20how%20to%20enable%20collection%20of%20these%20events%2C%20please%20refer%20to%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-sentinel%2Fsecure-your-calls-monitoring-microsoft-teams-callrecords%2Fba-p%2F1574600%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3Ethis%20blog%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOnce%20we%20have%20the%20call%20logs%20available%20to%20us%2C%20we%20can%20use%20our%20existing%20Teams%20queries%20to%20pivot%20from%20a%20user%20and%20identify%20what%20calls%20they%20have%20been%20present%20in.%20Below%20is%20an%20example%20of%20taking%20one%20of%20the%20suspicious%20file%20upload%20queries%20above%20and%20pivoting%20to%20see%20the%20call%20attendance%20of%20the%20user%20who%20originally%20shared%20the%20file.%20This%20is%20a%20good%20way%20to%20identify%20the%20scope%20of%20an%20incident%20and%20other%20impacted%20users.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3Elet%20suspiciousFilenames%20%3D%20dynamic(%5B'password'%2C%20'admin'%2C%20'confidential_term'%5D)%3B%0AOfficeActivity%0A%2F%2FGet%20teams%20files%20where%20the%20file%20is%20being%20uploaded%2C%20teams%20uses%20SharePoint%20and%20OneDrive%20for%20file%20sharing%0A%7C%20where%20RecordType%20%3D~%20%22SharePointFileOperation%22%0A%7C%20where%20SourceRelativeUrl%20contains%20%22Microsoft%20Teams%20Chat%20Files%22%0A%7C%20where%20Operation%20%3D~%20%22FileUploaded%22%0A%2F%2FCheck%20for%20a%20suspicious%20file%20name%2C%20comment%20out%20to%20see%20all%20files%0A%7C%20where%20SourceFileName%20contains%20suspiciousFilenames%0A%7C%20summarize%20by%20TimeGenerated%2C%20OfficeObjectId%2C%20UserId%2C%20ClientIP%2C%20SourceFileName%0A%2F%2FCount%20how%20many%20users%20it%20was%20shared%20to%2C%20we%20can't%20get%20who%20it%20was%20shared%20to%20here%0A%7C%20join%20kind%3Dleftouter%20(%0AOfficeActivity%0A%2F%2FWhen%20sending%20a%20file%20in%20teams%20a%20new%20sharepoint%20sharing%20operation%20event%20is%20generated%2C%20teams%20shares%20the%20file%20with%20all%20the%20users%20in%20a%20chat%0A%7C%20where%20RecordType%20%3D~%20%22SharePointSharingOperation%22%0A%7C%20where%20Operation%20%3D~%20%22SharingSet%22%0A%7C%20where%20SourceRelativeUrl%20contains%20%22Microsoft%20Teams%20Chat%20Files%22%0A%7C%20where%20UserId%20!~%20%22app%40sharepoint%22%0A%2F%2FOfficeId%20is%20a%20unique%20GUID%20for%20office%20operations%2C%20counting%20this%20provides%20the%20number%20of%20share%20events%20teams%20generated%0A%7C%20summarize%20dcount(OfficeId)%2C%20SentTo%3Dmake_list(UserId)%20by%20OfficeObjectId%20%0A)%20on%20OfficeObjectId%0A%7C%20project-away%20OfficeObjectId1%0A%2F%2FJoin%20data%20that%20shows%20who%20accessed%20the%20file%0A%7C%20join%20kind%3Dleftouter%20(%0AOfficeActivity%0A%2F%2FAgain%2C%20teams%20generated%20sharepoint%20events%20for%20users%20downloading%20or%20accessing%20the%20file%0A%7C%20where%20RecordType%20%3D~%20%22SharePointFileOperation%22%0A%7C%20where%20Operation%20%3D~%20%22FileDownloaded%22%20or%20Operation%20%3D%3D%20%22FileAccessed%22%0A%7C%20where%20UserId%20!~%20%22app%40sharepoint%22%0A%7C%20extend%20userBag%20%3D%20pack(tostring(TimeGenerated)%2C%20UserId)%0A%7C%20summarize%20make_bag(userBag)%2C%20dcount(UserId)%20by%20OfficeObjectId%20%0A)%20on%20OfficeObjectId%20%0A%7C%20project%20TimeGenerated%2C%20SourceFileName%2C%20Uploader%3DUserId%2C%20UploaderIP%3DClientIP%2C%20UsersSentCount%3Ddcount_OfficeId%2C%20UsersOpenedCount%3Ddcount_UserId%2C%20AccessedBy%3Dbag_userBag%2C%20SentTo%2C%20OfficeObjectId%0A%2F%2F%20We%20need%20to%20join%20these%20logs%20to%20AAD%20SigninEvents%20to%20get%20the%20AADUserID%20we%20need%20to%20the%20Teams%20call%20logs%0A%7C%20join%20(SigninLogs%0A%7C%20project%20UserPrincipalName%2C%20AADUserId%20%3D%20UserId)%0Aon%20%24left.Uploader%20%3D~%20%24right.UserPrincipalName%0A%2F%2FWe%20can%20now%20join%20this%20to%20our%20Teams%20call%20logs%20to%20get%20details%20of%20all%20the%20calls%20that%20the%20user%20who%20uploaded%20the%20file%20has%20participated%20in%0A%7C%20join%20(TeamsCallLogs_CL%0A%7C%20mv-expand%20todynamic(participants_s)%0A%7C%20extend%20AADUserId%20%3D%20tostring(participants_s.user.id))%0Aon%20AADUserId%0A%2F%2F%20To%20make%20the%20ouput%20a%20bit%20cleaner%20we%20can%20pack%20our%20meeting%20events%20into%20a%20single%20object.%0A%7C%20extend%20Meetings%20%3D%20pack(%22MeetingId%22%2C%20id_g%2C%20%22Type%22%2C%20type_s%2C%20%22Participants%22%2C%20participants_s%2C%20%22StartTime%22%2C%20startDateTime_t%2C%20%22EndTime%22%2C%20endDateTime_t%2C%20%22Organizer%22%2C%20organizer_user_displayName_s)%0A%7C%20summarize%20make_list(Meetings)%20by%20SourceFileName%2C%20UsersOpenedCount%2C%20Uploader%0A%7C%20extend%20meeting_count%3Darray_length(list_Meetings)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ENote%3A%3C%2FSTRONG%3E%26nbsp%3BIn%20the%20query%20above%20we%20are%20presuming%20that%20the%20custom%20table%20name%20used%20to%20ingest%20the%20Teams%20call%20logs%20is%20%E2%80%9CTeamsCallLogs_CL%E2%80%9D.%20If%20your%20configuration%20is%20different%20you%20will%20need%20to%20edit%20the%20query%20above%20to%20reflect%20that.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--534863123%22%20id%3D%22toc-hId--534863123%22%3EFinding%20Anomalous%20Teams%20Logins%3C%2FH2%3E%0A%3CP%3ECommon%20techniques%20to%20identify%20anomalous%20sign%20in%20activity%20include%20analysing%20the%20login%20locations%20for%20suspicious%20countries%2C%20searching%20for%20IP%20subnets%20that%20are%20not%20used%20commonly%2C%20and%20looking%20for%20multiple%20failed%20accesses%20followed%20by%20a%20successful%20login%20to%20detect%20brute%20force%20activity.%20These%20techniques%20are%20effective%20at%20identifying%20potentially%20suspicious%20activity%20but%20can%20generate%20high%20false%20positive%20rates.%20With%20more%20users%20working%20from%20home%2C%20some%20of%20these%20techniques%20have%20become%20impractical%20given%20the%20network%20diversity%20when%20users%20connect%20from%20home%20offices.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWith%20additional%20information%20from%20other%20log%20sources%20it%20is%20possible%20to%20improve%20confidence%20in%20the%20detections.%20Anomalous%20login%20techniques%20can%20be%20corelated%20with%20log%20data%20from%20applications%20to%20determine%20if%20an%20administrative%20action%20was%20performed%20during%20a%20time%20window%20after%20a%20successful%20anomalous%20login%20has%20occurred.%20The%20new%20Teams%20connector%20provides%20logging%20of%20Teams%20events%2C%20including%20administrative%20events%2C%20which%20can%20be%20used%20to%20detect%20potentially%20suspicious%20Teams%20activity%20taking%20place.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ECertain%20actions%20in%20Teams%20will%20result%20in%20a%20log%20entry%2C%20this%20ranges%20from%20a%20Teams%20session%20starting%20to%20administrative%20actions%20e.g.%20deleting%20a%20team.%20This%20information%20is%20logged%20to%20the%20%E2%80%9COperation%E2%80%9D%20column%20of%20the%20Teams%20log.%20As%20seen%20in%20the%20image%20below%20the%20most%20common%20event%20%E2%80%9CTeamsSessionStarted%E2%80%9D%20is%20shown.%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-center%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20573px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F228689i8E83132F406D08B2%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThere%20are%20a%20number%20of%20operations%20within%20the%20Teams%20log%20that%20can%20be%20considered%20administrative%2C%20and%20a%20subset%20of%20those%20have%20potential%20application%20in%20a%20threat%20actors%20campaign%2C%20in%20this%20example%20the%20following%20actions%20will%20be%20used%20as%20indicators%20of%26nbsp%3Bof%20potentially%20suspicious%20activity%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3EOfficeActivity%0A%7C%20where%20OfficeWorkload%20%3D~%20%22MicrosoftTeams%22%0A%7C%20where%20Operation%20in~%20(%22TeamsAdminAction%22%2C%20%22MemberAdded%22%2C%20%22MemberRemoved%22%2C%20%22MemberRoleChanged%22%2C%20%22AppInstalled%22%2C%20%22BotAddedToTeam%22)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EA%20TeamsAdminAction%20operation%20is%20logged%20when%20a%20team%20administrative%20action%20is%20performed%2C%20this%20covers%20a%20wide%20range%20of%20administrative%20actions%20that%20can%20be%20performed%20by%20an%20account%20with%20an%20administrator%20role%2C%20a%20full%20list%20of%20action%20can%20be%20found%20%3CA%20href%3D%22.%2520https%3A%2Fdocs.microsoft.com%2Fen-us%2FMicrosoftTeams%2Fusing-admin-roles%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehere%3C%2FA%3E.%20Many%20of%20these%20actions%20would%20be%20useful%20to%20an%20attacker%2C%20allowing%20management%20of%20meetings%2C%20call%20policies%2C%20viewing%20user%20profiles%20and%20accessing%20monitoring%20and%20reporting%20from%20Teams.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EMemberAdded%20and%20MemberRemoved%20operations%20can%20be%20performed%20by%20any%20Teams%20user%20that%20is%20an%20administrator%20of%20a%20Team.%20These%20events%20are%20generated%20when%20a%20member%20is%20added%20to%20or%20removed%20from%20a%20Team.%20After%20compromising%20a%20legitimate%20account%2C%20a%20malicious%20actor%20may%20attempt%20to%20add%20their%20own%20account%20to%20meetings%20that%20they%20wish%20to%20eavesdrop%20on%2C%20the%20actor%20may%20remove%20that%20same%20member%20after%20data%20has%20been%20collected%20from%20the%20Team.%20Generally%2C%20these%20events%20are%20quite%20common%2C%20but%20when%20following%20an%20anomalous%20login%2C%20they%20should%20be%20treated%20as%20suspicious.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20AppInstalled%20and%20BotAddedToTeam%20log%20events%20are%20generated%20when%20an%20app%20or%20bot%20is%20installed%20into%20Teams.%20An%20attacker%20could%20use%20this%20to%20install%20malicious%20Teams%20addons%20or%20bots%20using%20the%20custom%20app%20upload%20feature.%20Apps%20and%20bots%20are%20installed%20on%20a%20per-user%20basis%2C%20but%20can%20be%20added%20to%20a%20Team%20by%20a%20user.%3C%2FP%3E%0A%3CP%3E%3CBR%20%2F%3ENow%20that%20potentially%20suspicious%20operations%20within%20Teams%20are%20identified%2C%20a%20query%20can%20be%20constructed%20that%20enriches%20the%20sign%20in%20log%20data%20with%20Teams%20data%20to%20find%20anomalous%20logins%20that%20were%20followed%20by%20an%20administrative%20action.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20query%20below%20first%20collects%20successful%20logins%20to%20Teams%20from%20sign%20in%20logs%2C%20it%20then%20calculates%20the%20delta%20for%20each%20user%20of%20the%20IP%20addresses%20used%20to%20login.%20Calculating%20the%20delta%20between%20the%20least%20used%20IP%20and%20the%20most%20used%20IP%20for%20each%20user%20will%20find%20accounts%20where%20an%20IP%20has%20been%20used%20to%20login%20only%20a%20handful%20of%20times%20vs.%20the%20user%E2%80%99s%20normal%20login%20activity.%20As%20no%20fixed%20values%20are%20used%20this%20also%20means%20that%20the%20detection%20will%20scale%20based%20on%20the%20user%E2%80%99s%20activity%20level.%20It%20will%20also%20adapt%20to%20activity%20where%20the%20user%20is%20roaming%20on%20a%20home%20connection.%20Even%20on%20internet%20service%20providers%20with%20dynamic%20IP%20addresses%2C%20the%20lease%20time%20will%20be%20long%20enough%20to%20evenly%20spread%20IP%20usage.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20example%20below%20shows%20a%20standalone%20calculation%20of%20the%20delta%20between%20IP%E2%80%99s%20used%20to%20login%20to%20accounts%20in%20sign%20in%20logs%2C%20followed%20by%20the%20output%20from%20Azure%20Sentinel.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3Elet%20timeRange%20%3D%2030d%3B%0A%2F%2FThe%20delta%20(%25)%20between%20the%20largest%20in-use%20IP%20and%20the%20smallest%20%5Bdefault%3A%2090%5D%0Alet%20deltaThreshold%20%3D%2095%3B%0A%2F%2FGet%20Teams%20successful%20signins%20globally%0ASigninLogs%0A%7C%20where%20TimeGenerated%20%26gt%3B%3D%20ago(timeRange)%0A%7C%20where%20AppDisplayName%20has%20%22Teams%22%0A%7C%20where%20ConditionalAccessStatus%20%3D~%20%22success%22%0A%7C%20extend%20country%20%3D%20tostring(LocationDetails%5B'countryOrRegion'%5D)%0A%7C%20where%20isnotempty(country)%20and%20isnotempty(IPAddress)%0A%2F%2FCount%20logins%20for%20each%20IP%20address%20used%20by%20each%20user%2C%20take%20one%20example%20of%20geolocation%0A%7C%20summarize%20count()%2C%20country%3Dany(country)%2C%20make_list(TimeGenerated)%20by%20IPAddress%2C%20UserPrincipalName%0A%2F%2FPack%20IP%20and%20count%20then%20summarize%20all%20IP%20events%20for%20each%20user%0A%7C%20extend%20p%20%3D%20pack(IPAddress%2C%20count_)%0A%7C%20summarize%20max(count_)%2C%20min(count_)%2C%20make_bag(p)%20by%20UserPrincipalName%0A%2F%2FCalculate%20delta%20and%20convert%20to%20percentage%0A%7C%20extend%20delta%20%3D%20toreal(max_count_%20-%20min_count_)%20%2F%20max_count_%20*%20100%0A%7C%20where%20delta%20%26gt%3B%3D%20deltaThreshold%3B%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%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20660px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F228690iF06B8B6546722F93%2Fimage-dimensions%2F660x78%3Fv%3D1.0%22%20width%3D%22660%22%20height%3D%2278%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20delta%20calculation%20alone%20may%20still%20produce%20false%20positives%20but%20can%20be%20further%20improved%20upon.%20The%20next%20two%20checks%20will%20use%20country-based%20analytics%2C%20they%20are%20optional%20and%20will%20need%20customisation%20based%20on%20environment.%20With%20all%20queries%20a%20point%20is%20reached%20where%20additional%20checks%20may%20begin%20to%20increase%20the%20false%20negative%20rate%2C%20so%20customization%20on%20a%20per-environment%20basis%20is%20often%20needed.%20In%20this%20instance%20the%20objective%20is%20a%20low%20noise%20detection%20quality%20query.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFirst%2C%20the%20number%20of%20distinct%20countries%20each%20user%20has%20logged%20in%20from%20is%20calculated%2C%20a%20threshold%20called%20%E2%80%9CminimumCountries%E2%80%9D%20is%20set%20to%202%20by%20default%20meaning%20the%20user%20must%20have%20logged%20in%20from%20two%20distinct%20countries.%20Once%20users%20that%20have%20accessed%20their%20account%20for%20at%20least%202%20countries%20have%20been%20identified%20the%20prevalence%20of%20each%20country%20used%20to%20login%20is%20calculated%2C%20only%20countries%20that%20appear%20less%20than%2010%25%20in%20sign%20in%20logs%20are%20identified.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20query%20below%20expands%20the%20original%20delta%20query%20to%20include%20the%20country%20checks.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3E%2F%2FThe%20bigger%20the%20window%20the%20better%20the%20data%20sample%20size%2C%20as%20we%20use%20IP%20prevalence%2C%20more%20sample%20data%20is%20better%0Alet%20timeRange%20%3D%2030d%3B%0A%2F%2FThe%20minimum%20number%20of%20countries%20that%20the%20account%20has%20been%20accessed%20from%20%5Bdefault%3A%202%5D%0Alet%20minimumCountries%20%3D%202%3B%0A%2F%2FThe%20delta%20(%25)%20between%20the%20largest%20in-use%20IP%20and%20the%20smallest%20%5Bdefault%3A%2090%5D%0Alet%20deltaThreshold%20%3D%2095%3B%0A%2F%2FThe%20maximum%20(%25)%20threshold%20that%20the%20country%20appears%20in%20login%20data%20%5Bdefault%3A%2010%5D%0Alet%20countryPrevalenceThreshold%20%3D%2010%3B%0A%2F%2FThe%20time%20to%20project%20forward%20after%20the%20last%20login%20activity%20%5Bdefault%3A%2060min%5D%0Alet%20projectedEndTime%20%3D%2060min%3B%20%0A%2F%2FGet%20Teams%20successful%20signins%20globally%0Alet%20signinData%20%3D%0A%20%20SigninLogs%0A%20%20%7C%20where%20TimeGenerated%20%26gt%3B%3D%20ago(timeRange)%0A%20%20%7C%20where%20AppDisplayName%20has%20%22Teams%22%0A%20%20%7C%20where%20ConditionalAccessStatus%20%3D~%20%22success%22%0A%20%20%7C%20extend%20country%20%3D%20tostring(LocationDetails%5B'countryOrRegion'%5D)%0A%20%20%7C%20where%20isnotempty(country)%20and%20isnotempty(IPAddress)%3B%0A%2F%2F%20Collect%20successful%20signins%20to%20teams%0Alet%20loginEvents%20%3D%20%0A%20%20signinData%0A%20%20%7C%20summarize%20count()%2C%20country%3Dany(country)%2C%20make_list(TimeGenerated)%20by%20IPAddress%2C%20UserPrincipalName%3B%0A%2F%2FCalcualte%20delta%20between%20logins%0Alet%20loginDelta%20%3D%0A%20%20loginEvents%0A%20%20%7C%20summarize%20max(count_)%2C%20min(count_)%20by%20UserPrincipalName%0A%20%20%7C%20extend%20delta%20%3D%20toreal(max_count_%20-%20min_count_)%20%2F%20max_count_%20*%20100%0A%20%20%7C%20where%20delta%20%26gt%3B%3D%20deltaThreshold%3B%0A%2F%2FCount%20number%20of%20countries%20used%20to%20sign%20in%0Alet%20countryCount%20%3D%0A%20%20loginEvents%0A%20%20%7C%20summarize%20Countries%20%3D%20dcount(country)%20by%20UserPrincipalName%3B%0A%2F%2FJoin%20delta%20and%20sign%20in%20counts%20to%20successful%20logins%0AloginDelta%0A%7C%20join%20kind%3Drightouter%20%20(%0A%20%20loginEvents%0A)%20on%20UserPrincipalName%0A%2F%2FJoin%20the%20count%20of%20countries%20to%20the%20login%20records%0A%7C%20join%20kind%3Drightouter%20(%0A%20%20countryCount%0A)%20on%20UserPrincipalName%0A%2F%2FCheck%20where%20the%20record%20meets%20the%20minimum%20required%20countries%20as%20an%20early%20defeat%0A%7C%20where%20Countries%20%26gt%3B%3D%20minimumCountries%0A%2F%2FJoin%20the%20count%20of%20each%20country%0A%7C%20join%20kind%3Dleftouter%20(%0A%20%20%20%20%20%20signinData%0A%20%20%20%20%20%20%7C%20summarize%20count()%20by%20country%0A%20%20%20%20%20%20%2F%2FNow%20get%20the%20total%20number%20of%20logins%20from%20any%20country%20and%20join%20it%20to%20the%20previous%20count%20in%20a%20single%20table%0A%20%20%20%20%20%20%7C%20join%20(%0A%20%20%20%20%20%20%20%20%20%20signinData%0A%20%20%20%20%20%20%20%20%20%20%7C%20summarize%20count()%20by%20country%0A%20%20%20%20%20%20%20%20%20%20%7C%20summarize%20sum(count_)%2C%20make_list(country)%0A%20%20%20%20%20%20%20%20%20%20%7C%20mv-expand%20list_country%0A%20%20%20%20%20%20%20%20%20%20%7C%20extend%20country%20%3D%20tostring(list_country)%0A%20%20%20%20%20%20)%20on%20country%0A%20%20%20%20%20%20%7C%20summarize%20by%20country%2C%20count_%2C%20sum_count_%0A%20%20%20%20%20%20%2F%2FNow%20calculate%20each%20countries%20prevalence%20within%20login%20events%0A%20%20%20%20%20%20%7C%20extend%20prevalence%20%3D%20toreal(count_)%20%2F%20toreal(sum_count_)%20*%20100%0A%20%20%20%20%20%20%7C%20project-away%20sum_count_%0A%20%20%20%20%20%20%7C%20order%20by%20prevalence%0A)%20on%20country%0A%2F%2FThe%20%25%20that%20suspicious%20country%20is%20prevalent%20in%20data%2C%20this%20can%20be%20configured%2C%20less%20than%2010%25%20is%20uncommon%0A%7C%20where%20prevalence%20%26lt%3B%20countryPrevalenceThreshold%0A%7C%20where%20min_count_%20%3D~%20count_%0A%7C%20project%20UserPrincipalName%2C%20SuspiciousIP%20%3D%20IPAddress%2C%20UserIPDelta%20%3D%20delta%2C%20SuspiciousLoginCountry%20%3D%20country%2C%20SuspiciousCountryPrevalence%20%3D%20prevalence%2C%20EventTimes%20%3D%20list_TimeGenerated%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EExecuting%20the%20above%20query%20will%20provide%20a%20list%20of%20accounts%20where%20a%20suspicious%20login%20has%20occurred%2C%20it%20will%20also%20provide%20the%20times%20those%20suspicious%20logins%20occurred.%20At%20this%20point%20the%20above%20query%20can%20be%20used%20as%20a%20hunting%20query%20to%20identify%20suspicious%20activity%2C%20but%20it%20may%20produce%20false%20positives.%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-center%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20805px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F228691iA816DB784F313B79%2Fimage-dimensions%2F805x95%3Fv%3D1.0%22%20width%3D%22805%22%20height%3D%2295%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENow%20candidate%20suspicious%20logins%20have%20been%20identified%2C%20a%20join%20can%20be%20performed%20on%20the%20Teams%20log%20data%20using%20the%20users%20email%20address.%20A%20time%20window%20join%20allows%20the%20query%20to%20determine%20if%20a%20Teams%20admin%20action%20was%20performed%20within%20a%20specified%20window.%20In%20the%20default%20query%20this%20will%20detect%20admin%20actions%20up%20to%201%20hour%20after%20the%20successful%20login.%20The%20below%20query%20will%20perform%20the%20final%20join.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3E%2F%2FTeams%20join%20to%20collect%20operations%20the%20user%20account%20has%20performed%20within%20the%20given%20time%20range%0A%7C%20join%20kind%3Dinner(%20%0A%20%20OfficeActivity%0A%20%20%7C%20where%20OfficeWorkload%20%3D~%20%22MicrosoftTeams%22%0A%20%20%7C%20where%20TimeGenerated%20%26gt%3B%3D%20ago(timeRange)%0A%20%20%7C%20where%20Operation%20in~%20(%22TeamsAdminAction%22%2C%20%22MemberAdded%22%2C%20%22MemberRemoved%22%2C%20%22MemberRoleChanged%22%2C%20%22AppInstalled%22%2C%20%22BotAddedToTeam%22)%0A%20%20%7C%20project%20Operation%2C%20UserId%3Dtolower(UserId)%2C%20OperationTime%3DTimeGenerated%0A)%20on%20%24left.UserPrincipalName%20%3D~%20%24right.UserId%0A%7C%20mv-expand%20StartTime%20%3D%20EventTimes%0A%7C%20extend%20StartTime%20%3D%20make_datetime(StartTime)%0A%2F%2FThe%20end%20time%20is%20projected%2060%20minutes%20forward%2C%20in%20case%20actions%20took%20place%20within%20the%20last%20hour%20of%20the%20final%20login%20for%20the%20suspicious%20IP%0A%7C%20extend%20ProjectedEndTime%20%3D%20make_datetime(StartTime%20%2B%20projectedEndTime)%0A%2F%2FLimit%20to%20operations%20carried%20out%20by%20the%20user%20account%20in%20the%20timeframe%20the%20IP%20was%20active%0A%7C%20where%20OperationTime%20between%20(StartTime%20..%20ProjectedEndTime)%0A%7C%20project%20UserPrincipalName%2C%20SuspiciousIP%2C%20StartTime%2C%20ProjectedEndTime%2C%20OperationTime%2C%20Operation%2C%20SuspiciousLoginCountry%2C%20SuspiciousCountryPrevalence%0A%2F%2FFilter%20on%20suspicious%20actions%0A%7C%20extend%20activitySummary%20%3D%20pack(tostring(StartTime)%2C%20pack(%22Operation%22%2Ctostring(Operation)%2C%20%22OperationTime%22%2C%20OperationTime))%0A%7C%20summarize%20make_bag(activitySummary)%20by%20UserPrincipalName%2C%20SuspiciousIP%2C%20SuspiciousLoginCountry%2C%20SuspiciousCountryPrevalence%0A%7C%20extend%20IPCustomEntity%20%3D%20SuspiciousIP%2C%20AccountCustomEntity%20%3D%20UserPrincipalName%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWith%20the%20above%20queries%20combined%20the%20false%20positive%20rate%20will%20be%20reduced%20significantly%20allowing%20this%20query%20to%20be%20used%20as%20a%20detection.%20This%20detection%20is%20already%20published%20to%20the%20Azure%20Sentinel%20GitHub%20and%20can%20be%20found%20%3CA%20href%3D%22https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2FAzure-Sentinel%2Fmaster%2FDetections%2FMultipleDataSources%2FAnomalousIPUsageFollowedByTeamsAction.yaml%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehere%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhile%20this%20example%20uses%20Teams%20data%2C%20it%20is%20possible%20to%20apply%20the%20same%20logic%20to%20any%20sign%20in%20anomaly%20query%20where%20the%20application%20or%20service%20provides%20logging%20of%20administrative%20activity.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1952649710%22%20id%3D%22toc-hId-1952649710%22%3EIn%20Conclusion%3C%2FH2%3E%0A%3CP%3EThe%20blog%20has%20shown%20how%20to%20use%20additional%20data%20sources%20to%20enhance%20threat%20hunting%20in%20Azure%20Sentinel%20for%20threats%20within%20Microsoft%20Teams.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EExtracting%20additional%20information%20from%20OfficeActivity%20logs%20allowed%20identification%20of%20potentially%20suspicious%20files%20being%20shared%20on%20Teams.%20The%20blog%20also%20showed%20how%20call%20records%20can%20be%20extracted%20and%20used%20to%20further%20expand%20visibility%20of%20Teams%20activity.%20Knowledge%20of%20where%20file%20sharing%20and%20call%20records%20are%20stored%20provides%20a%20starting%20point%20to%20developing%20queries%20to%20answer%20specific%20questions%20about%20user%20account%20activity.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAs%20an%20example%20of%20how%20merging%20multiple%20data%20sources%20can%20lead%20to%20higher%20quality%20detections%20in%20Teams%2C%20the%20blog%20looked%20at%20how%20merging%20signing%20logs%20data%20with%20Teams%20activity%20enables%20the%20creation%20of%20a%20high-quality%2C%20low%20false%20positive%20detections.%20These%20principles%20can%20be%20applied%20in%20other%20scenarios%20where%20a%20high%20false-positive%20anomaly%20query%20can%20be%20combined%20with%20a%20suspicious%20behaviour.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you'd%20like%20to%20know%20more%20about%20the%20Teams%20schema%20in%20Azure%20Sentinel%20this%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-sentinel%2Funderstanding-microsoft-teams-data-schema-in-azure-sentinel%2Fba-p%2F1722876%22%20target%3D%22_self%22%3Eblog%26nbsp%3Bpost%3C%2FA%3E%26nbsp%3Bcontains%20information%20on%20the%20types%20of%20Teams%20operations%20you%20may%20see.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EIf%20you%20have%20questions%20or%20specific%20scenarios%20you%20would%20like%20to%20share%2C%20please%20leave%20a%20comment%20or%20reach%20out.%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1811827%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22teams_blog.png%22%20style%3D%22width%3A%20600px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F228699iDF59AA79FEFB9AF6%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22teams_blog.png%22%20alt%3D%22teams_blog.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3ELearn%20how%20to%20extract%20Teams%20file%20sharing%20and%20call%20records%20logs%20using%20Azure%20Sentinel.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1811827%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20Sentinel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EHunting%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EInvestigation%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESecurity%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

Tom McElroy, Pete Bryan - Microsoft Threat Intelligence Center

 

Pete Bryan posted a blog in March detailing how to protect Microsoft Teams with Azure Sentinel. Since then a new Teams connector has entered public preview, this allows Teams data to be accessed without the need for a custom log. Using the official connector means you will be able to take advantage of new Teams log events as they become available. More information on setting the connector up can he found hereTeams logs are provided by the Office 365 connector as part of Office Activity logging so will not incur additional costs to ingest if Office Activity logs are already being ingested.

 

This blog post will cover how Teams logs can be expanded to provide deeper security insight by mapping additional data from other tables available in Azure Sentinel, the topics covered are:

 

  • Extracting Teams file sharing information
  • Mapping Teams logs to Teams call records
  • Merging Teams logs with sign in activity to detect anomalous actions

 

Exploring Teams File Sharing

Teams allows users to share files in conversations, this feature is commonly used to share meeting notes, agendas or documents when collaborating on a piece of work.

 

When sharing a file on Teams it uses underlying Office technology to upload the file to the users OneDrive, it then shares the file using existing SharePoint operations. While file sharing information is not available in the local Teams Log, it can be extracted from the Office Activity log.

 

Teams file uploads are recorded in the Office activity log as SharePoint file operations. To distinguish Teams file uploads from other services the column “SourceRelativeURL” is populated with the entry “Microsoft Teams Chat Files”. The query below will extract Teams file uploads from the Office Activity log.

 

OfficeActivity 
| where RecordType =~ "SharePointFileOperation" 
| where UserId !~ "app@sharepoint"
| where SourceRelativeUrl has "Microsoft Teams Chat Files" 
| where Operation =~ "FileUploaded" 
| project TimeGenerated, UserId, ClientIP, Site_Url, OfficeObjectId, SourceFileName, SourceFileExtension

 

The query can now be expanded to find suspiciously named files. Either a list of potentially suspicious filenames can be provided, or an external data source can be used. In the below query, matching is being performed to detect users sharing passwords or files containing a confidential term. A list of terms can be passed in using a list, in the example below the list is called “suspiciousFilenames”.

 

let suspiciousFilenames = dynamic(['password', 'admin', 'confidential_term']);
OfficeActivity 
| where RecordType =~ "SharePointFileOperation" 
| where UserId !~ "app@sharepoint"
| where SourceRelativeUrl has "Microsoft Teams Chat Files" 
| where Operation =~ "FileUploaded" 
| project TimeGenerated, UserId, ClientIP, Site_Url, OfficeObjectId, SourceFileName, SourceFileExtension
| where SourceFileName has_any(suspiciousFilenames)

 

This query can be modified to search for suspicious file extensions instead, the query below will show common Windows executable files being shared through Teams.

 

let suspiciousExtensions = dynamic(['exe', 'msi', 'bin', 'dll']);
OfficeActivity 
| where RecordType =~ "SharePointFileOperation" 
| where UserId !~ "app@sharepoint"
| where SourceRelativeUrl has "Microsoft Teams Chat Files" 
| where Operation =~ "FileUploaded" 
| project TimeGenerated, UserId, ClientIP, Site_Url, OfficeObjectId, SourceFileName, SourceFileExtension
| where SourceFileExtension has_any(suspiciousExtensions)

 

Joining either of the above queries back to the Office activity log allows the query to extract how many users received the file and how many users opened the file, with counts for each. In the below example the suspicious file name query has been expanded to collect the additional user information.

 

let suspiciousFilenames = dynamic(['password', 'admin', 'confidential_term']);
OfficeActivity
//Get teams files where the file is being uploaded, teams uses SharePoint and OneDrive for file sharing
| where RecordType =~ "SharePointFileOperation"
| where SourceRelativeUrl contains "Microsoft Teams Chat Files"
| where Operation =~ "FileUploaded"
//Check for a suspicious file name, comment out to see all files
| where SourceFileName has suspiciousFilenames
| summarize by TimeGenerated, OfficeObjectId, UserId, ClientIP, SourceFileName
//Count how many users it was shared to, we can't get who it was shared to here
| join kind=leftouter (
OfficeActivity
//When sending a file in teams a new sharepoint sharing operation event is generated, teams shares the file with all the users in a chat
| where RecordType =~ "SharePointSharingOperation"
| where Operation =~ "SharingSet"
| where SourceRelativeUrl has "Microsoft Teams Chat Files"
| where UserId !~ "app@sharepoint"
//OfficeId is a unique GUID for office operations, counting this provides the number of share events teams generated
| summarize dcount(OfficeId), SentTo=make_list(UserId) by OfficeObjectId 
) on OfficeObjectId
| project-away OfficeObjectId1
//Join data that shows who accessed the file
| join kind=leftouter (
OfficeActivity
//Again, teams generated sharepoint events for users downloading or accessing the file
| where RecordType =~ "SharePointFileOperation"
| where Operation =~ "FileDownloaded" or Operation == "FileAccessed"
| where UserId !~ "app@sharepoint"
| extend userBag = pack(tostring(TimeGenerated), UserId)
| summarize make_bag(userBag), dcount(UserId) by OfficeObjectId 
) on OfficeObjectId 
| project TimeGenerated, SourceFileName, Uploader=UserId, UploaderIP=ClientIP, UsersSentCount=dcount_OfficeId, UsersOpenedCount=dcount_UserId, AccessedBy=bag_userBag, SentTo, OfficeObjectId

 

While the above examples use a fixed list of suspicious filenames for matching, the Kusto external data operator can be used to import a list of known-bad filenames.

 

Matching malicious filenames is often unreliable as attackers will name files to blend in with their target environment, however, this query could be used situationally in a response scenario to search of malicious documents that may have been passed between users. While uncommon, attacker spear phishing lures can prove so interesting that users share the lure beyond the initial recipient.

 

Mapping Teams log to Teams Call Records

As well as providing key administrative and user activity logs via the new Teams connector we can also access specific call record logs. These logs provide details about calls and meetings made via Teams, and provide details about who organized them, who participated, and what technologies were used. These logs need to be collected separately from the main Teams logs collected by the connector, for more details about how to enable collection of these events, please refer to this blog.

 

Once we have the call logs available to us, we can use our existing Teams queries to pivot from a user and identify what calls they have been present in. Below is an example of taking one of the suspicious file upload queries above and pivoting to see the call attendance of the user who originally shared the file. This is a good way to identify the scope of an incident and other impacted users.

 

let suspiciousFilenames = dynamic(['password', 'admin', 'confidential_term']);
OfficeActivity
//Get teams files where the file is being uploaded, teams uses SharePoint and OneDrive for file sharing
| where RecordType =~ "SharePointFileOperation"
| where SourceRelativeUrl contains "Microsoft Teams Chat Files"
| where Operation =~ "FileUploaded"
//Check for a suspicious file name, comment out to see all files
| where SourceFileName contains suspiciousFilenames
| summarize by TimeGenerated, OfficeObjectId, UserId, ClientIP, SourceFileName
//Count how many users it was shared to, we can't get who it was shared to here
| join kind=leftouter (
OfficeActivity
//When sending a file in teams a new sharepoint sharing operation event is generated, teams shares the file with all the users in a chat
| where RecordType =~ "SharePointSharingOperation"
| where Operation =~ "SharingSet"
| where SourceRelativeUrl contains "Microsoft Teams Chat Files"
| where UserId !~ "app@sharepoint"
//OfficeId is a unique GUID for office operations, counting this provides the number of share events teams generated
| summarize dcount(OfficeId), SentTo=make_list(UserId) by OfficeObjectId 
) on OfficeObjectId
| project-away OfficeObjectId1
//Join data that shows who accessed the file
| join kind=leftouter (
OfficeActivity
//Again, teams generated sharepoint events for users downloading or accessing the file
| where RecordType =~ "SharePointFileOperation"
| where Operation =~ "FileDownloaded" or Operation == "FileAccessed"
| where UserId !~ "app@sharepoint"
| extend userBag = pack(tostring(TimeGenerated), UserId)
| summarize make_bag(userBag), dcount(UserId) by OfficeObjectId 
) on OfficeObjectId 
| project TimeGenerated, SourceFileName, Uploader=UserId, UploaderIP=ClientIP, UsersSentCount=dcount_OfficeId, UsersOpenedCount=dcount_UserId, AccessedBy=bag_userBag, SentTo, OfficeObjectId
// We need to join these logs to AAD SigninEvents to get the AADUserID we need to the Teams call logs
| join (SigninLogs
| project UserPrincipalName, AADUserId = UserId)
on $left.Uploader =~ $right.UserPrincipalName
//We can now join this to our Teams call logs to get details of all the calls that the user who uploaded the file has participated in
| join (TeamsCallLogs_CL
| mv-expand todynamic(participants_s)
| extend AADUserId = tostring(participants_s.user.id))
on AADUserId
// To make the ouput a bit cleaner we can pack our meeting events into a single object.
| extend Meetings = pack("MeetingId", id_g, "Type", type_s, "Participants", participants_s, "StartTime", startDateTime_t, "EndTime", endDateTime_t, "Organizer", organizer_user_displayName_s)
| summarize make_list(Meetings) by SourceFileName, UsersOpenedCount, Uploader
| extend meeting_count=array_length(list_Meetings)

 

Note: In the query above we are presuming that the custom table name used to ingest the Teams call logs is “TeamsCallLogs_CL”. If your configuration is different you will need to edit the query above to reflect that.

 

Finding Anomalous Teams Logins

Common techniques to identify anomalous sign in activity include analysing the login locations for suspicious countries, searching for IP subnets that are not used commonly, and looking for multiple failed accesses followed by a successful login to detect brute force activity. These techniques are effective at identifying potentially suspicious activity but can generate high false positive rates. With more users working from home, some of these techniques have become impractical given the network diversity when users connect from home offices.

 

With additional information from other log sources it is possible to improve confidence in the detections. Anomalous login techniques can be corelated with log data from applications to determine if an administrative action was performed during a time window after a successful anomalous login has occurred. The new Teams connector provides logging of Teams events, including administrative events, which can be used to detect potentially suspicious Teams activity taking place.

 

Certain actions in Teams will result in a log entry, this ranges from a Teams session starting to administrative actions e.g. deleting a team. This information is logged to the “Operation” column of the Teams log. As seen in the image below the most common event “TeamsSessionStarted” is shown.

 

image.png

 

There are a number of operations within the Teams log that can be considered administrative, and a subset of those have potential application in a threat actors campaign, in this example the following actions will be used as indicators of of potentially suspicious activity:

 

OfficeActivity
| where OfficeWorkload =~ "MicrosoftTeams"
| where Operation in~ ("TeamsAdminAction", "MemberAdded", "MemberRemoved", "MemberRoleChanged", "AppInstalled", "BotAddedToTeam")

 

A TeamsAdminAction operation is logged when a team administrative action is performed, this covers a wide range of administrative actions that can be performed by an account with an administrator role, a full list of action can be found here. Many of these actions would be useful to an attacker, allowing management of meetings, call policies, viewing user profiles and accessing monitoring and reporting from Teams.

 

MemberAdded and MemberRemoved operations can be performed by any Teams user that is an administrator of a Team. These events are generated when a member is added to or removed from a Team. After compromising a legitimate account, a malicious actor may attempt to add their own account to meetings that they wish to eavesdrop on, the actor may remove that same member after data has been collected from the Team. Generally, these events are quite common, but when following an anomalous login, they should be treated as suspicious.

 

The AppInstalled and BotAddedToTeam log events are generated when an app or bot is installed into Teams. An attacker could use this to install malicious Teams addons or bots using the custom app upload feature. Apps and bots are installed on a per-user basis, but can be added to a Team by a user.


Now that potentially suspicious operations within Teams are identified, a query can be constructed that enriches the sign in log data with Teams data to find anomalous logins that were followed by an administrative action.

 

The query below first collects successful logins to Teams from sign in logs, it then calculates the delta for each user of the IP addresses used to login. Calculating the delta between the least used IP and the most used IP for each user will find accounts where an IP has been used to login only a handful of times vs. the user’s normal login activity. As no fixed values are used this also means that the detection will scale based on the user’s activity level. It will also adapt to activity where the user is roaming on a home connection. Even on internet service providers with dynamic IP addresses, the lease time will be long enough to evenly spread IP usage.

 

The example below shows a standalone calculation of the delta between IP’s used to login to accounts in sign in logs, followed by the output from Azure Sentinel.

 

let timeRange = 30d;
//The delta (%) between the largest in-use IP and the smallest [default: 90]
let deltaThreshold = 95;
//Get Teams successful signins globally
SigninLogs
| where TimeGenerated >= ago(timeRange)
| where AppDisplayName has "Teams"
| where ConditionalAccessStatus =~ "success"
| extend country = tostring(LocationDetails['countryOrRegion'])
| where isnotempty(country) and isnotempty(IPAddress)
//Count logins for each IP address used by each user, take one example of geolocation
| summarize count(), country=any(country), make_list(TimeGenerated) by IPAddress, UserPrincipalName
//Pack IP and count then summarize all IP events for each user
| extend p = pack(IPAddress, count_)
| summarize max(count_), min(count_), make_bag(p) by UserPrincipalName
//Calculate delta and convert to percentage
| extend delta = toreal(max_count_ - min_count_) / max_count_ * 100
| where delta >= deltaThreshold;

 

 

image.png

 

The delta calculation alone may still produce false positives but can be further improved upon. The next two checks will use country-based analytics, they are optional and will need customisation based on environment. With all queries a point is reached where additional checks may begin to increase the false negative rate, so customization on a per-environment basis is often needed. In this instance the objective is a low noise detection quality query.

 

First, the number of distinct countries each user has logged in from is calculated, a threshold called “minimumCountries” is set to 2 by default meaning the user must have logged in from two distinct countries. Once users that have accessed their account for at least 2 countries have been identified the prevalence of each country used to login is calculated, only countries that appear less than 10% in sign in logs are identified.

 

The query below expands the original delta query to include the country checks.

 

//The bigger the window the better the data sample size, as we use IP prevalence, more sample data is better
let timeRange = 30d;
//The minimum number of countries that the account has been accessed from [default: 2]
let minimumCountries = 2;
//The delta (%) between the largest in-use IP and the smallest [default: 90]
let deltaThreshold = 95;
//The maximum (%) threshold that the country appears in login data [default: 10]
let countryPrevalenceThreshold = 10;
//The time to project forward after the last login activity [default: 60min]
let projectedEndTime = 60min; 
//Get Teams successful signins globally
let signinData =
  SigninLogs
  | where TimeGenerated >= ago(timeRange)
  | where AppDisplayName has "Teams"
  | where ConditionalAccessStatus =~ "success"
  | extend country = tostring(LocationDetails['countryOrRegion'])
  | where isnotempty(country) and isnotempty(IPAddress);
// Collect successful signins to teams
let loginEvents = 
  signinData
  | summarize count(), country=any(country), make_list(TimeGenerated) by IPAddress, UserPrincipalName;
//Calcualte delta between logins
let loginDelta =
  loginEvents
  | summarize max(count_), min(count_) by UserPrincipalName
  | extend delta = toreal(max_count_ - min_count_) / max_count_ * 100
  | where delta >= deltaThreshold;
//Count number of countries used to sign in
let countryCount =
  loginEvents
  | summarize Countries = dcount(country) by UserPrincipalName;
//Join delta and sign in counts to successful logins
loginDelta
| join kind=rightouter  (
  loginEvents
) on UserPrincipalName
//Join the count of countries to the login records
| join kind=rightouter (
  countryCount
) on UserPrincipalName
//Check where the record meets the minimum required countries as an early defeat
| where Countries >= minimumCountries
//Join the count of each country
| join kind=leftouter (
      signinData
      | summarize count() by country
      //Now get the total number of logins from any country and join it to the previous count in a single table
      | join (
          signinData
          | summarize count() by country
          | summarize sum(count_), make_list(country)
          | mv-expand list_country
          | extend country = tostring(list_country)
      ) on country
      | summarize by country, count_, sum_count_
      //Now calculate each countries prevalence within login events
      | extend prevalence = toreal(count_) / toreal(sum_count_) * 100
      | project-away sum_count_
      | order by prevalence
) on country
//The % that suspicious country is prevalent in data, this can be configured, less than 10% is uncommon
| where prevalence < countryPrevalenceThreshold
| where min_count_ =~ count_
| project UserPrincipalName, SuspiciousIP = IPAddress, UserIPDelta = delta, SuspiciousLoginCountry = country, SuspiciousCountryPrevalence = prevalence, EventTimes = list_TimeGenerated

 

Executing the above query will provide a list of accounts where a suspicious login has occurred, it will also provide the times those suspicious logins occurred. At this point the above query can be used as a hunting query to identify suspicious activity, but it may produce false positives.

 

image.png

 

Now candidate suspicious logins have been identified, a join can be performed on the Teams log data using the users email address. A time window join allows the query to determine if a Teams admin action was performed within a specified window. In the default query this will detect admin actions up to 1 hour after the successful login. The below query will perform the final join.

 

//Teams join to collect operations the user account has performed within the given time range
| join kind=inner( 
  OfficeActivity
  | where OfficeWorkload =~ "MicrosoftTeams"
  | where TimeGenerated >= ago(timeRange)
  | where Operation in~ ("TeamsAdminAction", "MemberAdded", "MemberRemoved", "MemberRoleChanged", "AppInstalled", "BotAddedToTeam")
  | project Operation, UserId=tolower(UserId), OperationTime=TimeGenerated
) on $left.UserPrincipalName =~ $right.UserId
| mv-expand StartTime = EventTimes
| extend StartTime = make_datetime(StartTime)
//The end time is projected 60 minutes forward, in case actions took place within the last hour of the final login for the suspicious IP
| extend ProjectedEndTime = make_datetime(StartTime + projectedEndTime)
//Limit to operations carried out by the user account in the timeframe the IP was active
| where OperationTime between (StartTime .. ProjectedEndTime)
| project UserPrincipalName, SuspiciousIP, StartTime, ProjectedEndTime, OperationTime, Operation, SuspiciousLoginCountry, SuspiciousCountryPrevalence
//Filter on suspicious actions
| extend activitySummary = pack(tostring(StartTime), pack("Operation",tostring(Operation), "OperationTime", OperationTime))
| summarize make_bag(activitySummary) by UserPrincipalName, SuspiciousIP, SuspiciousLoginCountry, SuspiciousCountryPrevalence
| extend IPCustomEntity = SuspiciousIP, AccountCustomEntity = UserPrincipalName

 

With the above queries combined the false positive rate will be reduced significantly allowing this query to be used as a detection. This detection is already published to the Azure Sentinel GitHub and can be found here.

 

While this example uses Teams data, it is possible to apply the same logic to any sign in anomaly query where the application or service provides logging of administrative activity.

 

In Conclusion

The blog has shown how to use additional data sources to enhance threat hunting in Azure Sentinel for threats within Microsoft Teams.

 

Extracting additional information from OfficeActivity logs allowed identification of potentially suspicious files being shared on Teams. The blog also showed how call records can be extracted and used to further expand visibility of Teams activity. Knowledge of where file sharing and call records are stored provides a starting point to developing queries to answer specific questions about user account activity.

 

As an example of how merging multiple data sources can lead to higher quality detections in Teams, the blog looked at how merging signing logs data with Teams activity enables the creation of a high-quality, low false positive detections. These principles can be applied in other scenarios where a high false-positive anomaly query can be combined with a suspicious behaviour.

 

If you'd like to know more about the Teams schema in Azure Sentinel this blog post contains information on the types of Teams operations you may see.

 

If you have questions or specific scenarios you would like to share, please leave a comment or reach out.