Query Details

Rule : Multiple Unique Webhook Endpoints Contacted by One Device

Exfiltration Rotating Webhook Destinations

Query

let lookback=24h;
let webhook_id_regex=@"(?i)webhook\.site/(?:token/)?([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})";
let from_process=DeviceProcessEvents
| where Timestamp > ago(lookback)
| where ProcessCommandLine has "webhook.site"
| project Timestamp, DeviceId, DeviceName, AccountName, Process=FileName, Evidence=ProcessCommandLine;
let from_network=DeviceNetworkEvents
| where Timestamp > ago(lookback)
| where RemoteUrl has "webhook.site"
| project Timestamp, DeviceId, DeviceName, AccountName=InitiatingProcessAccountName, Process=InitiatingProcessFileName, Evidence=strcat(RemoteUrl," | ",InitiatingProcessCommandLine);
union from_process, from_network
| extend WebhookIds=extract_all(webhook_id_regex, Evidence)
| extend WebhookIds=iff(array_length(WebhookIds) == 0, dynamic([""]), WebhookIds)
| mv-expand WebhookId=WebhookIds to typeof(string)
| summarize Events=count(), DistinctWebhookIds=dcountif(WebhookId, isnotempty(WebhookId)), WebhookIdExamples=make_set_if(WebhookId, isnotempty(WebhookId), 12), Processes=make_set(Process,8), Examples=make_set(substring(Evidence,0,200),6), FirstSeen=min(Timestamp), LastSeen=max(Timestamp) by DeviceId, DeviceName, AccountName, bin(Timestamp,15m)
| where DistinctWebhookIds >= 3 or Events >= 10
| order by DistinctWebhookIds desc, Events desc

About this query

Explanation

This query is designed to detect unusual activity on a device by identifying when it contacts multiple unique webhook endpoints within a short period, which could indicate suspicious behavior. Here's a simplified breakdown:

  1. Purpose: The query aims to find devices that are accessing several distinct webhook URLs (specifically from webhook.site) within a 15-minute window. This behavior is considered unusual and potentially malicious, as it was observed in certain threat actor operations.

  2. Data Sources: It analyzes data from two tables:

    • DeviceProcessEvents: Logs processes running on devices.
    • DeviceNetworkEvents: Logs network activities, including URLs accessed by devices.
  3. Detection Criteria:

    • The query looks for devices that contact at least 3 different webhook UUIDs or make 10 or more webhook-related events in 15 minutes.
    • It extracts webhook UUIDs from command lines and URLs to identify distinct endpoints.
  4. Query Logic:

    • It searches for references to webhook.site in both process and network event logs within the last 24 hours.
    • It extracts UUIDs from these references and groups the data by device, account, and 15-minute intervals.
    • It triggers an alert if the criteria for distinct UUIDs or event count are met.
  5. Use Cases:

    • This query is useful for detecting potential data exfiltration or command-and-control activities by malicious actors.
    • It can help security teams identify and investigate suspicious device behavior.
  6. Considerations:

    • The query includes mechanisms to reduce false positives, such as excluding known authorized activities.
    • It suggests further investigation steps, like comparing URLs with process command lines and reviewing proxy logs.
  7. Severity and Tuning:

    • The rule is initially set to high severity, but it should be tuned based on the environment before setting up alerts.
    • It's recommended to run this query as a hunt to validate its effectiveness and adjust thresholds as needed.