-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #496 from NZLostboy/cis
Added CIS Checks 2.1.5, 2.1.6
- Loading branch information
Showing
12 changed files
with
286 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
powershell/public/cis/Test-MtCisOutboundSpamFilterPolicy.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
2.1.6 (L1) Ensure Exchange Online Spam Policies are set to notify administrators | ||
|
||
Description: Configure Exchange Online Spam Policies to copy emails and notify someone when a sender in the organization has been blocked for sending spam emails. | ||
|
||
#### Remediation action: | ||
|
||
To set the Exchange Online Spam Policies: | ||
|
||
1. Navigate to Microsoft 365 Defender [https://security.microsoft.com](https://security.microsoft.com) | ||
2. Under **Email & collaboration** select **Policies & rules** | ||
3. Select **Threat policies** then **Anti-spam** | ||
4. Click on the **Anti-spam outbound policy (default)** | ||
5. Select **Edit protection settings** then under **Notifications** | ||
6. Check **Send a copy of outbound messages that exceed these limits to these users and groups** then enter the desired email addresses | ||
7. Check **Notify these users and groups if a sender is blocked due to sending outbound spam** then enter the desired email addresses. | ||
8. Click **Save**. | ||
|
||
#### Related links | ||
|
||
* [Microsoft 365 Defender](https://security.microsoft.com) | ||
* [CIS Microsoft 365 Foundations Benchmark v3.1.0 - Page 76](https://www.cisecurity.org/benchmark/microsoft_365) | ||
|
||
<!--- Results ---> | ||
%TestResult% |
92 changes: 92 additions & 0 deletions
92
powershell/public/cis/Test-MtCisOutboundSpamFilterPolicy.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<# | ||
.SYNOPSIS | ||
Checks if Exchange Online Spam Policies are set to notify administrators | ||
.DESCRIPTION | ||
Ensure Exchange Online Spam Policies are set to notify administrators | ||
.EXAMPLE | ||
Test-MtCisOutboundSpamFilterPolicy | ||
Returns true if Exchange Online Spam Policies are set to notify administrators | ||
.LINK | ||
https://maester.dev/docs/commands/Test-MtCisOutboundSpamFilterPolicy | ||
#> | ||
function Test-MtCisOutboundSpamFilterPolicy { | ||
[CmdletBinding()] | ||
[OutputType([bool])] | ||
param() | ||
|
||
if (!(Test-MtConnection ExchangeOnline)) { | ||
Add-MtTestResultDetail -SkippedBecause NotConnectedExchange | ||
return $null | ||
} | ||
elseif (!(Test-MtConnection SecurityCompliance)) { | ||
Add-MtTestResultDetail -SkippedBecause NotConnectedSecurityCompliance | ||
return $null | ||
} | ||
elseif ($null -eq (Get-MtLicenseInformation -Product Mdo)) { | ||
Add-MtTestResultDetail -SkippedBecause NotLicensedMdo | ||
return $null | ||
} | ||
|
||
Write-Verbose "Getting Outbound Spam Filter Policy..." | ||
$policy = Get-MtExo -Request HostedOutboundSpamFilterPolicy | ||
|
||
$OutboundSpamFilterPolicyCheckList = @() | ||
|
||
#BccSuspiciousOutboundMail should be True | ||
$OutboundSpamFilterPolicyCheckList += [pscustomobject] @{ | ||
"CheckName" = "BccSuspiciousOutboundMail" | ||
"Value" = "True" | ||
} | ||
|
||
#NotifyOutboundSpam should be True | ||
$OutboundSpamFilterPolicyCheckList += [pscustomobject] @{ | ||
"CheckName" = "NotifyOutboundSpam" | ||
"Value" = "True" | ||
} | ||
|
||
|
||
Write-Verbose "Executing checks" | ||
$failedCheckList = @() | ||
foreach ($check in $OutboundSpamFilterPolicyCheckList) { | ||
|
||
$checkResult = $policy | Where-Object { $_.($check.CheckName) -notmatch $check.Value } | ||
|
||
if ($checkResult) { | ||
#If the check fails, add it to the list so we can report on it later | ||
$failedCheckList += $check.CheckName | ||
} | ||
|
||
} | ||
|
||
$testResult = ($failedCheckList | Measure-Object).Count -eq 0 | ||
|
||
$portalLink = "https://security.microsoft.com/antispam" | ||
|
||
if ($testResult) { | ||
$testResultMarkdown = "Well done. Your tenant has Exchange Online Spam Policies set to notify administrators ($portalLink).`n`n%TestResult%" | ||
} | ||
else { | ||
$testResultMarkdown = "Your tenant does not have Exchange Online Spam Policies set to notify administrators ($portalLink).`n`n%TestResult%" | ||
} | ||
|
||
|
||
$resultMd = "| Check Name | Result |`n" | ||
$resultMd += "| --- | --- |`n" | ||
foreach ($item in $OutboundSpamFilterPolicyCheckList) { | ||
$itemResult = "❌ Fail" | ||
if ($item.CheckName -notin $failedCheckList) { | ||
$itemResult = "✅ Pass" | ||
} | ||
$resultMd += "| $($item.CheckName) | $($itemResult) |`n" | ||
} | ||
|
||
$testResultMarkdown = $testResultMarkdown -replace "%TestResult%", $resultMd | ||
|
||
Add-MtTestResultDetail -Result $testResultMarkdown | ||
|
||
return $testResult | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
powershell/public/cis/Test-MtCisSafeAttachmentsAtpPolicy.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
2.1.5 (L2) Ensure Safe Attachments for SharePoint, OneDrive, and Microsoft Teams is Enabled | ||
|
||
Description: Safe Attachments for SharePoint, OneDrive, and Microsoft Teams scans these services for malicious files. | ||
|
||
#### Remediation action: | ||
|
||
To enable Safe Attachments for SharePoint, OneDrive, and Microsoft Teams: | ||
|
||
1. Navigate to Microsoft 365 Defender [https://security.microsoft.com](https://security.microsoft.com) | ||
2. Under **Email & collaboration** select **Policies & rules** | ||
3. Select **Threat policies** then **Safe Attachments** | ||
4. Click on **Global settings** | ||
5. Click to **Enable Turn on Defender for Office 365 for SharePoint, OneDrive, and Microsoft Teams** | ||
6. Click to **Enable Turn on Safe Documents for Office clients** | ||
7. Click to **Disable Allow people to click through Protected View even if Safe Documents identified the file as malicious** | ||
8. Click **Save**. | ||
|
||
#### Related links | ||
|
||
* [Microsoft 365 Defender](https://security.microsoft.com) | ||
* [CIS Microsoft 365 Foundations Benchmark v3.1.0 - Page 73](https://www.cisecurity.org/benchmark/microsoft_365) | ||
|
||
<!--- Results ---> | ||
%TestResult% |
97 changes: 97 additions & 0 deletions
97
powershell/public/cis/Test-MtCisSafeAttachmentsAtpPolicy.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<# | ||
.SYNOPSIS | ||
Checks if Safe Attachments for SharePoint, OneDrive, and Microsoft Teams are enabled | ||
.DESCRIPTION | ||
Safe Attachments for SharePoint, OneDrive, and Microsoft Teams should be enabled | ||
.EXAMPLE | ||
Test-MtCisSafeAttachmentsAtpPolicy | ||
Returns true if safe attachments are enabled for SharePoint, OneDrive, and Microsoft Teams | ||
.LINK | ||
https://maester.dev/docs/commands/Test-MtCisSafeAttachmentsAtpPolicy | ||
#> | ||
function Test-MtCisSafeAttachmentsAtpPolicy { | ||
[CmdletBinding()] | ||
[OutputType([bool])] | ||
param() | ||
|
||
if (!(Test-MtConnection ExchangeOnline)) { | ||
Add-MtTestResultDetail -SkippedBecause NotConnectedExchange | ||
return $null | ||
} | ||
elseif (!(Test-MtConnection SecurityCompliance)) { | ||
Add-MtTestResultDetail -SkippedBecause NotConnectedSecurityCompliance | ||
return $null | ||
} | ||
elseif ($null -eq (Get-MtLicenseInformation -Product Mdo)) { | ||
Add-MtTestResultDetail -SkippedBecause NotLicensedMdo | ||
return $null | ||
} | ||
|
||
Write-Verbose "Getting 365 Atp Policy..." | ||
$policy = Get-MtExo -Request AtpPolicyForO365 | ||
|
||
$atpPolicyCheckList = @() | ||
|
||
#EnableATPForSPOTeamsODB should be True | ||
$atpPolicyCheckList += [pscustomobject] @{ | ||
"CheckName" = "EnableATPForSPOTeamsODB" | ||
"Value" = "True" | ||
} | ||
|
||
#EnableSafeDocs should be True | ||
$atpPolicyCheckList += [pscustomobject] @{ | ||
"CheckName" = "EnableSafeDocs" | ||
"Value" = "True" | ||
} | ||
|
||
#AllowSafeDocsOpen should be False | ||
$atpPolicyCheckList += [pscustomobject] @{ | ||
"CheckName" = "AllowSafeDocsOpen" | ||
"Value" = "False" | ||
} | ||
|
||
Write-Verbose "Executing checks" | ||
$failedCheckList = @() | ||
foreach ($check in $atpPolicyCheckList) { | ||
|
||
$checkResult = $policy | Where-Object { $_.($check.CheckName) -notmatch $check.Value } | ||
|
||
if ($checkResult) { | ||
#If the check fails, add it to the list so we can report on it later | ||
$failedCheckList += $check.CheckName | ||
} | ||
|
||
} | ||
|
||
$testResult = ($failedCheckList | Measure-Object).Count -eq 0 | ||
|
||
$portalLink = "https://security.microsoft.com/safeattachmentv2" | ||
|
||
if ($testResult) { | ||
$testResultMarkdown = "Well done. Your tenant has Safe Attachments for SharePoint, OneDrive, and Microsoft Teams enabled ($portalLink).`n`n%TestResult%" | ||
} | ||
else { | ||
$testResultMarkdown = "Your tenant does not have Safe Attachments for SharePoint, OneDrive, and Microsoft Teams enabled ($portalLink).`n`n%TestResult%" | ||
} | ||
|
||
|
||
$resultMd = "| Check Name | Result |`n" | ||
$resultMd += "| --- | --- |`n" | ||
foreach ($item in $atpPolicyCheckList) { | ||
$itemResult = "❌ Fail" | ||
if ($item.CheckName -notin $failedCheckList) { | ||
$itemResult = "✅ Pass" | ||
} | ||
$resultMd += "| $($item.CheckName) | $($itemResult) |`n" | ||
} | ||
|
||
$testResultMarkdown = $testResultMarkdown -replace "%TestResult%", $resultMd | ||
|
||
Add-MtTestResultDetail -Result $testResultMarkdown | ||
|
||
return $testResult | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Describe "CIS" -Tag "CIS 2.1.6", "L1", "CIS E3 Level 1", "CIS E3", "CIS", "Security", "All", "CIS M365 v3.1.0" { | ||
It "2.1.6 (L1) Ensure Exchange Online Spam Policies are set to notify administrators" { | ||
|
||
$result = Test-MtCisOutboundSpamFilterPolicy | ||
|
||
if ($null -ne $result) { | ||
$result | Should -Be $true -Because "the Exchange Online Spam Policies are set to notify administrators." | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Describe "CIS" -Tag "CIS 2.1.5", "L2", "CIS E5 Level 2", "CIS E5", "CIS", "Security", "All", "CIS M365 v3.1.0" { | ||
It "2.1.5 (L2) Ensure Safe Attachments for SharePoint, OneDrive, and Microsoft Teams is Enabled" { | ||
|
||
$result = Test-MtCisSafeAttachmentsAtpPolicy | ||
|
||
if ($null -ne $result) { | ||
$result | Should -Be $true -Because "the Safe Attachement policies for SharePoint, OneDrive, and Microsoft Teams are Enabled." | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters