Query Details
// Rule : M365 - Teams Application or Bot Added to Channel (Suspicious App)
// Severity: Medium
// Tactics : Persistence, Execution
// MITRE : T1546 (Event Triggered Execution), T1059 (Command and Scripting Interpreter)
// Freq : PT1H Period: PT1H
// Description: Detects installation of bots or third-party applications into Teams
// channels, particularly those associated with known post-exploitation
// tooling names or unexpected app publishers.
//==========================================================================================
let SuspiciousAppPatterns = dynamic([
"ngrok", "webhook", "tunnel", "shell", "exec", "bot", "forward",
"proxy", "exfil", "revealer", "bypass"
]);
let LookbackPeriod = 1h;
OfficeActivity
| where TimeGenerated > ago(LookbackPeriod)
| where RecordType == "MicrosoftTeams"
| where Operation in ("AppInstalled", "BotAddedToTeam", "TabAdded", "ConnectorAdded")
| extend
AppNameRaw = tostring(parse_json(ExtraProperties)[0].Value),
AppLower = tolower(tostring(parse_json(ExtraProperties)[0].Value))
| extend IsSuspicious = AppLower has_any (SuspiciousAppPatterns)
| summarize
InstallCount = count(),
AppsInstalled = make_set(AppNameRaw, 10),
TeamsAffected = make_set(TeamName, 10),
Channels = make_set(ChannelName, 10),
IsSuspicious = any(IsSuspicious),
FirstSeen = min(TimeGenerated),
LastSeen = max(TimeGenerated)
by UserId, ClientIP
| extend AlertSeverity = case(
IsSuspicious == true, "High",
InstallCount > 5, "Medium",
"Low")
| project
TimeGenerated = LastSeen,
UserId,
AppsInstalled,
TeamsAffected,
Channels,
InstallCount,
IsSuspicious,
ClientIP,
AlertSeverity
This query is designed to detect potentially suspicious activities related to the installation of applications or bots in Microsoft Teams channels. Here's a simplified breakdown of what it does:
Purpose: The query aims to identify when bots or third-party applications are added to Teams channels, especially those that might be associated with malicious activities or unexpected publishers.
Suspicious Patterns: It looks for specific keywords in app names that are often linked to suspicious activities, such as "ngrok", "webhook", "tunnel", and others.
Time Frame: The query examines activities within the last hour.
Data Source: It filters data from the OfficeActivity table, focusing on records related to Microsoft Teams operations like app installations or bot additions.
Processing:
Alerting:
Output: The query produces a summary that includes:
This helps in monitoring and responding to potential security threats related to unauthorized or suspicious app installations in Teams.

David Alonso
Released: March 18, 2026
Tables
Keywords
Operators