Skip to main content

Azure Innovators

A gloved hand holding a magnifying glass over a blank envelope whose round postmark glows green
Forged From line, or a message your tenant actually sent?

Two Reports, Two Very Different Incidents

"Did you mean to send me this?" is one of the most common messages an IT team gets, and most of the time the answer is boring. Someone forged your address, your domain's protections did or didn't catch it, and your mailbox was never touched.

That was my starting assumption on August 6, when contacts began asking about an "Azure Innovators RFP" email I hadn't sent. It turned out to be wrong. My account had been compromised, and the full story is in the post-mortem, The Email Really Was From Me. This series goes deeper on each stage, starting with the question you have to answer first: was the message forged, or did your tenant actually send it?

It matters because the two answers send you in opposite directions:

If it was…What actually happenedWhat you do next
SpoofedAn outside server put your address in the From lineCheck SPF, DKIM, and DMARC, look for lookalike domains, help recipients filter it
Sent by your tenantSomeone had a valid session and used your real mailboxContain the identity now, then hunt for persistence and scope the recipients

Get it wrong in one direction and you spend a day tuning DMARC while an attacker reads your mail. Get it wrong in the other and you reset passwords and alarm customers over a forgery. The good news is that Exchange Online can settle it in under an hour, without a copy of the message. We never got one, and we didn't need it.

About the Code in This Post

Everything here is read-only. It's the same collection the investigation used, trimmed for the post. Run it from a privileged access workstation (PAW), in a fresh PowerShell 7 window, with the ExchangeOnlineManagement module (3.7.0 or later for Get-MessageTraceV2).

CheckCmdletNeeds
Did Exchange Online process it?Get-MessageTraceV2An Exchange role that includes message trace
Did the mailbox itself send it?Search-UnifiedAuditLogView-Only Audit Logs (or Audit Logs) in Purview
What changed inside the mailbox?Get-InboxRule, Search-UnifiedAuditLogThe same

One forward-looking note: Microsoft is retiring Search-UnifiedAuditLog on October 15, 2027, and the Graph AuditLogQuery API replaces it. The cmdlet works unchanged until then, and it's what we used. If you're building new tooling, build it on the API.

Check 1: Did Exchange Online Process It?

A steel mailbox with rows of brass mail slots, a flashlight lighting the front while a slot on the side glows green with an envelope sliding out
Search every address the mailbox owns, not just the one people reply to.

Message trace answers the first question directly. If your tenant processed outbound mail with that subject, from your mailbox, it's in the trace. If the message was forged somewhere else, there's nothing to find.

The gotcha is which address you search for. My sign-in name and my primary SMTP address are on different domains, and the mailbox holds 23 SMTP addresses in all, accumulated over years of domains and aliases. The campaign went out under my sign-in address, not the primary address people reply to. A trace on the primary alone would have come back looking reassuringly quiet.

So start by collecting every address the mailbox owns:

Connect-ExchangeOnline -ShowBanner:$false

$mbx = Get-Mailbox -Identity 'jd**@*****************re.com'
$senders = @(
    $mbx.EmailAddresses |
        ForEach-Object { $_.ToString() } |
        Where-Object { $_ -match '^(?i)smtp:' } |
        ForEach-Object { $_.Substring(5).ToLowerInvariant() } |
        Sort-Object -Unique
)
"{0} addresses: {1}" -f $senders.Count, ($senders -join ', ')

Then trace the window you care about. Get-MessageTraceV2 can reach back 90 days, but each query covers at most 10 days and returns at most 5,000 rows. In a busy tenant a single day can blow past 5,000, so the loop below walks one day at a time and uses Microsoft's continuation pattern (pass the last row's Received time and RecipientAddress back in) instead of trusting one call:

$start = [datetime]'2026-08-04T00:00:00Z'
$end   = [datetime]'2026-08-08T00:00:00Z'
$trace = [System.Collections.Generic.List[object]]::new()

for ($day = $start; $day -lt $end; $day = $day.AddDays(1)) {
    $q = @{ StartDate = $day; EndDate = $day.AddDays(1)
            SenderAddress = $senders; ResultSize = 5000 }
    do {
        $page = @(Get-MessageTraceV2 @q)
        $page | ForEach-Object { $trace.Add($_) }
        if ($page.Count -eq 5000) {
            $q.EndDate = $page[-1].Received.ToString('O')
            $q.StartingRecipientAddress = $page[-1].RecipientAddress
        }
    } while ($page.Count -eq 5000)
}

