Slack Anomaly Detected


Description

Passthrough for anomalies detected by Slack

Query · python

from panther_slack_helpers import slack_alert_context

ELEVATED_ANOMALIES = {"excessive_malware_uploads", "session_fingerprint", "unexpected_admin_action"}


def rule(event):
    return event.get("action") == "anomaly"


def severity(event):
    # Return "MEDIUM" for some more serious anomalies
    reasons = event.deep_get("details", "reason", default=[])
    if set(reasons) & ELEVATED_ANOMALIES:
        return "MEDIUM"
    return "DEFAULT"


def title(event):
    anomalies = {
        "asn": "An ASN was on a list of suspicious ASNs",
        "excessive_downloads": "A user downloaded an excessive amount of files",
        "excessive_file_shares": "A user shared an excessive amount of files",
        "excessive_malware_uploads": "A user uploaded an excessive amount of malware files",
        "ip_address": "An anomaly was detected in the IP address used for the user token",
        "search_volume": "An unusual volume of search activity was detected",
        "session_fingerprint": "The session cookie has an unusual timestamp or client fingerprint",
        "spoofed_user_agent": "Characteristics of the client do not match the user agent",
        "tor": "A Tor exit node was used",
        "unexpected_admin_action": "An unexpected admin action was performed",
        "unexpected_api_call_volume": "An unexpected volume of API calls was detected",
        "unexpected_client": "An anomalous Slack client was detected",
        "unexpected_credential_testing": "Unexpected credential testing activity was detected",
        "unexpected_message_deletion": "Unexpected message deletion activity was detected",
        "unexpected_scraping": "Unexpected scraping activity was detected",
        "unexpected_user_agent": "An unexpected user agent was detected",
        "user_agent": "An anomaly was detected in the user agent used for the user token",
    }

    reasons = event.deep_get("details", "reason", default=[])
    reasons_str = reasons[0] if reasons else ""
    anomaly_description = anomalies.get(reasons_str)

    actor = event.deep_get("actor", "user", "email", default="")
    actor_str = f" for {actor}" if actor else ""

    if anomaly_description:
        return f"Slack Anomaly Detected{actor_str}: {anomaly_description}"
    # if the anomaly is not in our list (for future use)
    return f"Slack Anomaly Detected{actor_str}"


def alert_context(event):
    context = slack_alert_context(event)
    context |= {"details": event.get("details", {}), "context": event.get("context", {})}
    return context
Raw source Slack Anomaly Detected · Panther Python
Esc
Published by panther-labs/panther-analysis ↗, licensed under Apache 2.0 ↗. Reproduced here unmodified.
AnalysisType: rule
Filename: slack_passthrough_anomaly.py
RuleID: "Slack.AuditLogs.PassthroughAnomaly"
DisplayName: "Slack Anomaly Detected"
Enabled: true
LogTypes:
  - Slack.AuditLogs
Severity: Low
Reports:
  MITRE ATT&CK:
    - TA0011:T1071
Description: Passthrough for anomalies detected by Slack
DedupPeriodMinutes: 60
Threshold: 1
Reference: 
  https://api.slack.com/admins/audit-logs-anomaly
SummaryAttributes:
  - p_any_ip_addresses
  - p_any_emails
Tags:
  - Slack
  - Command and Control
  - Application Layer Protocol
