Information
Anti-spam protection is a feature of Exchange Online that utilizes policies to help to reduce the amount of junk email, bulk and phishing emails a mailbox receives. These policies contain lists to allow or block specific senders or domains.
- The allowed senders list
- The allowed domains list
- The blocked senders list
- The blocked domains list
The recommended state is: Do not define any Allowed domains
Messages from entries in the allowed senders list or the allowed domains list bypass most email protection (except malware and high confidence phishing) and email authentication checks (SPF, DKIM and DMARC). Entries in the allowed senders list or the allowed domains list create a high risk of attackers successfully delivering email to the Inbox that would otherwise be filtered. The risk is increased even more when allowing common domain names as these can be easily spoofed by attackers.
Microsoft specifies in its documentation that allowed domains should be used for testing purposes only.
Solution
To remediate using the UI:
- Navigate to Microsoft 365 Defender
https://security.microsoft.com
.
- Click to expand Email & collaboration select Policies & rules > Threat policies
- Under Policies select Anti-spam
- Open each out of compliance inbound anti-spam policy by clicking on it.
- Click Edit allowed and blocked senders and domains
- Select Allow domains
- Delete each domain from the domains list.
- Click Done > Save
- Repeat as needed.
To remediate using PowerShell:
- Connect to Exchange Online using Connect-ExchangeOnline
- Run the following PowerShell command:
Set-HostedContentFilterPolicy -Identity <Policy name> -AllowedSenderDomains @{}
Or, run this to remove allowed domains from all inbound anti-spam policies:
$AllowedDomains = Get-HostedContentFilterPolicy | Where-Object {$_.AllowedSenderDomains}
$AllowedDomains | Set-HostedContentFilterPolicy -AllowedSenderDomains @{}
Impact:
This is the default behavior. Allowed domains may reduce false positives, however, this benefit is outweighed by the importance of having a policy which scans all messages regardless of the origin. As an alternative consider sender based lists. This supports the principle of zero trust.