Detection rules › Kusto

SlackAudit - User login after deactivated.

Status
available
Severity
medium
Time window
14d
Group by
EntityUserEmail, EntityUserId
Source
github.com/Azure/Azure-Sentinel

'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

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
Threshold
lt new_login_time

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.

FieldKindValues
Actioneq
  • user_deactivated
  • user_login
EntityUserEmaileq
  • SrcUserEmail transforms: cased
deactivation_timelt
  • new_login_time transforms: cased

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.

FieldSource
EntityUserEmailproject
EntityUserIdproject
deactivation_timeproject
AccountCustomEntityextend