Tests:
  - Name: Name
    ExpectedResult: true
    Log:
      {
        "action": "anomaly",
        "actor": {
          "type": "user",
          "user": {
            "email": "user@example.com",
            "id": "W012J3FEWAU",
            "name": "primary-owner",
            "team": "T01234N56GB"
          }
        },
        "context": {
          "ip_address": "1.2.3.4",
          "location": {
            "domain": "test-workspace-1",
            "id": "T01234N56GB",
            "name": "test-workspace-1",
            "type": "workspace"
          },
          "ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36"
        }
      }
  - Name: User Logout
    ExpectedResult: false
    Log:
      {
        "action": "user_logout",
        "actor": {
          "type": "user",
          "user": {
            "email": "user@example.com",
            "id": "W012J3FEWAU",
            "name": "primary-owner",
            "team": "T01234N56GB"
          }
        },
        "context": {
          "ip_address": "1.2.3.4",
          "location": {
            "domain": "test-workspace-1",
            "id": "T01234N56GB",
            "name": "test-workspace-1",
            "type": "workspace"
          },
          "ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36"
        },
        "date_create": "2022-07-28 15:22:32",
        "entity": {
          "type": "user",
          "user": {
            "email": "user@example.com",
            "id": "W012J3FEWAU",
            "name": "primary-owner",
            "team": "T01234N56GB"
          }
        },
        "id": "72cac009-9eb3-4dde-bac6-ee49a32a1789"
      }
  - Name: Session Fingerprint
    ExpectedResult: true
    Log:
      {
        "action": "anomaly",
        "actor": {
          "type": "user",
          "user": {
            "email": "user@example.com",
            "id": "W012J3FEWAU",
            "name": "primary-owner",
            "team": "T01234N56GB"
          }
        },
        "context": {
          "ip_address": "1.2.3.4",
          "location": {
            "domain": "test-workspace-1",
            "id": "T01234N56GB",
            "name": "test-workspace-1",
            "type": "workspace"
          },
          "ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36"
        },
        "date_create": "2024-08-19 13:54:53.000000000",
        "details": {
          "action_timestamp": 1724075641026703,
          "location": "London, UK",
          "previous_ip_address": "",
          "previous_ua": "",
          "reason": [
            "session_fingerprint"
          ]
        },
        "entity": {
          "type": "user",
          "user": {
            "email": "user@example.com",
            "id": "W012J3FEWAU",
            "name": "primary-owner",
            "team": "T01234N56GB"
          }
        },
        "id": "95edcb27-132a-4420-9229-783b38a16b5a",
        "p_event_time": "2024-08-19 13:54:53.000000000",
        "p_log_type": "Slack.AuditLogs"
      }


# ------ paired body: slack_passthrough_anomaly.py ------

from panther_slack_helpers import slack_alert_context

ELEVATED_ANOMALIES = {"excessive_malware_uploads", "session_fingerprint", "unexpected_admin_action"}


def rule(event):
    return event.get("action") == "anomaly"


def severity(event):
    # Return "MEDIUM" for some more serious anomalies
    reasons = event.deep_get("details", "reason", default=[])
    if set(reasons) & ELEVATED_ANOMALIES:
        return "MEDIUM"
    return "DEFAULT"


def title(event):
    anomalies = {
        "asn": "An ASN was on a list of suspicious ASNs",
        "excessive_downloads": "A user downloaded an excessive amount of files",
        "excessive_file_shares": "A user shared an excessive amount of files",
        "excessive_malware_uploads": "A user uploaded an excessive amount of malware files",
        "ip_address": "An anomaly was detected in the IP address used for the user token",
        "search_volume": "An unusual volume of search activity was detected",
        "session_fingerprint": "The session cookie has an unusual timestamp or client fingerprint",
        "spoofed_user_agent": "Characteristics of the client do not match the user agent",
        "tor": "A Tor exit node was used",
        "unexpected_admin_action": "An unexpected admin action was performed",
        "unexpected_api_call_volume": "An unexpected volume of API calls was detected",
        "unexpected_client": "An anomalous Slack client was detected",
        "unexpected_credential_testing": "Unexpected credential testing activity was detected",
        "unexpected_message_deletion": "Unexpected message deletion activity was detected",
        "unexpected_scraping": "Unexpected scraping activity was detected",
        "unexpected_user_agent": "An unexpected user agent was detected",
        "user_agent": "An anomaly was detected in the user agent used for the user token",
    }

    reasons = event.deep_get("details", "reason", default=[])
    reasons_str = reasons[0] if reasons else ""
    anomaly_description = anomalies.get(reasons_str)

    actor = event.deep_get("actor", "user", "email", default="")
    actor_str = f" for {actor}" if actor else ""

    if anomaly_description:
        return f"Slack Anomaly Detected{actor_str}: {anomaly_description}"
    # if the anomaly is not in our list (for future use)
    return f"Slack Anomaly Detected{actor_str}"


def alert_context(event):
    context = slack_alert_context(event)
    context |= {"details": event.get("details", {}), "context": event.get("context", {})}
    return context

Detection rules belong to the projects that publish them and remain under their own licenses. This site indexes and links to them; it claims no rights in them.