$trace | Group-Object Subject, FromIP | ForEach-Object {
    [pscustomobject]@{
        Subject    = $_.Group[0].Subject
        FromIP     = $_.Group[0].FromIP
        Rows       = $_.Count
        Recipients = @($_.Group.RecipientAddress | Sort-Object -Unique).Count
        Statuses   = (@($_.Group.Status | Sort-Object -Unique) -join ', ')
    }
} | Sort-Object Recipients -Descending | Format-Table -AutoSize

Grouping by subject and source IP is the step that makes the answer obvious. Normal mail is lots of small groups: one subject, a handful of recipients. A campaign is one subject with hundreds of recipients, sent from an address you don't recognize. Ours was 356 trace rows for one subject, which reduced to 351 unique recipients. Five of the mailbox's addresses had sent mail during the incident window, and the campaign came from the one I sign in with.

If the subject people reported isn't in your trace at all, across every address the mailbox owns, that's strong evidence of spoofing, and the SPF/DKIM/DMARC path is the right one. If it is there, you're done with the spoofing theory.

Check 2: Did the Mailbox Itself Send It?

Message trace proves the tenant processed the message. The Purview audit log proves which client in the mailbox sent it, and that's what separates "someone abused an SMTP relay" from "someone was signed in as me."

$audit = [System.Collections.Generic.List[object]]::new()
$sid = "SendAudit-$([guid]::NewGuid())"
do {
    $page = @(Search-UnifiedAuditLog -StartDate $start -EndDate $end `
        -UserIds $mbx.UserPrincipalName -Operations Send, SendAs `
        -SessionId $sid -SessionCommand ReturnLargeSet -ResultSize 5000)
    $page | ForEach-Object { $audit.Add($_) }
} while ($page.Count -gt 0)

$audit | ForEach-Object {
    $d = $_.AuditData | ConvertFrom-Json
    [pscustomobject]@{
        TimeUtc = $_.CreationDate
        Op      = $d.Operation
        Client  = ($d.ClientInfoString -split ';')[0]
        IP      = if ($d.ClientIPAddress) { $d.ClientIPAddress } else { $d.ClientIP }
        Subject = $d.Item.Subject
    }
} | Sort-Object TimeUtc | Format-Table -AutoSize

Over the incident window, this mailbox logged 69 send records. Nearly all of them were what you'd expect from me: Outlook on the desktop, Outlook on my phone, one REST client, one ActiveSync device. Exactly six came from Outlook on the web, all within three minutes on August 6, all from the same unfamiliar address, all with the campaign subject.

That's the moment the spoofing theory died. A forged From line can't create a Send audit record in your tenant. Only a session in the mailbox can.

How to read it:

  • Group by the client first. Your own sending habits are boringly consistent. A client you don't use, or one you do use but from an address you don't recognize, is the outlier.
  • SendAs records are normal if you hold Send As on a shared mailbox or another address. Ours were 18 legitimate desktop sends. Don't chase them just because they look unusual.
  • A burst of sends with the subject people reported is the finding. Count them, note the first and last time, and put both in your timeline.

The 50,000-Record Trap

Three mail sacks hanging from spring scales, each fuller than the last, envelopes spilling to the floor and the last needle pushed into the red
The search stops at 50,000 records, and it won't tell you.

The send search above is narrow, so it stays small. The broader mailbox audit you'll want next (everything the account did in the window) is not, and Search-UnifiedAuditLog returns at most 50,000 records per search session, even with ReturnLargeSet.

That sounds like plenty for one mailbox. It wasn't. Our user-scoped search ran from a few hundred to a few thousand records a day for most of the window, then one day added more than 32,000 records on its own. A single search across the whole window would have hit the cap partway through and stopped. It wouldn't have thrown an error, and the output would have looked complete.

The fix is the one the collector used from the start: slice the window by day, give each slice its own session ID, and log the count per slice. If any slice comes close to 50,000, split that day into hours. A per-day count in your notes also tells you, months later, that the search was complete. That's worth more than the extra few lines of code.

Check 3: What Changed Inside the Mailbox?

Cutaway of a mailbox where a glowing lever tips a chute so envelopes drop into a side bin, a gloved hand pressing the lever
The rule history shows who set the lever, and when.

The second symptom, two days of no inbound mail, pointed straight here. Look at the rules as they are now and as they were created, because each one tells you something the other can't.

