Detection rules › Kusto
SlackAudit - User login after deactivated.
'Detects when a Slack user account was deactivated and the same user identity later authenticated again within the detection window, which may indicate account reactivation, unauthorized access, or use of a deactivated account. Analyst triage should review the deactivation time, subsequent login time, EntityUserEmail, and EntityUserId to determine whether the login was expected. This rule uses the SlackAuditAPI connector and SlackAudit_CL data type.'
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Initial Access | T1078.004 Valid Accounts: Cloud Accounts |
| Persistence | T1078.004 Valid Accounts: Cloud Accounts |
| Privilege Escalation | T1078.004 Valid Accounts: Cloud Accounts |
Rule body kusto
id: e6e99dcb-4dff-48d2-8012-206ca166b36b
name: SlackAudit - User login after deactivated.
description: |
'Detects when a Slack user account was deactivated and the same user identity later authenticated again within
the detection window, which may indicate account reactivation, unauthorized access, or use of a deactivated account. Analyst
triage should review the deactivation time, subsequent login time, EntityUserEmail, and EntityUserId to determine whether
the login was expected. This rule uses the SlackAuditAPI connector and SlackAudit_CL data type.'
severity: Medium
status: Available
requiredDataConnectors:
- connectorId: SlackAuditAPI
dataTypes:
- SlackAudit_CL
queryFrequency: 1h
queryPeriod: 14d
triggerOperator: gt
triggerThreshold: 0
tactics:
- InitialAccess
- Persistence
- PrivilegeEscalation
relevantTechniques:
- T1078
- T1078.004
query: |
let lbperiod_max_d = 14d;
let lbperiod_min_d = 1d;
let lb_time_max_h = 24h;
SlackAudit
| where TimeGenerated between (ago(lbperiod_max_d) .. (lbperiod_min_d))
| where Action =~ 'user_deactivated'
| summarize deactivation_time = max(TimeGenerated) by EntityUserEmail, EntityUserId
| project deactivation_time, EntityUserEmail, EntityUserId
| join (SlackAudit
| where TimeGenerated > ago(lb_time_max_h)
| where Action =~ 'user_login'
| summarize new_login_time = max(TimeGenerated) by SrcUserEmail, SrcUserIdentity
| project new_login_time, SrcUserEmail, EntityUserId = SrcUserIdentity) on EntityUserId
| where EntityUserEmail == SrcUserEmail
| where deactivation_time < new_login_time
| extend AccountCustomEntity = SrcUserEmail
entityMappings:
- entityType: Account
fieldMappings:
- identifier: FullName
columnName: AccountCustomEntity
alertDetailsOverride:
alertDisplayNameFormat: 'Slack user login after deactivation: {{AccountCustomEntity}}'
alertDescriptionFormat: User {{AccountCustomEntity}} logged in after deactivation; review deactivation_time {{deactivation_time}}
and new_login_time {{new_login_time}}.
customDetails:
DeactivationTime: deactivation_time
NewLoginTime: new_login_time
SlackUserEmail: EntityUserEmail
SlackUserId: EntityUserId
version: 1.0.1
kind: Scheduled
Stages and Predicates
Parameters
let lbperiod_max_d = 14d;
let lbperiod_min_d = 1d;
let lb_time_max_h = 24h;
Stage 1: source
SlackAudit
Stage 2: where
| where TimeGenerated between (ago(lbperiod_max_d) .. (lbperiod_min_d))
Stage 3: where
| where Action =~ 'user_deactivated'
Stage 4: summarize
| summarize deactivation_time = max(TimeGenerated) by EntityUserEmail, EntityUserId
Stage 5: project
| project deactivation_time, EntityUserEmail, EntityUserId
Stage 6: join
| join (SlackAudit
| where TimeGenerated > ago(lb_time_max_h)
| where Action =~ 'user_login'
| summarize new_login_time = max(TimeGenerated) by SrcUserEmail, SrcUserIdentity
| project new_login_time, SrcUserEmail, EntityUserId = SrcUserIdentity) on EntityUserId
Stage 7: where
| where EntityUserEmail == SrcUserEmail
Stage 8: where
| where deactivation_time < new_login_time
Stage 9: extend
| extend AccountCustomEntity = SrcUserEmail
Indicators
Each row is a field, operator, and value that the rule matches. The corpus column counts how many other rules in the catalog look for the same combination: high numbers point to widely-used, community-vetted indicators. Blank or 1 shows that the indicator is specific to this rule.
| Field | Kind | Values |
|---|---|---|
Action | eq |
|
EntityUserEmail | eq |
|
deactivation_time | lt |
|
Output fields
Fields the rule emits when it matches. Chronicle authors list these in the outcome block; they appear on the detection and $risk_score drives alerting. Sentinel / Defender XDR rules build them up through project / summarize / extend stages. Sentinel maps these into alert fields via entityMappings and customDetails; Defender XDR custom detections surface them as alert fields directly.
| Field | Source |
|---|---|
EntityUserEmail | project |
EntityUserId | project |
deactivation_time | project |
AccountCustomEntity | extend |