
Finding and blocking malicious mailbox forwarding rules
After an attacker gets into a mailbox, one of the first things they do is set up a rule: forward anything mentioning 'invoice' to an outside address, or move replies from the finance team into a folder nobody checks. A password reset doesn't remove it. Here is how to find these rules across the whole tenant and stop them working.
Reviewed by the ITRS security team · Last updated
Why attackers create rules
Inbox rules and mailbox forwarding give an attacker persistence and stealth. Microsoft's phishing investigation playbook tells responders to check every affected mailbox for both SMTP forwarding and inbox rules that forward to external recipients, and to look out for rules with keyword conditions like 'all mail with the word invoice in the subject'.
We see a few recurring patterns in business email compromise:
- Forward all mail, or mail matching 'invoice', 'payment', 'wire' or 'bank', to an external address so the attacker keeps reading after they lose access.
- Move messages from a specific client or the accounts payable team to RSS Feeds, Archive or Conversation History and mark them read, so the real owner never sees the 'did you change your bank details?' reply.
- Delete messages containing words like 'hacked', 'phishing' or 'suspicious' so warnings from colleagues disappear.
- Rules with meaningless names (a single dot, or '..') that are easy to miss in Outlook.
Finding inbox rules and forwarding
Check mailbox-level SMTP forwarding for every mailbox
Microsoft's playbook uses Exchange Online PowerShell: Get-Mailbox -RecipientTypeDetails UserMailbox -ResultSize unlimited, showing ForwardingSmtpAddress and DeliverToMailboxAndForward, exported to CSV. Any external address there needs an owner and a reason.
List inbox rules for suspect mailboxes
Get-InboxRule -Mailbox user@yourcompany.ca lists a mailbox's rules; pipe a single rule to Format-List to see its conditions and actions. Look for ForwardTo, ForwardAsAttachmentTo, RedirectTo, DeleteMessage and MoveToFolder actions.
Search the audit log for rule creation
Search-UnifiedAuditLog with -RecordType ExchangeAdmin -Operations New-InboxRule (and Set-InboxRule) over the investigation window shows when rules were created and from what IP. Rules created in Outlook desktop may appear as UpdateInboxRules. Also search Remove-InboxRule: attackers sometimes clean up.
Use the Auto-forwarded messages report
Microsoft points to the Auto-forwarded messages report in the Exchange admin centre as another source showing who is forwarding externally.
Check the other forwarding paths
Mail flow (transport) rules created by a compromised admin, delegate permissions on the mailbox, and connected apps with mail permissions can all exfiltrate mail without an inbox rule.
Outbound spam policy: auto-forward control
The strongest preventive control is to stop automatic forwarding to external recipients at the tenant level. In the Microsoft Defender portal, outbound spam filter policies have an Automatic forwarding rules setting with three values:
- Set the default policy explicitly to Off rather than relying on System-controlled.
- If a few people genuinely need to forward externally (a shared mailbox to an outsourced bookkeeper, say), create a separate custom outbound spam policy for just those users with forwarding On, and document it.
- Internal forwarding between your own users isn't affected.
| Setting | Effect |
|---|---|
Automatic - System-controlled (default) | Microsoft changed this to mean forwarding off for new organizations and those not actively using it in 2021, but organizations that were already using it may still effectively allow forwarding |
On - Forwarding is enabled | External auto-forwarding allowed and unrestricted |
Off - Forwarding is disabled | External auto-forwarding blocked; sender gets an NDR with 5.7.520 Access denied, Your organization does not allow external forwarding |
Remote domains and transport rules
Microsoft describes two other controls that interact with the outbound policy. Remote domains in the Exchange admin centre can allow or block automatic forwarding to all external domains or specific ones. Mail flow rules can detect and block messages automatically forwarded to external recipients. If any of these layers blocks the forward, the message is blocked. A common pattern is to leave the outbound policy permissive for a named group, but use a remote domain entry so forwarding only reaches one approved partner domain.
Alerts for new rules
- Microsoft's default alert policies include 'Creation of forwarding/redirect rule', which fires when someone creates an inbox rule that forwards or redirects mail. Microsoft notes it only tracks rules created in Outlook on the web or Exchange Online PowerShell, so it won't see every rule.
- 'Suspicious email forwarding activity' alerts when a user auto-forwards to a suspicious external account.
- Make sure alert notifications go to a monitored mailbox or ticket queue, not a former employee's inbox.
- Review the Auto-forwarded messages report monthly even without alerts.
What to do if you find one
Sources: Microsoft Learn: 'Phishing investigation' incident response playbook, 'Control automatic external email forwarding' (Defender for Office 365), 'Detect and remediate Outlook rules and custom forms injections attacks', 'Alert policies in the Microsoft Defender portal', and 'Turn auditing on or off' (Microsoft Purview).
Preserve before you delete
Export the rule details (Get-InboxRule ... | Format-List) and the related audit entries. The rule's conditions show what the attacker cared about; the creation IP and time anchor the timeline.
Contain the account
Reset the password, revoke sessions, review MFA methods and app consents, then remove the rule and any forwarding.
Scope the exposure
Work out what was forwarded and to whom. That determines whether clients or vendors need warning and whether personal information was exposed.
Check for fraud in progress
Look for payment-change requests sent from or received by the mailbox during the compromise and call the counterparties on known numbers.
Assess notification duties
If personal information was exposed, Canadian privacy law may require reporting. Talk to your counsel early.
Related reading.
- PracticeCyber Forensics & AssuranceIncident response, digital forensics, penetration testing and independent attestation.
- ServiceBusiness email compromise investigation and response in Toronto and OntarioSomeone got into a company mailbox and a payment went to the wrong account, or nearly did.
- GuideWhat to do if a Microsoft 365 account is hackedAn admin's step-by-step for a compromised Microsoft 365 mailbox. The order matters: lock the attacker out first, record what they did, and only then clean up.
- GuideUsing the Microsoft 365 audit log in an investigationAlmost every Microsoft 365 investigation comes down to the audit log: who signed in, what they read, which rule they created, what they sent.
- ServiceDigital forensics in Toronto: computers, phones, Microsoft 365 and Google WorkspaceIT Rapid Support provides digital and computer forensics services for businesses in Toronto, the GTA and Ontario, focused on Microsoft 365, Exchange Online and Google…

Under attack right now?
Call before you reset passwords, wipe a laptop or pay anyone. A responder will help you contain the incident without destroying the evidence you will need later.
