Query Details

Delivered Mail Carrying Exfiltration Style Urls

Query

let lookback = 30d;
EmailEvents
| where Timestamp > ago(lookback)
| where DeliveryAction == "Delivered"
| join kind=inner (
    EmailUrlInfo
    | where Timestamp > ago(lookback)
) on NetworkMessageId
| where Url matches regex @"(?i)([?&](data|q|payload|d)=[A-Za-z0-9+/]{24,}={0,2}|/(collect|exfil|log)\b)"
| project Timestamp, SenderFromAddress, RecipientEmailAddress, Subject, Url, DeliveryLocation
| sort by Timestamp desc

About this query

Delivered mail carrying exfiltration-style URLs

Description

This query joins delivered messages to their URLs and flags long, encoded-looking query parameters or collector-style paths, the shape an AI assistant would be instructed to call.

  • Note on field values: the exact DetectionMethods string can vary by tenant and evolve over time (in my data it appeared as {"Phish":["Prompt Injection..."]}). Confirm the literal in your own EmailEvents before operationalizing an alert, and treat this query's regex as a starting heuristic to tune against your legitimate URL patterns to keep false positives down. Always consider reviewing Advanced Hunting schema.

Microsoft Defender XDR

Versioning

VersionDateComments
1.008/10/2026Initial publish

Explanation

This query is designed to identify potentially suspicious emails that have been delivered and contain URLs that might be used for data exfiltration. Here's a simplified breakdown of what the query does:

  1. Lookback Period: It examines email data from the past 30 days.

  2. Filter Delivered Emails: It focuses on emails that have been successfully delivered.

  3. Join with URL Data: It combines the email data with URL information related to those emails.

  4. Identify Suspicious URLs: It searches for URLs with specific patterns that might indicate data exfiltration attempts. These patterns include:

    • Long, encoded-looking query parameters (e.g., data, q, payload, d) with a certain length and character set.
    • Paths that resemble collector or exfiltration activities (e.g., /collect, /exfil, /log).
  5. Output Details: For emails that match these criteria, it displays details such as the timestamp, sender's address, recipient's address, email subject, the suspicious URL, and where the email was delivered.

  6. Sort by Time: The results are sorted by the timestamp in descending order, showing the most recent emails first.

The query is a starting point and should be adjusted to fit the specific patterns and legitimate URL structures of your organization to minimize false positives. It is part of Microsoft Defender's advanced hunting capabilities.