Email forwarding rules
| Class | Data exposure, Persistence |
|---|---|
| Also known as | Inbox rules, mailbox rules, auto-forwarding, SMTP forwarding |
| MITRE ATT&CK | T1114.003 Email Collection: Email Forwarding Rule |
| Tactic | Collection |
| Typical severity | High |
| Affects | Hosted mailboxes in Microsoft 365 and Google Workspace, on-premises Exchange, and desktop mail clients with their own filters |
Most mail services let a user write inbox rules: when a message matches a condition, the rule acts on it, for example by moving it to a folder or forwarding it to another address. Rules can be made in a desktop mail app, in webmail or from a command line. An attacker who signs in to a mailbox once can add a rule that forwards new mail to an address they control, and the rule keeps sending mail after an administrator resets the stolen password.1
Where forwarding is set
Microsoft 365 offers two kinds of automatic forwarding. A user can create an Inbox rule, in Outlook, Outlook on the web or PowerShell, that forwards or redirects messages that meet a condition. An administrator can set mailbox forwarding, also called SMTP forwarding, which sends all mail for a mailbox to another address and can keep or drop the original.2 A redirected message is not delivered to the mailbox at all, and a forward can also go out as an attachment.3 Administrators of Exchange can also write transport rules (mail flow rules) that test all mail the organization receives against a condition.1
Gmail forwards all new mail except spam to a forwarding address, or chosen messages through filters with the action Forward it. Before Gmail forwards anything, it sends a verification link to the new address.45 The link goes to the new address, not to the account owner, so an attacker who enters their own address can confirm it themselves. Gmail then shows the owner a banner, "You are forwarding your email to", for the first week.4
Desktop clients keep rules of their own: Thunderbird message filters, Apple Mail rules in property-list files, and on Linux servers a .forward file or a procmail recipe.1
Why attackers use them
A second rule can delete the forwarded copies so the owner does not see them.6 Rules that move messages to the Notes, Junk Email or RSS Subscriptions folders are on Microsoft's list of signs of a compromised account.3 Through the Microsoft Messaging API (MAPI) an attacker can also change a rule's properties so that it no longer appears in Outlook, Outlook on the web or most Exchange admin tools.1
Groups recorded using the technique include LAPSUS$, which set a tenant-wide transport rule that copied all mail in and out of a target organization to an account it had created, and Scattered Spider, which redirected the emails that warned users about suspicious activity on their accounts.1 In business email compromise, a form of Financial theft, forwarding rules hand the attacker the mailbox's messages about invoices and payments.6 Attackers who steal a session through Adversary-in-the-middle phishing have created inbox rules in the same way.
A 2021 campaign
In June 2021 Microsoft published its analysis of a BEC operation that had reached hundreds of mailboxes in several organizations. Victims received a phishing email with a voice-message lure and an HTML attachment that drew a fake Microsoft sign-in page with the username filled in.6 With the stolen passwords, the attackers created two rules in each mailbox:
| Rule name | Condition | Action |
|---|---|---|
o365 default | Body contains "invoice", "payment" or "statement" | Forward to an attacker address |
o365 (del) | Body contains that attacker address | Delete the message |
The attackers tested the stolen passwords with a client that Microsoft linked to older mail protocols such as IMAP and POP3. On accounts with MFA that sign-in flow returned an invalid_grant error without sending the user an MFA notification, and MFA kept the attackers out of those mailboxes. A C# tool called EmailRuler drove a Chrome browser to add the rules at scale from virtual machines on fraudulent subscriptions at several cloud providers, which suspended the accounts after Microsoft reported them.6
Finding rules
In Exchange Online PowerShell, two commands list what a mailbox sends elsewhere.3 The first shows mailbox forwarding; a value in ForwardingSmtpAddress means mail goes to an outside address. The second lists Inbox rules, including hidden ones:
Get-Mailbox -Identity anna@example.com | Format-List Forwarding*Address,DeliverTo*
Get-InboxRule -Mailbox anna@example.com -IncludeHidden | Format-List Name,Enabled,RedirectTo,Forward*,IdentityGet-TransportRule lists organization-wide rules, and Remove-InboxRule and Remove-TransportRule delete what should not be there.1 The Microsoft Purview audit log records each change: New-InboxRule and Set-InboxRule for rules made or edited in Outlook on the web, and UpdateInboxRules for changes made from the Outlook desktop client.7 The Auto forwarded messages report lists users who forward mail outside the organization.2
Rules that forward to unknown addresses and recently added external forwarding are both listed signs of a compromised mailbox. During the response the new password should not travel by email, since the attacker may still read the mailbox, and app passwords have to be deleted by hand because a password reset leaves them working.3 Responding to an administrator account takeover covers the rest of the response.
Blocking external forwarding
In Microsoft 365 the outbound spam filter policy controls automatic forwarding to outside addresses, with three values. The default, Automatic - System-controlled, first meant on; in 2021 it changed to off for new organizations and for those not actively using it, while some older tenants still forward under it. Microsoft advises choosing On - Forwarding is enabled or Off - Forwarding is disabled explicitly.2 With forwarding off, Inbox rules and mailbox forwarding to outside addresses stop, and the sender gets a bounce with the code 5.7.520. Forwarding between internal users is not affected, and where remote-domain settings or mail flow rules disagree with the policy, the block usually wins.2
In the Google Admin console the setting is Automatic forwarding, with the box Allow users to automatically forward incoming email and a choice of any address or internal addresses only. It is on by default; when it is off, the forwarding option disappears from users' Gmail settings.5
Rules created by apps
Mail rules are also reachable through APIs. In Microsoft Graph, a POST to /me/mailFolders/inbox/messageRules with a forwardTo action creates a forwarding rule, and the permission it needs is MailboxSettings.ReadWrite, offered both as a delegated permission for an OAuth app acting for one user and as an application permission.8 Whoever holds a token with this permission can create a forwarding rule without the account's password, so a stolen token (Stolen OAuth tokens) gives the same result as a stolen password.
See also
- Phishing
- Adversary-in-the-middle phishing
- Financial theft
- Stolen OAuth tokens
- Responding to an administrator account takeover
- Audit logs
- Data exfiltration
- Category: Persistence
References
- a b c d e f "Email Collection: Email Forwarding Rule, Sub-technique T1114.003". MITRE ATT&CK. Version 1.4, modified 3 November 2026.
- a b c d Microsoft (n.d.). "Control external email forwarding and fix 5.7.520 errors". Microsoft Learn.
- a b c d Microsoft (n.d.). "Responding to a compromised email account". Microsoft Learn.
- a b Google (n.d.). "Automatically forward Gmail messages to another account". Gmail Help.
- a b Google (n.d.). "Let users automatically forward their own Gmail emails". Google Workspace Admin Help.
- a b c d Microsoft 365 Defender Research Team (14 June 2021). "Behind the scenes of business email compromise: Using cross-domain threat data to disrupt a large BEC campaign". Microsoft Security Blog.
- back Microsoft (n.d.). "Audit log activities". Microsoft Purview documentation.
- back Microsoft (n.d.). "Create rule". Microsoft Graph documentation.