How do you find and block malicious inbox rules and auto-forwarding?
A malicious inbox rule is a rule an attacker adds to a compromised mailbox to hide, delete or forward mail. In Microsoft 365, find them with Get-InboxRule -IncludeHidden and the Auto forwarded messages report. In Gmail, check Filters and Forwarding. Block external auto-forwarding by setting Automatic forwarding rules to Off in the outbound spam policy.
On this page 9 sections
An inbox rule is the quietest thing an attacker leaves behind. It needs no malware, survives a password change, and keeps working until someone looks. A malicious inbox rule is any rule, created by someone other than the mailbox owner, that hides, deletes or forwards the owner's mail. This guide shows what malicious rules and forwarding look like, how to find them in Microsoft 365 and Google Workspace, and how to block external auto-forwarding at the tenant level.
Why do attackers create inbox rules?
Attackers create inbox rules to hide their fraud from the real mailbox owner and to keep receiving copies of mail after they lose access. Once inside a mailbox, an attacker has two problems: the real owner might notice replies to the attacker's messages, and access might be cut off. Rules solve both. Microsoft's Defender XDR playbook says attackers "might also set rules in the compromised user mailbox to delete emails, move the emails into another less noticeable folder (like RSS), or forward mails to an external account." It adds that "malicious inbox rules are common during business email compromise (BEC) and phishing campaigns."
MITRE ATT&CK tracks these as two techniques:
- Email Hiding Rules (T1564.008): rules used "to delete and/or move emails to less noticeable folders", often to hide replies to phishing sent from the account.
- Email Forwarding Rule (T1114.003): "Adversaries may setup email forwarding rules to collect sensitive information." Forwarding keeps feeding the attacker mail even after the password is reset.
Rules are stored with the mailbox and run on the server, so they keep working whether or not the user is signed in, and changing the password doesn't remove them. MITRE notes that forwarding rules let attackers keep reading a victim's mail "even after compromised credentials are reset." That's why Microsoft's compromised-account steps treat reviewing mail forwarders and inbox rules (including hidden ones) as a separate step from the password reset.
Hiding rules are what make thread hijacking work: the supplier never sees the customer's "Are these new bank details right?" reply.
What do malicious inbox rules look like?
Malicious inbox rules usually move mail to a folder nobody checks and mark it as read, delete it, or forward it to an outside address, either for all mail or only for messages containing words like "invoice" or "phish". The patterns below come from Microsoft's investigations and the MITRE technique pages:
| Pattern | Typical setup | Why the attacker wants it |
|---|---|---|
| Hide everything | Move all incoming mail to Archive or RSS Subscriptions and mark as read | The user sees an empty-looking inbox and nothing alarming |
| Delete everything | Delete all incoming mail | Microsoft says a "delete all incoming emails" rule without keywords "is an indicator of malicious activity" |
| Keyword hiding | Delete or move mail containing words such as "invoice", "phish", "hack", "suspicious" or "do not reply" | Hides replies and security warnings about the fraud |
| Single-contact hiding | Move mail from one supplier or customer to an obscure folder | Hides the target of a payment fraud while the attacker writes as the user |
| External forwarding | Forward, redirect or forward as attachment to an outside address | Copies every message out, even after a password reset |
A real example: in one Microsoft investigation, the rule applied to "every incoming email where sender address contains" the fraud target's domain, moved those messages to the Archive folder and marked them as read (Microsoft, 2022). Microsoft's playbook adds that a rule with no keyword filter at all can be suspicious too.
How do you check a mailbox for rules in Outlook?
To check one mailbox in Outlook, open the rules list and the forwarding page and look for anything the user didn't create. The menus at the time of writing (October 2026) are:
- New Outlook and Outlook on the web: Settings > Mail > Rules, then Settings > Mail > Forwarding.
- Classic Outlook for Windows: File > Manage Rules & Alerts.
Look for rules the user doesn't recognize, rules with odd names, and anything that deletes, moves to an unusual folder, marks as read or forwards. Don't stop here, though. MITRE's Email Forwarding Rule page notes attackers can modify a rule through MAPI, "making it hidden and not visible from Outlook, OWA or most Exchange Administration tools." Use PowerShell to be sure.
How do you check every mailbox for hidden rules with PowerShell?
To find hidden rules in Exchange Online, run Get-InboxRule with the -IncludeHidden switch against each mailbox, then check Get-Mailbox for admin-set forwarding. Get-InboxRule has an -IncludeHidden switch that "specifies whether to include hidden Inbox rules in the results." Microsoft notes the cmdlet doesn't work for the View-Only Organization Management role group or the Global Reader role, so use an account with Exchange admin permissions. Connect with Connect-ExchangeOnline, then check one mailbox:
Get-InboxRule -Mailbox user@example.com -IncludeHidden |
Format-List Name, Enabled, Description, ForwardTo, ForwardAsAttachmentTo, RedirectTo, DeleteMessage, MoveToFolder, MarkAsRead
To sweep the whole tenant for rules that forward, redirect, delete or move mail:
Get-Mailbox -ResultSize Unlimited | ForEach-Object {
Get-InboxRule -Mailbox $_.UserPrincipalName -IncludeHidden |
Where-Object { $_.ForwardTo -or $_.ForwardAsAttachmentTo -or $_.RedirectTo -or $_.DeleteMessage -or $_.MoveToFolder } |
Select-Object MailboxOwnerId, Name, Enabled, ForwardTo, RedirectTo, DeleteMessage, MoveToFolder, Description
} | Export-Csv inbox-rules.csv -NoTypeInformation
Review the results rather than deleting everything they return: plenty of move rules are legitimate, so ask the user about anything you're unsure of. Then check admin-set mailbox forwarding, which doesn't appear as an inbox rule:
Get-Mailbox -ResultSize Unlimited |
Where-Object { $_.ForwardingSmtpAddress -or $_.ForwardingAddress } |
Format-Table UserPrincipalName, ForwardingSmtpAddress, ForwardingAddress, DeliverToMailboxAndForward
To remove what you find, record each rule first, then use Remove-InboxRule -Mailbox user@example.com -Identity "<rule name>", and clear mailbox forwarding with Set-Mailbox user@example.com -ForwardingSmtpAddress $null.
Check when rules were created
In Defender XDR advanced hunting, look for the Exchange Online actions New-InboxRule, Set-InboxRule, UpdateInboxRules and Set-Mailbox in CloudAppEvents. Microsoft's playbook includes a query that shows the IP address, location and rule configuration for each change. A rule created from an unfamiliar country or ISP minutes after a phishing click is a strong signal.
How do you find forwarding in the Exchange admin center?
To see who forwards mail outside the organization, open the Auto forwarded messages report in the new Exchange admin center. The Auto forwarded messages report in the new Exchange admin center shows mail automatically forwarded to external domains (Microsoft Learn). It breaks forwarding down by type (Mail flow rules, Inbox rules and SMTP forwarding), recipient domain and forwarding user. It shows the last 7 days by default, the summary can query up to 90 days, and a requested (downloadable) report covers up to 30 days.
Two related insights, New domains being forwarded email and New users forwarding email, highlight changes. Check the report monthly at minimum; a forwarder you can't explain needs investigating.
How do you block external auto-forwarding in Microsoft 365?
To block external auto-forwarding in Microsoft 365, set Automatic forwarding rules to Off in the outbound spam policy. That one control covers both inbox rules and admin-configured mailbox forwarding (Microsoft Learn). At the time of writing (October 2026), the setting has three values:
| Value | Effect |
|---|---|
| Automatic - System-controlled (default) | Changed to mean Off in 2021 for new organizations, but "can remain equivalent to On" for some existing ones |
| On - Forwarding is enabled | External auto-forwarding is allowed |
| Off - Forwarding is disabled | External auto-forwarding bounces with 5.7.520 Access denied, Your organization does not allow external forwarding |
Because the default can differ between tenants, Microsoft says to choose On or Off explicitly, and its recommended Standard and Strict settings are both Off. To set it:
- In the Defender portal (security.microsoft.com), go to Email & collaboration > Policies & rules > Threat policies > Anti-spam.
- Open Anti-spam outbound policy (Default) and edit Protection settings.
- Under Forwarding rules, set Automatic forwarding rules to Off - Forwarding is disabled and save.
Or run Set-HostedOutboundSpamFilterPolicy -Identity Default -AutoForwardingMode Off. Forwarding between internal users isn't affected. One detail catches admins out: when an inbox rule's forwarding is blocked, Microsoft says the NDR goes back to external senders, but internal senders get no bounce; mailbox (SMTP) forwarding bounces for both. If someone has a genuine need, create a custom outbound policy set to On for just that user. Our guide to Microsoft 365 mail flow rules for security explains how this combines with remote domains and transport rules, and the 550 5.7.520 page covers the bounce users see. Our guide to Microsoft 365 email forwarding blocked errors explains why some forwards vanish silently and how to allow one user safely.
Blocking forwarding doesn't remove hiding rules. You still need the sweep above.
How do you check Gmail filters and forwarding?
In Gmail, filters do the job of inbox rules, so check a user's filters and forwarding address in Gmail settings, then restrict automatic forwarding for the whole domain in the Admin console. For one user:
- Open Settings > See all settings.
- Check Filters and Blocked Addresses for filters that delete, archive, skip the inbox, mark as read or forward.
- Check Forwarding and POP/IMAP for a forwarding address, and select Disable forwarding if it shouldn't be there (Gmail Help).
Gmail shows a "You are forwarding your email to..." notice, but only for the first week after forwarding is turned on, so don't rely on users noticing it.
For admins, Google's compromised account guidance notes that "you can retrieve user account settings (such as forwarding settings) through the Gmail API", which is how to audit at scale.
To restrict forwarding across the domain (Google Workspace Admin Help):
- In the Admin console, go to Menu > Apps > Google Workspace > Gmail > End User Access. You need the Gmail Settings administrator privilege.
- Under Automatic forwarding, clear Allow users to automatically forward incoming email, or limit it to internal email addresses only.
- Apply it to the whole organization or to specific organizational units, and save.
The setting is on by default. When it's off, "the forwarding option isn't available in Gmail settings." Our guide to disabling automatic forwarding in Google Workspace covers allowing it for only some users and finding forwarding that already exists.
What should you do when you find a malicious inbox rule?
When you find a malicious inbox rule, treat the mailbox as compromised: record the rule, cut the attacker's access, then remove the rule and look for damage. A malicious rule means someone had access to the mailbox. Microsoft's playbook recommends disabling the rule, resetting credentials, searching for other activity by the account, and checking for activity from the same IP or ISP across the tenant.
- Record the rule (screenshot or export) before deleting it. You'll need it to scope the incident.
- Revoke sessions and reset the password. A password reset alone isn't enough if the attacker holds a session; see AiTM phishing and MFA bypass.
- Remove unknown MFA methods, app passwords and app consents. Microsoft notes app passwords aren't revoked by a password reset. See OAuth consent phishing.
- Delete the rules and forwarding.
- Review hidden folders (Archive, RSS Subscriptions, Deleted Items) for messages the user never saw.
- Check sent mail for payment requests, and phone anyone who may have acted on one.
- Sweep other mailboxes for the same rule name or pattern.
Our guide to signs your email account is compromised has the full response checklist.
Next steps
- Run the tenant-wide PowerShell sweep today and review every forwarding or delete rule.
- Set external auto-forwarding to Off explicitly in Microsoft 365, or restrict it in Google Workspace.
- Put the Auto forwarded messages report on a monthly checklist.
- Cut the phishing that leads to compromised mailboxes. iBlockSpam filters phishing, spoofing and malware at the MX before mail reaches Exchange Online; our Microsoft 365 page explains how it sits alongside the built-in protection. If users report bounces after you block forwarding, paste them into the SMTP Error Code Lookup.
Browse our other email operations guides.
Frequently asked questions
What does a malicious inbox rule usually look like?
Typically it moves messages to a folder nobody checks, such as RSS Subscriptions or Archive, and marks them as read, or it deletes them outright. Some apply to all mail; others only to messages containing words like invoice, phish or hack. Forwarding rules send copies to an outside address. A rule with no condition at all is also suspicious.
Why doesn't a rule show up in Outlook?
Some rules are hidden. MITRE ATT&CK describes attackers using MAPI to modify rule properties so a rule is not visible from Outlook, Outlook on the web or most Exchange admin tools. In Exchange Online, run Get-InboxRule with the IncludeHidden switch to list hidden rules as well. Classic Outlook can also hold client-side rules that run only on one computer.
Is external forwarding blocked by default in Microsoft 365?
Usually, but not reliably. At the time of writing (October 2026), the default, Automatic - System-controlled, has meant Off for new organizations since 2021, but Microsoft says older tenants that were already using it can still treat it as On. Microsoft recommends choosing On or Off explicitly; its Standard and Strict recommendations are both Off.
Can Google Workspace block forwarding to outside addresses?
Yes. In the Admin console under Apps, Google Workspace, Gmail, End User Access, the Automatic forwarding setting is on by default. You can turn it off, or limit forwarding to internal email addresses only, and apply the change to specific organizational units. When it's off, the forwarding option disappears from users' Gmail settings.
What should I do after deleting a malicious rule?
Treat the account as compromised. Revoke sessions, reset the password, remove unknown MFA methods and app consents, and check what was sent and forwarded while the rule existed. Then look for the same rule pattern in other mailboxes, because attackers often reuse it. Warn anyone who may have received fraudulent messages, by phone for payments.
Sources
- Microsoft Learn: Alert classification for suspicious inbox manipulation rules
- Microsoft Learn: Get-InboxRule
- Microsoft Learn: Control external email forwarding and fix 5.7.520 errors
- Microsoft Learn: Auto forwarded messages report in the new Exchange admin center
- MITRE ATT&CK: Email Hiding Rules (T1564.008)
- MITRE ATT&CK: Email Forwarding Rule (T1114.003)
- Google Workspace Admin Help: Let users automatically forward their own Gmail emails
- Microsoft Learn: Respond to a compromised email account in Microsoft 365
See how your domain measures up
Run a free Email Health Check: MX, SPF, DKIM, DMARC and transport security in one scan, with the raw records shown. No sign-up.
Keep reading
Microsoft 365 email forwarding blocked: how to fix the 5.7.520 error
Why Microsoft 365 blocks email forwarding with 5.7.520, who gets the bounce, why some forwards vanish silently, and how to allow forwarding for one user safely.
9 min read Running email day to dayWhich Microsoft 365 mail flow rules improve email security, and how do you set them up safely?
Exchange Online mail flow rules for security: block external auto-forwarding, warn on risky mail, stop executables, test in audit mode and avoid SCL -1 rules.
11 min read Setup guidesHow do you disable automatic email forwarding in Google Workspace?
Turn off or limit Gmail auto-forwarding in Google Workspace: the End User Access path, the internal-only option, OU exceptions, other leak paths and audits.
9 min read