Current state first. -IncludeHidden matters, because rules created by some clients don't show up in Outlook's rule list:

Get-InboxRule -Mailbox $mbx.UserPrincipalName -IncludeHidden |
    Select-Object Name, Enabled, Priority, MoveToFolder, MarkAsRead,
        DeleteMessage, StopProcessingRules,
        @{ n = 'Forward'; e = { ($_.ForwardTo + $_.RedirectTo) -join '; ' } } |
    Format-Table -AutoSize

Then the history. Here's the detail that surprises people: a rule created in Outlook on the web is audited as an admin cmdlet. It shows up as New-InboxRule under the ExchangeAdmin record type, with every parameter the rule was created with. Rules made in classic Outlook on the desktop show up differently, as UpdateInboxRules, so search for both:

$rules = Search-UnifiedAuditLog -StartDate '2026-07-15' -EndDate '2026-08-10' `
    -RecordType ExchangeAdmin -ResultSize 5000 `
    -Operations New-InboxRule, Set-InboxRule, Remove-InboxRule, UpdateInboxRules

$rules | ForEach-Object {
    $d = $_.AuditData | ConvertFrom-Json
    [pscustomobject]@{
        TimeUtc = $_.CreationDate
        Op      = $d.Operation
        By      = $d.UserId
        Params  = ($d.Parameters |
            ForEach-Object { "$($_.Name)=$($_.Value)" }) -join '; '
    }
} | Sort-Object TimeUtc | Format-List

Ours returned four records, and they told the story better than the current state could:

  • July 22: a rule moving mail from one specific external correspondent to Conversation History. That's two weeks before anyone noticed anything.
  • August 6: a rule moving all incoming mail to Conversation History, MarkAsRead=True, StopProcessingRules=True. Created two minutes before the campaign.
  • August 8: two Remove-InboxRule records. Those were mine, during containment.

Two details are worth stealing for your own triage. The attacker named the rules after the mailbox owner, the way you'd get rules called "Jane" and "Doe" in Jane Doe's mailbox. In a list of 51 legitimate rules, a rule with the owner's name looks like something the owner made. And your own fixes land in the same log, so write down the time of every containment action as you take it. Months later, the only way to tell their Remove-InboxRule from yours is your notes.

If Someone Forwards You a Copy

We never had the original message. Recipients had deleted it, and the attacker had hard-deleted the sent copies. If you do get one, forwarded as an attachment so the headers survive, two things settle the question quickly:

  • Authentication-Results shows dkim=pass with header.d= set to your own domain. A forger can put your domain in the From line, but they can't sign with your DKIM key.
  • X-MS-Exchange-CrossTenant-AuthAs: Internal means the message was authenticated inside your tenant, not just relayed through it.

Treat the headers as corroboration, not the primary proof. The trace and the audit log are in your tenant, under your control, and don't depend on a recipient keeping a copy.

Proving Which One It Was

A steel mailbox with a glowing green wax seal on its door and a blank envelope clipped beside it
One tenant-side finding is enough to start containment.

Here's the decision table we ended up using. Each row is a test that can come back either way:

TestPoints to spoofingPoints to your tenantOurs
Subject in message trace, any aliasNot foundFoundFound, 351 recipients
Send audit for that subjectNoneSend records from a mailbox session6 sends from Outlook on the web
Client and source match your habits—Unfamiliar client or addressBoth unfamiliar
Rules created recentlyNoneHide, move, mark-read, forwardTwo, both hiding mail
Headers on a forwarded copyDKIM fails or absent for your domainDKIM passes, AuthAs InternalNo copy available

One "your tenant" row is enough to start containment. You don't need all five. We had three of them inside the first hour, and that justified changing the password, revoking sessions, and pulling the rules before we understood how the attacker got in.

That's the point of this stage. The first conclusion wasn't "I know exactly what happened." It was narrower and defensible: the mailbox was used through authenticated access, rules had hidden inbound mail, and Exchange Online had sent the campaign. Everything after that, including the identity side, was built on that statement.

Next: The Identity Side

Message trace and the mailbox audit prove that the mailbox was used. They don't show how the attacker got a session. Part 2 moves to Microsoft Entra ID: correlating sign-ins, device registrations, and session IDs when the only thing you have is logs, and why the property that finally explained it, originalTransferMethod, is easy to miss.

Had a "spam from me" report that turned out to be more than spoofing, or want help working out which one you're looking at? Get in touch.

Leave a Reply

Your email address will not be published. Required fields are marked *