diff --git a/powershell/public/services/exchange/Get-MtExo.ps1 b/powershell/public/services/exchange/Get-MtExo.ps1 index f78d5f7209..6ec1f01677 100644 --- a/powershell/public/services/exchange/Get-MtExo.ps1 +++ b/powershell/public/services/exchange/Get-MtExo.ps1 @@ -59,6 +59,9 @@ "EOPProtectionPolicyRule" = "Get-EOPProtectionPolicyRule" "ATPProtectionPolicyRule" = "Get-ATPProtectionPolicyRule" "ProtectionAlert" = "Get-ProtectionAlert" + "TeamsProtectionPolicy" = "Get-TeamsProtectionPolicy" + "TeamsProtectionPolicyRule" = "Get-TeamsProtectionPolicyRule" + "ReportSubmissionPolicy" = "Get-ReportSubmissionPolicy" "EXOMailbox" = "Get-EXOMailbox -ResultSize 'Unlimited'" "EXOSharedMailbox" = "Get-EXOMailbox -RecipientTypeDetails 'SharedMailbox' -ResultSize 'Unlimited'" "ArcConfig" = "Get-ArcConfig" diff --git a/powershell/tests/functions/Invoke-MtPackGitHubRequest.Tests.ps1 b/powershell/tests/functions/Invoke-MtPackGitHubRequest.Tests.ps1 index edba6469da..fc0f702b60 100644 --- a/powershell/tests/functions/Invoke-MtPackGitHubRequest.Tests.ps1 +++ b/powershell/tests/functions/Invoke-MtPackGitHubRequest.Tests.ps1 @@ -1,4 +1,4 @@ -BeforeAll { +BeforeAll { Import-Module "$PSScriptRoot/../../Maester.psd1" -Force $script:savedGhToken = $env:GH_TOKEN diff --git a/powershell/tests/functions/Test-MtCisStrictPresetForPriorityAccount.Tests.ps1 b/powershell/tests/functions/Test-MtCisStrictPresetForPriorityAccount.Tests.ps1 new file mode 100644 index 0000000000..74ddfa64e5 --- /dev/null +++ b/powershell/tests/functions/Test-MtCisStrictPresetForPriorityAccount.Tests.ps1 @@ -0,0 +1,89 @@ +BeforeAll { + Import-Module "$PSScriptRoot/../../Maester.psd1" -Force -WarningAction SilentlyContinue + . "$PSScriptRoot/../helpers/Use-MtModuleFunction.ps1" + Use-MtModuleFunction -Name Test-MtCisStrictPresetForPriorityAccount + + function Get-StrictRuleFixture { + param([hashtable] $Conditions = @{}) + $rule = [ordered]@{ + Identity = 'Strict Preset Security Policy' + State = 'Enabled' + SentTo = $null + SentToMemberOf = $null + RecipientDomainIs = $null + } + foreach ($key in $Conditions.Keys) { $rule[$key] = $Conditions[$key] } + [pscustomobject]$rule + } +} + +Describe 'Test-MtCisStrictPresetForPriorityAccount' { + BeforeEach { + $script:Result = $null + $script:EopRule = Get-StrictRuleFixture -Conditions @{ SentToMemberOf = @('Priority Accounts') } + $script:AtpRule = Get-StrictRuleFixture -Conditions @{ SentToMemberOf = @('Priority Accounts') } + Mock -ModuleName Maester Add-MtTestResultDetail { param($Result) $script:Result = $Result } + Mock -ModuleName Maester Get-MtExo -ParameterFilter { $Request -in 'EOPProtectionPolicyRule', 'ATPProtectionPolicyRule' } { + if ($Request -eq 'EOPProtectionPolicyRule') { $script:EopRule } else { $script:AtpRule } + } + Mock -ModuleName Maester Invoke-MtGraphRequest { throw 'CIS 2.4.2 does not use Graph.' } + } + + It 'passes when both enabled rules have recipient conditions' { + Test-MtCisStrictPresetForPriorityAccount | Should -BeTrue + $script:Result | Should -Match 'SentToMemberOf' + Should -Invoke Get-MtExo -ModuleName Maester -ParameterFilter { $Request -eq 'EOPProtectionPolicyRule' } -Times 1 -Exactly + Should -Invoke Get-MtExo -ModuleName Maester -ParameterFilter { $Request -eq 'ATPProtectionPolicyRule' } -Times 1 -Exactly + } + + It 'accepts a SentTo target' { + $script:EopRule = Get-StrictRuleFixture -Conditions @{ SentTo = @('user@contoso.com') } + + Test-MtCisStrictPresetForPriorityAccount | Should -BeTrue + } + + It 'accepts a RecipientDomainIs target' { + $script:EopRule = Get-StrictRuleFixture -Conditions @{ RecipientDomainIs = @('contoso.com') } + + Test-MtCisStrictPresetForPriorityAccount | Should -BeTrue + } + + It 'does not check account coverage with Graph' { + Test-MtCisStrictPresetForPriorityAccount | Should -BeTrue + Should -Invoke Invoke-MtGraphRequest -ModuleName Maester -Times 0 -Exactly + } + + It 'fails when the rule has no recipient conditions' { + $script:EopRule = Get-StrictRuleFixture + $script:EopRule.SentToMemberOf = $null + $script:AtpRule = Get-StrictRuleFixture + + Test-MtCisStrictPresetForPriorityAccount | Should -BeFalse + $script:Result | Should -Match 'no recipient conditions' + } + + It 'fails when the EOP rule has no recipient conditions and the ATP rule is targeted' { + $script:EopRule = Get-StrictRuleFixture + + Test-MtCisStrictPresetForPriorityAccount | Should -BeFalse + } + + It 'fails when the ATP rule has no recipient conditions and the EOP rule is targeted' { + $script:AtpRule = Get-StrictRuleFixture + + Test-MtCisStrictPresetForPriorityAccount | Should -BeFalse + } + + It 'fails when a rule is not returned' { + $script:EopRule = $null + + Test-MtCisStrictPresetForPriorityAccount | Should -BeFalse + $script:Result | Should -Match 'Not found' + } + + It 'fails when a rule is disabled' { + $script:AtpRule = Get-StrictRuleFixture -Conditions @{ SentToMemberOf = @('Priority Accounts'); State = 'Disabled' } + + Test-MtCisStrictPresetForPriorityAccount | Should -BeFalse + } +} diff --git a/powershell/tests/functions/Test-MtCisTeamsChecks.Tests.ps1 b/powershell/tests/functions/Test-MtCisTeamsChecks.Tests.ps1 new file mode 100644 index 0000000000..26ea23d941 --- /dev/null +++ b/powershell/tests/functions/Test-MtCisTeamsChecks.Tests.ps1 @@ -0,0 +1,298 @@ +BeforeAll { + Import-Module "$PSScriptRoot/../../Maester.psd1" -Force -WarningAction SilentlyContinue + . "$PSScriptRoot/../helpers/Use-MtModuleFunction.ps1" + Use-MtModuleFunction -Name Test-MtCisZAP, Test-MtCisThirdPartyFileSharing, Test-MtCisThirdPartyAndCustomApps, Test-MtCisTeamsReportSecurityConcerns + + # MicrosoftTeams is optional; stubs let its cmdlets be mocked when it is not installed. + $script:stubs = @() + foreach ($name in 'Get-CsTeamsClientConfiguration', 'Get-CsTeamsMessagingPolicy', 'Get-M365UnifiedTenantSettings', 'Get-CsTeamsSettingsCustomApp', 'Get-CsTenantFederationConfiguration', 'Get-CsExternalAccessPolicy') { + if (-not (Get-Command $name -ErrorAction SilentlyContinue)) { + Set-Item -Path "function:global:$name" -Value { + [CmdletBinding()] + param( + [string] $Identity, + [string[]] $SettingNames + ) + $null = $Identity + $null = $SettingNames + } + $script:stubs += $name + } + } + + . "$PSScriptRoot/../../../tests/cis/Test.CIS.M365.8.2.2.ps1" + . "$PSScriptRoot/../../../tests/cis/Test.CIS.M365.8.2.3.ps1" +} + +AfterAll { + foreach ($name in $script:stubs) { + Remove-Item -Path "Function:\$name" -ErrorAction SilentlyContinue + } +} + +Describe 'Test-MtCisZAP' { + BeforeEach { + $script:Result = $null + $script:Policies = @([pscustomobject]@{ Name = 'Teams Protection Policy'; ZapEnabled = $true }) + $script:Rules = @() + Mock -ModuleName Maester Add-MtTestResultDetail { param($Result) $script:Result = $Result } + Mock -ModuleName Maester Get-MtExo -ParameterFilter { $Request -eq 'TeamsProtectionPolicy' } { $script:Policies } + Mock -ModuleName Maester Get-MtExo -ParameterFilter { $Request -eq 'TeamsProtectionPolicyRule' } { $script:Rules } + } + + It 'passes when ZAP is on' { + Test-MtCisZAP | Should -BeTrue + $script:Result | Should -Match 'No participants are excluded' + } + + It 'fails when ZAP is off' { + $script:Policies[0].ZapEnabled = $false + Test-MtCisZAP | Should -BeFalse + } + + It 'fails when no Teams protection policy is returned' { + $script:Policies = @() + Test-MtCisZAP | Should -BeFalse + $script:Result | Should -Match 'No Teams protection policy was returned' + } + + It 'lists the exclusions for review' { + $script:Rules = @([pscustomobject]@{ ExceptIfSentTo = @('research@contoso.com'); ExceptIfSentToMemberOf = $null; ExceptIfRecipientDomainIs = @('research.contoso.com') }) + Test-MtCisZAP | Should -BeTrue + $script:Result | Should -Match 'ExceptIfSentTo \| research\\?@contoso\.com' + $script:Result | Should -Match 'ExceptIfRecipientDomainIs \| research.contoso.com' + } + + It 'escapes tenant-controlled Markdown in policy names and exclusions' { + $script:Policies = @([pscustomobject]@{ Name = '![x](https://example.com)'; ZapEnabled = $true }) + $participant = 'research@contoso.com|[link](https://example.com)' + $script:Rules = @([pscustomobject]@{ ExceptIfSentTo = @($participant); ExceptIfSentToMemberOf = $null; ExceptIfRecipientDomainIs = $null }) + + Test-MtCisZAP | Should -BeTrue + $safeName = Get-MtSafeMarkdown -Text '![x](https://example.com)' + $safeParticipant = Get-MtSafeMarkdown -Text $participant + $script:Result | Should -Match ([regex]::Escape("| $safeName | True | ✅ Pass |")) + $script:Result | Should -Match ([regex]::Escape("| ExceptIfSentTo | $safeParticipant |")) + } +} + +Describe 'CIS unmanaged Teams user settings' { + BeforeEach { + $script:Result = $null + $script:Federation = [pscustomobject]@{ + AllowTeamsConsumer = $false + AllowTeamsConsumerInbound = $false + } + $script:GlobalPolicy = $null + Mock Add-MtTestResultDetail { param($Result) $script:Result = $Result } + Mock Get-CsTenantFederationConfiguration { $script:Federation } + Mock Get-CsExternalAccessPolicy { + if ($null -eq $script:GlobalPolicy) { throw 'The Global policy lookup should not run.' } + $script:GlobalPolicy + } + } + + It 'passes 8.2.2 without looking up the Global policy when the organization setting is false' { + Test-MtCisCommunicateWithUnmanagedTeamsUsers | Should -BeTrue + $script:Result | Should -Match ([regex]::Escape('| AllowTeamsConsumer (organization settings) | False | ✅ Pass |')) + Should -Invoke Get-CsExternalAccessPolicy -Times 0 -Exactly + } + + It 'passes 8.2.3 without looking up the Global policy when the organization setting is false' { + Test-MtCisCommunicateInitiateExternalTeamsUsers | Should -BeTrue + $script:Result | Should -Match ([regex]::Escape('| AllowTeamsConsumerInbound (organization settings) | False | ✅ Pass |')) + Should -Invoke Get-CsExternalAccessPolicy -Times 0 -Exactly + } + + It 'uses the Global policy fallback and reports pass/fail for 8.2.2 when the organization setting is enabled' { + $script:Federation.AllowTeamsConsumer = $true + $script:GlobalPolicy = [pscustomobject]@{ EnableTeamsConsumerAccess = $false } + + Test-MtCisCommunicateWithUnmanagedTeamsUsers | Should -BeTrue + $script:Result | Should -Match ([regex]::Escape('| EnableTeamsConsumerAccess (Global external access policy) | False | ✅ Pass |')) + + $script:GlobalPolicy.EnableTeamsConsumerAccess = $true + Test-MtCisCommunicateWithUnmanagedTeamsUsers | Should -BeFalse + $script:Result | Should -Match ([regex]::Escape('| EnableTeamsConsumerAccess (Global external access policy) | True | ❌ Fail |')) + Should -Invoke Get-CsExternalAccessPolicy -Times 2 -Exactly + } + + It 'uses the Global policy fallback and reports pass/fail for 8.2.3 when the organization setting is enabled' { + $script:Federation.AllowTeamsConsumerInbound = $true + $script:GlobalPolicy = [pscustomobject]@{ EnableTeamsConsumerInbound = $false } + + Test-MtCisCommunicateInitiateExternalTeamsUsers | Should -BeTrue + $script:Result | Should -Match ([regex]::Escape('| EnableTeamsConsumerInbound (Global external access policy) | False | ✅ Pass |')) + + $script:GlobalPolicy.EnableTeamsConsumerInbound = $true + Test-MtCisCommunicateInitiateExternalTeamsUsers | Should -BeFalse + $script:Result | Should -Match ([regex]::Escape('| EnableTeamsConsumerInbound (Global external access policy) | True | ❌ Fail |')) + Should -Invoke Get-CsExternalAccessPolicy -Times 2 -Exactly + } +} + +Describe 'Test-MtCisThirdPartyFileSharing' { + BeforeEach { + $script:Result = $null + $script:Config = [pscustomobject]@{ AllowDropBox = $false; AllowBox = $false; AllowGoogleDrive = $false; AllowShareFile = $false; AllowEgnyte = $false } + Mock -ModuleName Maester Add-MtTestResultDetail { param($Result) $script:Result = $Result } + Mock -ModuleName Maester Get-CsTeamsClientConfiguration { $script:Config } + } + + It 'passes when every provider is off' { + Test-MtCisThirdPartyFileSharing | Should -BeTrue + $script:Result | Should -Match ([regex]::Escape('| AllowDropBox | False | No | ✅ Pass |')) + } + + It 'fails when a provider that is not approved is on' { + $script:Config.AllowBox = $true + Test-MtCisThirdPartyFileSharing | Should -BeFalse + } + + It 'passes when only approved providers are on' { + $script:Config.AllowBox = $true + Test-MtCisThirdPartyFileSharing -ApprovedProviders Box | Should -BeTrue + } + + It 'fails when approved and unapproved providers are both on' { + $script:Config.AllowDropBox = $true + $script:Config.AllowBox = $true + Test-MtCisThirdPartyFileSharing -ApprovedProviders Box | Should -BeFalse + } + + It 'fails when the client configuration is not returned' { + $script:Config = $null + Test-MtCisThirdPartyFileSharing | Should -BeFalse + } + + It 'fails when a provider setting is missing' { + $script:Config = [pscustomobject]@{ + AllowDropBox = $false + AllowBox = $false + AllowGoogleDrive = $false + AllowShareFile = $false + } + + Test-MtCisThirdPartyFileSharing | Should -BeFalse + $script:Result | Should -Match 'AllowEgnyte \| Not found \| No \| .*Fail' + } +} + +Describe 'Test-MtCisThirdPartyAndCustomApps' { + BeforeEach { + $script:Result = $null + $script:SkippedBecause = $null + $script:TenantSettings = @( + [pscustomobject]@{ SettingName = 'DefaultApp'; SettingValue = 'All' } + [pscustomobject]@{ SettingName = 'GlobalApp'; SettingValue = 'None' } + [pscustomobject]@{ SettingName = 'PrivateApp'; SettingValue = 'None' } + ) + $script:CustomApp = [pscustomobject]@{ IsSideloadedAppsInteractionEnabled = $false } + Mock -ModuleName Maester Add-MtTestResultDetail { param($Result, $SkippedBecause) $script:Result = $Result; $script:SkippedBecause = $SkippedBecause } + Mock -ModuleName Maester Get-M365UnifiedTenantSettings { $script:TenantSettings } + Mock -ModuleName Maester Get-CsTeamsSettingsCustomApp { $script:CustomApp } + } + + It 'passes when third-party apps, custom apps and custom apps in preview are off' { + Test-MtCisThirdPartyAndCustomApps | Should -BeTrue + } + + It 'fails when third-party apps are available by default' { + $script:TenantSettings[1].SettingValue = 'All' + Test-MtCisThirdPartyAndCustomApps | Should -BeFalse + } + + It 'fails when users can interact with custom apps in preview' { + $script:CustomApp.IsSideloadedAppsInteractionEnabled = $true + Test-MtCisThirdPartyAndCustomApps | Should -BeFalse + } + + It 'fails when the settings are not returned' { + $script:TenantSettings = @() + $script:CustomApp = $null + Test-MtCisThirdPartyAndCustomApps | Should -BeFalse + $script:Result | Should -Match 'Not found' + } + + It 'uses Teams settings when the Graph context is app-only' { + Mock -ModuleName Maester Get-MgContext { [pscustomobject]@{ AuthType = 'AppOnly' } } + + Test-MtCisThirdPartyAndCustomApps | Should -BeTrue + Should -Invoke Get-M365UnifiedTenantSettings -ModuleName Maester -Times 1 -Exactly + } + + It 'skips when unified tenant settings reports unsupported app-only authentication' { + Mock -ModuleName Maester Get-M365UnifiedTenantSettings { throw 'Application-based authentication is not supported for this cmdlet.' } + + Test-MtCisThirdPartyAndCustomApps | Should -BeNullOrEmpty + $script:SkippedBecause | Should -Be 'NotSupportedAppPermission' + } +} + +Describe 'Test-MtCisTeamsReportSecurityConcerns' { + BeforeEach { + $script:Result = $null + $script:MessagingPolicy = [pscustomobject]@{ AllowSecurityEndUserReporting = $true } + $script:Policy = [pscustomobject]@{ + EnableReportToMicrosoft = $false + ReportChatMessageEnabled = $false + ReportChatMessageToCustomizedAddressEnabled = $true + ReportChatMessageAddresses = @('soc@contoso.com') + ReportJunkToCustomizedAddress = $true + ReportNotJunkToCustomizedAddress = $true + ReportPhishToCustomizedAddress = $true + ReportJunkAddresses = @('soc@contoso.com') + ReportNotJunkAddresses = @('soc@contoso.com') + ReportPhishAddresses = @('soc@contoso.com') + } + Mock -ModuleName Maester Add-MtTestResultDetail { param($Result) $script:Result = $Result } + Mock -ModuleName Maester Get-CsTeamsMessagingPolicy { $script:MessagingPolicy } + Mock -ModuleName Maester Get-MtExo -ParameterFilter { $Request -eq 'ReportSubmissionPolicy' } { $script:Policy } + Mock -ModuleName Maester Get-MtExo -ParameterFilter { $Request -eq 'ReportSubmissionRule' } {} + } + + It 'passes when reports go only to the reporting mailbox' { + Test-MtCisTeamsReportSecurityConcerns | Should -BeTrue + Should -Invoke Get-MtExo -ModuleName Maester -ParameterFilter { $Request -eq 'ReportSubmissionRule' } -Times 0 -Exactly + } + + It 'fails when reported messages are also sent to Microsoft' { + $script:Policy.EnableReportToMicrosoft = $true + Test-MtCisTeamsReportSecurityConcerns | Should -BeFalse + $script:Result | Should -Match 'EnableReportToMicrosoft \| True \| False \| ❌ Fail' + } + + It 'fails when Teams reporting is not set' { + $script:MessagingPolicy = [pscustomobject]@{ AllowSecurityEndUserReporting = $null } + Test-MtCisTeamsReportSecurityConcerns | Should -BeFalse + } + + It 'fails when the Teams reporting mailbox is not configured' { + $script:Policy.ReportChatMessageAddresses = @() + + Test-MtCisTeamsReportSecurityConcerns | Should -BeFalse + $script:Result | Should -Match 'ReportChatMessageAddresses \| Not set \| soc\\?@contoso\.com \| ❌ Fail' + } + + It 'fails when a reporting destination differs from the single mailbox' { + $script:Policy.ReportChatMessageAddresses = @('triage@contoso.com') + + Test-MtCisTeamsReportSecurityConcerns | Should -BeFalse + $script:Result | Should -Match 'ReportChatMessageAddresses \| triage\\?@contoso\.com \| soc\\?@contoso\.com \| ❌ Fail' + } + + It 'escapes tenant-controlled Markdown in reporting destinations' { + $destination = 'triage@contoso.com|[link](https://example.com)' + $script:Policy.ReportChatMessageAddresses = @($destination) + + Test-MtCisTeamsReportSecurityConcerns | Should -BeFalse + $safeDestination = Get-MtSafeMarkdown -Text $destination + $script:Result | Should -Match ([regex]::Escape("| ReportChatMessageAddresses | $safeDestination |")) + } + + It 'fails when no report submission policy is returned' { + $script:Policy = $null + Test-MtCisTeamsReportSecurityConcerns | Should -BeFalse + $script:Result | Should -Match 'No report submission policy was returned' + } +} diff --git a/tests/cis/Test.CIS.M365.2.4.1.md b/tests/cis/Test.CIS.M365.2.4.1.md index 2b33891c16..e1022155c2 100644 --- a/tests/cis/Test.CIS.M365.2.4.1.md +++ b/tests/cis/Test.CIS.M365.2.4.1.md @@ -7,9 +7,15 @@ The test needs the protection to be on, at least one priority account, and an en #### Remediation action 1. Sign in to the [Microsoft Defender portal](https://security.microsoft.com). -2. Go to **Settings** > **Email & collaboration** > **Priority account protection** and turn on **Priority account protection**. -3. Go to **Settings** > **Email & collaboration** > **User tags**, open **Priority account** and add the accounts to tag. -4. Go to **Email & collaboration** > **Policies & rules** > **Alert policy** and create alerts for malware and phishing that use the **Priority account** user tag, a severity of **High**, the filter for inbound mail and a notification recipient. +2. Go to **System** > **Settings** > **Email & collaboration** > [**Priority account protection**](https://security.microsoft.com/securitysettings/priorityAccountProtection) and turn on **Priority account protection**. +3. Select **User tags**, select the **Priority account** tag and select **Edit**. Add the users or groups that are your priority accounts (groups are recommended), then select **Next** and **Submit**. Repeat for any other tags you use, such as Finance or HR. +4. Go to **Email & collaboration** > **Policies & rules** > [**Alert policy**](https://security.microsoft.com/alertpoliciesv2) and select **New alert policy**. +5. Enter a name and description, set **Severity** to **High** and **Category** to **Threat management**. +6. Set **Activity is** to **Detected malware in an email message** and the mail direction to **Inbound**. +7. Select **Add condition** > **User: recipient tags are** and select **Priority account**. +8. Select **Every time an activity matches the rule**, select **Next** and add the recipients who should be notified. +9. Select **Yes, turn it on right away** and **Submit**. +10. Repeat steps 4 to 9 with **Activity is** set to **Phishing email detected at time of delivery**. #### Related links diff --git a/tests/cis/Test.CIS.M365.2.4.2.md b/tests/cis/Test.CIS.M365.2.4.2.md index 51f74daa74..5d6e325dca 100644 --- a/tests/cis/Test.CIS.M365.2.4.2.md +++ b/tests/cis/Test.CIS.M365.2.4.2.md @@ -1,21 +1,25 @@ The Strict preset security policy applies its strongest protections to the recipients selected for Exchange Online Protection and Defender for Office 365. -Microsoft maintains the Standard and Strict preset security policies and updates them as threats change. Strict has the most aggressive settings for spam, phishing, malware, Safe Links and Safe Attachments, which suits the accounts that are most likely to be targeted and most valuable to compromise. +Executives, finance staff and administrators are the usual targets of spear phishing and whaling. Microsoft maintains the Standard and Strict preset security policies and updates them as threats change. Strict has the most aggressive settings for spam, phishing, malware, spoofing, impersonation, Safe Links and Safe Attachments, which suits the accounts that are most likely to be targeted and most valuable to compromise. -When enabled, a rule with no recipient conditions applies to everyone, including priority accounts. This test follows the CIS PowerShell audit procedure literally: it requires at least one explicit recipient condition on each enabled rule to pass. It does not verify that the selected recipients actually include priority accounts. To meet the audit criterion while targeting those accounts, add a group containing priority accounts to the rule's `SentToMemberOf` condition. Microsoft Defender for Office 365 licences are required. +The test reads the Strict preset rules for Exchange Online Protection and Defender for Office 365. Each rule must be enabled and have at least one recipient condition: `SentTo`, `SentToMemberOf` or `RecipientDomainIs`. This follows the CIS PowerShell audit procedure, but it does not verify that those targets include every priority account or evaluate rule exceptions. Review the recipient conditions, target membership and exceptions on both rules: different condition types combine with AND, while any matching exception excludes the recipient. Adjust or remove conditions and exceptions that keep a priority account from receiving either protection. Preset security policies can't target user tags, so use a group that contains the priority accounts. Microsoft Defender for Office 365 licences are required. #### Remediation action 1. Sign in to the [Microsoft Defender portal](https://security.microsoft.com). 2. Go to **Email & collaboration** > **Policies & rules** > **Threat policies** > [**Preset security policies**](https://security.microsoft.com/presetSecurityPolicies). -3. Under **Strict protection**, select **Manage protection settings**. -4. Apply the policy to **Specific recipients** and add a group containing priority accounts so each rule has a `SentToMemberOf` condition. -5. Finish the wizard and turn the policy on. +3. Turn on **Strict protection** and select **Manage protection settings**. +4. On **Apply Exchange Online Protection**, select **Specific recipients** and add the users or groups that are your priority accounts. Review existing recipient conditions and exceptions on this page, and adjust or remove any that keep a priority account from receiving protection. +5. On **Apply Defender for Office 365 protection**, select **Specific recipients** and add the same users or groups. Review existing recipient conditions and exceptions here as well, and adjust or remove any that keep a priority account from receiving protection. +6. On **Add email addresses to flag when impersonated by attackers**, add the internal and external senders, including your priority accounts, that attackers may impersonate. +7. On **Add domains to flag when impersonated by attackers**, add the domains of key partners. Your accepted domains are protected automatically. +8. On **Review and confirm your changes**, select **Confirm**. #### Related links * [Microsoft Defender portal - Preset security policies](https://security.microsoft.com/presetSecurityPolicies) * [Preset security policies in EOP and Microsoft Defender for Office 365](https://learn.microsoft.com/defender-office-365/preset-security-policies) +* [Security recommendations for priority accounts](https://learn.microsoft.com/defender-office-365/priority-accounts-security-recommendations) * [CIS Microsoft 365 Foundations Benchmark v7.0.0 - 2.4.2](https://www.cisecurity.org/benchmark/microsoft_365) diff --git a/tests/cis/Test.CIS.M365.2.4.2.ps1 b/tests/cis/Test.CIS.M365.2.4.2.ps1 index 7e1c7be3c3..cf4823632f 100644 --- a/tests/cis/Test.CIS.M365.2.4.2.ps1 +++ b/tests/cis/Test.CIS.M365.2.4.2.ps1 @@ -1,16 +1,16 @@ function Test-MtCisStrictPresetForPriorityAccount { <# .SYNOPSIS - Checks that both Strict preset security policy rules are enabled and have an explicit recipient condition. + Checks that both Strict preset security policy rules are enabled and have recipient conditions. .DESCRIPTION - Checks that both the Exchange Online Protection and the Defender for Office 365 rules of the Strict preset security policy are enabled and have at least one explicit recipient condition. A rule with no recipient conditions applies to all recipients, including priority accounts, but this test follows the CIS PowerShell audit procedure literally and requires an explicit condition to pass. It does not verify that the selected recipients are priority accounts; add a priority-account group to SentToMemberOf. + Checks that the Exchange Online Protection and Defender for Office 365 rules of the Strict preset security policy are enabled and have at least one recipient condition (SentTo, SentToMemberOf or RecipientDomainIs), as required by the CIS PowerShell audit procedure. CIS Microsoft 365 Foundations Benchmark v7.0.0 (2.4.2, L1) .EXAMPLE Test-MtCisStrictPresetForPriorityAccount - Returns true if both Strict preset security policy rules are enabled and have an explicit recipient condition. + Returns true if both Strict preset security policy rules are enabled and have recipient conditions. .LINK https://maester.dev/docs/tests/CIS.M365.2.4.2 @@ -29,47 +29,50 @@ Control = ('cis-m365:2.4.2', 'nist-800-53-r5:SI-4(5)'), Service = 'ExchangeOnline', License = 'ATP_ENTERPRISE', - Author = 'JeremyFinney-lgtm' + Author = 'JeremyFinney-lgtm', + Contributor = 'merill' )] [CmdletBinding()] [OutputType([bool])] param() - Write-Verbose 'Getting preset security policy rules...' + Write-Verbose 'Getting Strict preset security policy rules...' $eopRule = @(Get-MtExo -Request EOPProtectionPolicyRule) | Where-Object { $_.Identity -eq 'Strict Preset Security Policy' } | Select-Object -First 1 $atpRule = @(Get-MtExo -Request ATPProtectionPolicyRule) | Where-Object { $_.Identity -eq 'Strict Preset Security Policy' } | Select-Object -First 1 - - $report = foreach ($entry in @(@{ Name = 'Exchange Online Protection'; Rule = $eopRule }, @{ Name = 'Defender for Office 365'; Rule = $atpRule })) { + $rules = @( + [pscustomobject]@{ Name = 'Exchange Online Protection'; Rule = $eopRule } + [pscustomobject]@{ Name = 'Defender for Office 365'; Rule = $atpRule } + ) + $report = foreach ($entry in $rules) { $rule = $entry.Rule - $hasTargets = @($rule.SentTo | Where-Object { $_ }).Count -gt 0 -or @($rule.SentToMemberOf | Where-Object { $_ }).Count -gt 0 -or @($rule.RecipientDomainIs | Where-Object { $_ }).Count -gt 0 - $scope = if (-not $rule) { 'Rule not found' } elseif ($hasTargets) { 'Explicit recipient condition' } else { 'All recipients (no conditions)' } + $recipientConditions = @() + if ($rule) { + foreach ($condition in @('SentTo', 'SentToMemberOf', 'RecipientDomainIs')) { + if (@($rule.$condition | Where-Object { $_ }).Count -gt 0) { + $recipientConditions += $condition + } + } + } + $state = if ($rule) { $rule.State } else { 'Not found' } [pscustomobject]@{ - Component = $entry.Name - State = if ($rule) { $rule.State } else { 'Not found' } - Scope = $scope - Pass = $null -ne $rule -and $rule.State -eq 'Enabled' -and $hasTargets + Component = $entry.Name + State = $state + RecipientConditions = if ($recipientConditions.Count -gt 0) { $recipientConditions -join ', ' } else { 'None' } + Pass = $null -ne $rule -and $state -eq 'Enabled' -and $recipientConditions.Count -gt 0 } } $testResult = @($report | Where-Object { -not $_.Pass }).Count -eq 0 - $passText = 'The Strict preset security policy is enabled and applied to recipients.' - $failText = 'The Strict preset security policy is missing or disabled, or one or more rules lack the explicit recipient condition required by the CIS audit.' - $scopeNote = if (@($report | Where-Object { $_.Scope -eq 'All recipients (no conditions)' }).Count -gt 0) { - "`n`nNote: When enabled, a rule with no recipient conditions applies to everyone, including priority accounts. The CIS 2.4.2 PowerShell audit requires an explicit recipient condition to pass. Add a group containing priority accounts to SentToMemberOf to meet that criterion.`n`n" - } else { - '' - } - - $resultMd = "| Component | Rule state | Scope | Result |`n" + $resultMd = "| Component | Rule state | Recipient conditions | Result |`n" $resultMd += "| --- | --- | --- | --- |`n" foreach ($row in $report) { - $resultMd += "| $($row.Component) | $($row.State) | $($row.Scope) | $(if ($row.Pass) { '✅ Pass' } else { '❌ Fail' }) |`n" + $resultMd += "| $($row.Component) | $($row.State) | $($row.RecipientConditions) | $(if ($row.Pass) { '✅ Pass' } else { '❌ Fail' }) |`n" } if ($testResult) { - $testResultMarkdown = "Well done. $passText`n`n%TestResult%" + $testResultMarkdown = "Well done. Both Strict preset security policy rules are enabled and have recipient conditions.`n`n%TestResult%" } else { - $testResultMarkdown = "$failText$scopeNote`n`n%TestResult%" + $testResultMarkdown = "One or both Strict preset security policy rules are missing, disabled, or have no recipient conditions. Configure both rules with a recipient target using SentTo, SentToMemberOf or RecipientDomainIs.`n`n%TestResult%" } $testResultMarkdown = $testResultMarkdown -replace '%TestResult%', $resultMd diff --git a/tests/cis/Test.CIS.M365.2.4.4.md b/tests/cis/Test.CIS.M365.2.4.4.md index 0f1e2baf85..e1a72665c8 100644 --- a/tests/cis/Test.CIS.M365.2.4.4.md +++ b/tests/cis/Test.CIS.M365.2.4.4.md @@ -1,38 +1,38 @@ -2.4.4 (L1) Ensure Zero-hour auto purge for Microsoft Teams is on +Zero-hour auto purge (ZAP) for Microsoft Teams is turned on. -Zero-hour auto purge (ZAP) is a protection feature that retroactively detects and neutralizes malware and high confidence phishing. When ZAP for Teams protection blocks a message, the message is blocked for everyone in the chat. The initial block happens right after delivery, but ZAP occurs up to 48 hours after delivery. +ZAP retroactively detects and blocks malware and high confidence phishing in Teams chats and channels. A message can be harmless when it's delivered and weaponized later, or a new signature can identify it after delivery. ZAP blocks such a message for everyone in the chat up to 48 hours after delivery. As with any anti-malware or anti-phishing protection, false positives can occur. -#### Rationale - -ZAP is intended to protect users that have received zero-day malware messages or content that is weaponized after being delivered to users. It does this by continually monitoring spam and malware signatures taking automated retroactive action on messages that have already been delivered. - -#### Impact - -As with any anti-malware or anti-phishing product, false positives may occur +The test passes when every Teams protection policy has ZAP turned on, and fails when no policy is returned. It also lists the participants excluded from Teams protection, which CIS asks you to review. The test runs on tenants with Microsoft Defender for Office 365 Plan 2. #### Remediation action -To enable Zero-hour auto purge for Microsoft Teams: - -1. Navigate to [Microsoft 365 Defender](https://security.microsoft.com) -2. Click to expand **System** select **Settings** > **Email & collaboration** > **Microsoft Teams protection** +1. Sign in to the [Microsoft Defender portal](https://security.microsoft.com). +2. Go to **System** > **Settings** > **Email & collaboration** > [**Microsoft Teams protection**](https://security.microsoft.com/securitysettings/teamsProtectionPolicy). 3. Set **Zero-hour auto purge (ZAP)** to **On (Default)**. +4. Under **Exclude these participants**, review the exclusions and remove any that are not justified. ##### PowerShell 1. Connect to Exchange Online using `Connect-ExchangeOnline`. -2. Run the following cmdlet: +2. Check whether a Teams protection policy exists, then create or update it with ZAP enabled: ```powershell -Set-TeamsProtectionPolicy -Identity "Teams Protection Policy" -ZapEnabled $true +if (Get-TeamsProtectionPolicy) { + Set-TeamsProtectionPolicy -Identity "Teams Protection Policy" -ZapEnabled $true +} +else { + New-TeamsProtectionPolicy -Name "Teams Protection Policy" -ZapEnabled $true +} ``` +3. Review the exclusions with `Get-TeamsProtectionPolicyRule | Format-List ExceptIf*`. + #### Related links -* [Microsoft 365 Admin Center](https://admin.microsoft.com) -* [Zero-hour auto purge (ZAP) in Microsoft Teams](https://learn.microsoft.com/defender-office-365/zero-hour-auto-purge?view=o365-worldwide#zero-hour-auto-purge-zap-in-microsoft-teams) -* [Configure ZAP for Teams protection in Defender for Office 365](https://learn.microsoft.com/defender-office-365/mdo-support-teams-about?view=o365-worldwide#configure-zap-for-teams-protection-in-defender-for-office-365-plan-2) -* [CIS Microsoft 365 Foundations Benchmark v7.0.0 - Page 157](https://www.cisecurity.org/benchmark/microsoft_365) +* [Microsoft Defender portal - Microsoft Teams protection](https://security.microsoft.com/securitysettings/teamsProtectionPolicy) +* [Zero-hour auto purge (ZAP) in Microsoft Teams](https://learn.microsoft.com/defender-office-365/zero-hour-auto-purge#zero-hour-auto-purge-zap-in-microsoft-teams) +* [Configure ZAP for Teams protection in Defender for Office 365](https://learn.microsoft.com/defender-office-365/mdo-support-teams-about#configure-zap-for-teams-protection-in-defender-for-office-365) +* [CIS Microsoft 365 Foundations Benchmark v7.0.0 - 2.4.4](https://www.cisecurity.org/benchmark/microsoft_365) %TestResult% diff --git a/tests/cis/Test.CIS.M365.2.4.4.ps1 b/tests/cis/Test.CIS.M365.2.4.4.ps1 index 2313413431..e82736a0fa 100644 --- a/tests/cis/Test.CIS.M365.2.4.4.ps1 +++ b/tests/cis/Test.CIS.M365.2.4.4.ps1 @@ -37,27 +37,53 @@ [OutputType([bool])] param() - Write-Verbose 'Get TeamsProtectionPolicy' - $teamsProtectionPolicy = Get-TeamsProtectionPolicy | Select-Object ZapEnabled + Write-Verbose 'Getting the Teams protection policy and rule' + $policies = @(Get-MtExo -Request TeamsProtectionPolicy) + $rules = @(Get-MtExo -Request TeamsProtectionPolicyRule) - Write-Verbose 'Add policy to result if ZAP is not enabled' - $result = $teamsProtectionPolicy | Where-Object { $_.ZapEnabled -ne 'True' } + $testResult = $policies.Count -gt 0 -and @($policies | Where-Object { $_.ZapEnabled -ne $true }).Count -eq 0 - $testResult = ($result | Measure-Object).Count -eq 0 - if ($testResult) { - $testResultMarkdown = "Well done. Your tenant has Zero-hour auto purge (ZAP) enabled for Microsoft Teams:`n`n%TestResult%" - } else { - $testResultMarkdown = "Your tenant does not have Zero-hour auto purge (ZAP) enabled for Microsoft Teams:`n`n%TestResult%" + $exclusions = foreach ($rule in $rules) { + foreach ($property in 'ExceptIfSentTo', 'ExceptIfSentToMemberOf', 'ExceptIfRecipientDomainIs') { + $values = @($rule.$property | Where-Object { $_ }) + if ($values.Count -gt 0) { + [pscustomobject]@{ Exception = $property; Values = $values -join ', ' } + } + } } - $resultMd = "| Zero-hour auto purge (ZAP) |`n" - $resultMd += "| --- |`n" if ($testResult) { - $itemResult = '✅ Enabled' - } else { - $itemResult = '❌ Not Enabled' + $testResultMarkdown = "Well done. Your tenant has Zero-hour auto purge (ZAP) enabled for Microsoft Teams.`n`n%TestResult%" + } + elseif ($policies.Count -eq 0) { + $testResultMarkdown = "No Teams protection policy was returned, so Zero-hour auto purge (ZAP) for Microsoft Teams could not be confirmed.`n`n%TestResult%" + } + else { + $testResultMarkdown = "Your tenant does not have Zero-hour auto purge (ZAP) enabled for Microsoft Teams.`n`n%TestResult%" + } + + $resultMd = "| Policy | Zero-hour auto purge (ZAP) | Result |`n" + $resultMd += "| --- | --- | --- |`n" + foreach ($policy in $policies) { + $safeName = Get-MtSafeMarkdown -Text "$($policy.Name)" + $resultMd += "| $safeName | $($policy.ZapEnabled) | $(if ($policy.ZapEnabled -eq $true) { '✅ Pass' } else { '❌ Fail' }) |`n" + } + if ($policies.Count -eq 0) { + $resultMd += "| Not found | | ❌ Fail |`n" + } + + if (@($exclusions).Count -gt 0) { + $resultMd += "`nReview these exclusions and confirm that each one is justified. These exceptions match recipient conditions: if any recipient in a chat is not excluded, ZAP can still block the message for everyone. ZAP takes no action only when all recipients are excluded.`n`n" + $resultMd += "| Exclusion | Participants |`n" + $resultMd += "| --- | --- |`n" + foreach ($exclusion in $exclusions) { + $safeValues = Get-MtSafeMarkdown -Text "$($exclusion.Values)" + $resultMd += "| $($exclusion.Exception) | $safeValues |`n" + } + } + else { + $resultMd += "`nNo participants are excluded from Teams protection.`n" } - $resultMd += "| $($itemResult) |`n" $testResultMarkdown = $testResultMarkdown -replace '%TestResult%', $resultMd diff --git a/tests/cis/Test.CIS.M365.8.1.1.md b/tests/cis/Test.CIS.M365.8.1.1.md index 25de809a8b..7f89f37dca 100644 --- a/tests/cis/Test.CIS.M365.8.1.1.md +++ b/tests/cis/Test.CIS.M365.8.1.1.md @@ -1,50 +1,39 @@ -8.1.1 (L2) Ensure external file sharing in Teams is enabled for only approved cloud storage services +The check evaluates only five third-party storage settings in the Global Teams client configuration: Dropbox, Box, Google Drive, Citrix ShareFile and Egnyte. A pass means each setting is present and disabled, or enabled only when its provider is listed in `ApprovedProviders`. It does not evaluate Teams storage apps, the Teams Files policy or the default upload-app setting, so a pass does not prove that all file sharing is limited to approved services. Review enabled cloud-storage apps separately under **Teams apps** > **Manage apps**, and review the Files settings. -Microsoft Teams enables collaboration via file sharing. This file sharing is conducted within Teams, using SharePoint Online, by default; however, third-party cloud services are allowed as well. +Teams stores and shares files in SharePoint and OneDrive by default, but it can also open files from Dropbox, Box, Google Drive, Citrix ShareFile and Egnyte. Files in those services are outside the organization's data protection, retention and sharing controls, and the services may not meet the organization's security standards. Turning off the services that aren't approved keeps users on storage the organization governs. Users who rely on another provider lose access to it from Teams. ->Note: Skype for business is deprecated as of July 31, 2021 although these settings may still be valid for a period of time. See the link in the references section for more information. - -#### Rationale - -Ensuring that only authorized cloud storage providers are accessible from Teams will -help to dissuade the use of non-approved storage providers. - -#### Impact - -The impact associated with this change is highly dependent upon current practices in the tenant. If users do not use other storage providers, then minimal impact is likely. However, if users do regularly utilize providers outside of the tenant this will affect their ability to continue to do so. +The `ApprovedProviders` parameter accepts `Dropbox`, `Box`, `GoogleDrive`, `ShareFile` and `Egnyte`; by default none are approved. #### Remediation action -To change third-party cloud services using the UI: - -1. Navigate to **Microsoft Teams admin center** [https://admin.teams.microsoft.com](https://admin.teams.microsoft.com). -2. Select **Settings & policies > Global (Org-wide default) settings.** -3. Click **Teams** to open the **Teams settings** section. -4. Under files set storages providers to **Off** unless they have first been authorized by the organization. +1. Sign in to the [Microsoft Teams admin center](https://admin.teams.microsoft.com). +2. If the **Settings & policies** experience is not enabled, select the opt-in card or banner in the Teams admin center to switch to it. Then go to **Settings & policies** > [**Global (Org-wide default) settings**](https://admin.teams.microsoft.com/one-policy/settings) and select **Teams** to open the **Teams settings** section. In the existing interface, go to **Teams** > **Teams settings**. +3. Under **Files**, turn off each storage provider that the organization has not authorized. +4. Select **Save**. -To change third-party cloud services using PowerShell: +##### PowerShell -1. Connect to Teams using **Connect-MicrosoftTeams**. -2. Run the following PowerShell command to disable external providers that are not authorized. (the example disables Citrix Files, DropBox, Box, Google Drive and Egnyte) +1. Connect to Teams PowerShell using `Connect-MicrosoftTeams`. +2. Run the following command, leaving out any provider that the organization has authorized: ```powershell -$Params = @{ - Identity = 'Global' - AllowGoogleDrive = $false - AllowShareFile = $false - AllowBox = $false - AllowDropBox = $false - AllowEgnyte = $false +$params = @{ + Identity = 'Global' + AllowGoogleDrive = $false + AllowShareFile = $false + AllowBox = $false + AllowDropBox = $false + AllowEgnyte = $false } -Set-CsTeamsClientConfiguration @Params +Set-CsTeamsClientConfiguration @params ``` #### Related links -* [Microsoft 365 Admin Center](https://admin.microsoft.com) -* [Microsoft Teams Admin Center](https://admin.teams.microsoft.com). -* [Manage Teams with Microsoft Teams PowerShell](https://learn.microsoft.com/microsoftteams/teams-powershell-managing-teams) -* [CIS Microsoft 365 Foundations Benchmark v7.0.0 - Page 500](https://www.cisecurity.org/benchmark/microsoft_365) +* [Microsoft Teams admin center - Settings & policies](https://admin.teams.microsoft.com/one-policy/settings) +* [Manage apps in the Teams admin center](https://learn.microsoft.com/microsoftteams/manage-apps) +* [Set-CsTeamsClientConfiguration](https://learn.microsoft.com/powershell/module/microsoftteams/set-csteamsclientconfiguration) +* [CIS Microsoft 365 Foundations Benchmark v7.0.0 - 8.1.1](https://www.cisecurity.org/benchmark/microsoft_365) %TestResult% diff --git a/tests/cis/Test.CIS.M365.8.1.1.ps1 b/tests/cis/Test.CIS.M365.8.1.1.ps1 index 3888bf1bb0..467a9e64dc 100644 --- a/tests/cis/Test.CIS.M365.8.1.1.ps1 +++ b/tests/cis/Test.CIS.M365.8.1.1.ps1 @@ -1,16 +1,22 @@ function Test-MtCisThirdPartyFileSharing { <# .SYNOPSIS - Ensure third-party file sharing cloud services in Teams are disabled + Ensure external file sharing in Teams is enabled for only approved cloud storage services .DESCRIPTION - Ensure third-party file sharing cloud services in Teams are disabled + Checks that the third-party cloud storage services in the Global Teams client configuration are turned off, + except those the organization has approved. CIS Microsoft 365 Foundations Benchmark v7.0.0 (8.1.1) .EXAMPLE Test-MtCisThirdPartyFileSharing - Returns true if all third-party file sharing cloud services in Teams are disabled + Returns true if every third-party cloud storage service in Teams is turned off + + .EXAMPLE + Test-MtCisThirdPartyFileSharing -ApprovedProviders Box + + Returns true if every third-party cloud storage service in Teams except Box is turned off .LINK https://maester.dev/docs/commands/Test-MtCisThirdPartyFileSharing @@ -29,36 +35,50 @@ Control = ('cis-m365:8.1.1', 'nist-800-53-r5:AC-20', 'nist-800-53-r5:CM-7'), Service = 'Teams', Author = 'HenrikPiecha', - Contributor = ('merill', 'Mynster9361') + Contributor = ('merill', 'Mynster9361', 'julien-ly') )] [CmdletBinding()] [OutputType([bool])] - param() + param( + # Cloud storage services the organization has approved for file sharing in Teams, which may stay turned on. + [ValidateSet('Dropbox', 'Box', 'GoogleDrive', 'ShareFile', 'Egnyte')] + [string[]] $ApprovedProviders + ) - Write-Verbose 'Test-MtCisThirdPartyFileSharing: Checking if third-party file sharing cloud services in Teams are disabled' + Write-Verbose 'Test-MtCisThirdPartyFileSharing: Checking that only approved third-party cloud storage services are turned on in Teams' - $return = $true - $thirdPartyCloudServices = Get-CsTeamsClientConfiguration -Identity Global | Select-Object AllowDropbox, AllowBox, AllowGoogleDrive, AllowShareFile, AllowEgnyte + $clientConfig = Get-CsTeamsClientConfiguration -Identity Global + if ($null -eq $clientConfig) { + Add-MtTestResultDetail -Result 'The Global Teams client configuration was not returned, so the third-party cloud storage settings could not be confirmed.' + return $false + } $passResult = '✅ Pass' $failResult = '❌ Fail' - $result = "| Policy | Value | Status |`n" - $result += "| --- | --- | --- |`n" + $result = "| Setting | Value | Approved | Status |`n" + $result += "| --- | --- | --- | --- |`n" - foreach ($thirdPartyProvider in ($thirdPartyCloudServices.PSObject.Properties)) { - if ($thirdPartyProvider.Value -eq $false) { - $result += "| $($thirdPartyProvider.Name) | $($thirdPartyProvider.Value) | $passResult |`n" + $return = $true + foreach ($provider in 'Dropbox', 'Box', 'GoogleDrive', 'ShareFile', 'Egnyte') { + $setting = "Allow$provider" + if ($provider -eq 'Dropbox') { + $setting = 'AllowDropBox' + } + $value = $clientConfig.$setting + $approved = $provider -in $ApprovedProviders + if ($value -eq $false -or ($approved -and $value -eq $true)) { + $result += "| $setting | $value | $(if ($approved) { 'Yes' } else { 'No' }) | $passResult |`n" } else { - $result += "| $($thirdPartyProvider.Name) | $($thirdPartyProvider.Value) | $failResult |`n" + $result += "| $setting | $(if ($null -eq $value) { 'Not found' } else { $value }) | $(if ($approved) { 'Yes' } else { 'No' }) | $failResult |`n" $return = $false } } if ($return) { - $testResultMarkdown = "Well done. All third-party cloud services are disabled.`n`n%TestResult%" + $testResultMarkdown = "Well done. The five checked third-party storage settings in the Global Teams client configuration are disabled or enabled only for approved providers.`n`n%TestResult%" } else { - $testResultMarkdown = "All or specific third-party cloud services are enabled.`n`n%TestResult%" + $testResultMarkdown = "One or more of the five checked third-party storage settings are missing or enabled without approval. Turn them off, or add approved providers to the ApprovedProviders parameter.`n`n%TestResult%" } $testResultMarkdown = $testResultMarkdown -replace '%TestResult%', $result diff --git a/tests/cis/Test.CIS.M365.8.1.2.md b/tests/cis/Test.CIS.M365.8.1.2.md index f864b97cc8..9d04b7d5af 100644 --- a/tests/cis/Test.CIS.M365.8.1.2.md +++ b/tests/cis/Test.CIS.M365.8.1.2.md @@ -5,7 +5,7 @@ When the setting is off, channel members can still post in Teams. Only the email #### Remediation action 1. Sign in to the [Microsoft Teams admin center](https://admin.teams.microsoft.com). -2. Go to **Teams** > **Teams settings**. +2. Go to **Settings & policies** > [**Global (Org-wide default) settings**](https://admin.teams.microsoft.com/one-policy/settings) and select **Teams** to open the **Teams settings** section. 3. Under **Email integration**, turn off **Users can send emails to a channel email address**. 4. Select **Save**. @@ -20,9 +20,8 @@ Set-CsTeamsClientConfiguration -Identity Global -AllowEmailIntoChannel $false #### Related links -* [Microsoft Teams admin center](https://admin.teams.microsoft.com) -* [Set-CsTeamsClientConfiguration (AllowEmailIntoChannel)](https://learn.microsoft.com/powershell/module/teams/set-csteamsclientconfiguration) -* [Set-CsTeamsClientConfiguration](https://learn.microsoft.com/powershell/module/teams/set-csteamsclientconfiguration) +* [Microsoft Teams admin center - Settings & policies](https://admin.teams.microsoft.com/one-policy/settings) +* [Set-CsTeamsClientConfiguration](https://learn.microsoft.com/powershell/module/microsoftteams/set-csteamsclientconfiguration) * [CIS Microsoft 365 Foundations Benchmark v7.0.0 - 8.1.2](https://www.cisecurity.org/benchmark/microsoft_365) diff --git a/tests/cis/Test.CIS.M365.8.2.1.md b/tests/cis/Test.CIS.M365.8.2.1.md index b91721c5c4..2d28a530a8 100644 --- a/tests/cis/Test.CIS.M365.8.2.1.md +++ b/tests/cis/Test.CIS.M365.8.2.1.md @@ -1,31 +1,40 @@ Federation lets users in other Microsoft 365 and Teams organizations find and message people in your tenant. If every known external domain is allowed, anyone with a tenant in those domains can start chats with your users. That is a common route for phishing and social engineering, because the sender looks like a normal business contact. -Restricting external domains means only the partner domains you choose can communicate with your users. Turning federation off removes the path completely. +Turning off external domains in the Global (Org-wide default) external access policy removes that path for everyone the policy applies to. Users who need to work with external organizations can be assigned a custom external access policy, or the organization settings can allow only specific partner domains. Both the organization setting and the policy assigned to a user must allow federation. An organization allowlist alone does not enable federation if the applicable policy still turns it off. The test passes when the Global policy turns off external domains, or when the organization settings turn external domains off, block all of them or allow only specific domains. #### Remediation action 1. Sign in to the [Microsoft Teams admin center](https://admin.teams.microsoft.com). -2. Go to **Users** > **External access**. -3. Next to **Teams and Skype for Business users in external organizations**, choose **Allow only specific external domains**, select **Add external domains** and add the approved domains. To turn external access off instead, choose **Block all external domains**. -4. Select **Save**. +2. Go to **External collaboration** > **External access** and open the **Policies** tab. +3. Select the **Global (Org-wide default)** policy. +4. Set **Manage external domains for this policy** to **Off**. +5. Select **Save**. + +On the **Organization settings** tab, setting **Manage external domains for this organization** to **Off**, or to **On** with **Allow only specific external domains** or **Block all external domains**, also meets the recommendation. ##### PowerShell 1. Connect to Teams PowerShell using `Connect-MicrosoftTeams`. -2. Run the following commands to allow only specific domains, replacing the example domain with your approved domains. The list replaces the domains that are allowed now: +2. Run the following command: + +```powershell +Set-CsExternalAccessPolicy -Identity Global -EnableFederationAccess $false +``` + +To use an organization allowlist instead of disabling federation in the Global policy, turn federation on in the Global policy and configure the tenant-level allowlist. Replace the example domain with your approved domains; the list replaces the domains that are allowed now: ```powershell $domains = [System.Collections.Generic.List[string]]::new() $domains.Add('partner.example.com') +Set-CsExternalAccessPolicy -Identity Global -EnableFederationAccess $true Set-CsTenantFederationConfiguration -AllowFederatedUsers $true -AllowedDomainsAsAList $domains ``` ->Note: Setting AllowFederatedUsers to $false also meets the recommended state. - #### Related links * [Microsoft Teams admin center](https://admin.teams.microsoft.com) * [Manage external meetings and chat with people and organizations](https://learn.microsoft.com/microsoftteams/manage-external-access) +* [Set-CsExternalAccessPolicy](https://learn.microsoft.com/powershell/module/microsoftteams/set-csexternalaccesspolicy) * [Set-CsTenantFederationConfiguration](https://learn.microsoft.com/powershell/module/teams/set-cstenantfederationconfiguration) * [CIS Microsoft 365 Foundations Benchmark v7.0.0 - 8.2.1](https://www.cisecurity.org/benchmark/microsoft_365) diff --git a/tests/cis/Test.CIS.M365.8.2.2.md b/tests/cis/Test.CIS.M365.8.2.2.md index 654921b064..b1955d1de3 100644 --- a/tests/cis/Test.CIS.M365.8.2.2.md +++ b/tests/cis/Test.CIS.M365.8.2.2.md @@ -1,36 +1,18 @@ -8.2.2 (L1) Ensure communication with unmanaged Teams users is disabled +Users can't chat or meet with external users who have unmanaged Microsoft accounts, such as Microsoft Teams (free). -This policy setting controls chats and meetings with external unmanaged Teams users (those not managed by an organization, such as Microsoft Teams (free)). +Little effort is needed to get a free or trial Teams account, so attackers use unmanaged accounts to reach users through external access. Attacks delivered this way include DarkGate malware, social engineering and phishing by Midnight Blizzard, GIFShell and username enumeration. Turning off communication with unmanaged accounts removes that channel. Users can no longer communicate with Teams users who aren't managed by an organization. To make exceptions with a custom policy, keep the organization-level setting on and assign an allowing policy to the users who need access; turning the organization setting off cannot be overridden by a custom policy. This setting doesn't control anonymous meeting join through a shared link, and isn't available in GCC, GCC High, DoD or private cloud environments. -The recommended state is: **People in my org can chat and have meetings with external users who have unmanaged Microsoft accounts set to Off**. - -#### Rationale - -Allowing users to communicate with unmanaged Teams users presents a potential security threat as little effort is required by threat actors to gain access to a trial or free Microsoft Teams account. Some real-world attacks and exploits delivered via Teams over external access channels include: - -* DarkGate malware -* Social engineering / Phishing attacks by "Midnight Blizzard" -* GIFShell -* Username enumeration - -#### Impact - -Users will be unable to communicate with Teams users who are not managed by an organization. Organizations may choose to create additional policies for specific groups needing to communicate with unmanaged external users. - ->Note: The settings that govern chats and meetings with external unmanaged Teams users aren't available in GCC, GCC High, or DOD deployments, or in private cloud environments +The test passes when the Global (Org-wide default) external access policy or the organization settings turn the setting off. #### Remediation action -To remediate using the UI: +1. Sign in to the [Microsoft Teams admin center](https://admin.teams.microsoft.com). +2. Go to **External collaboration** > **External access** and open the **Policies** tab. +3. Select the **Global (Org-wide default)** policy. +4. Set **People in my org can chat and have meetings with external users who have unmanaged Microsoft accounts** to **Off**. +5. Select **Save**. -1. Navigate to [Microsoft 365 Teams Admin Center](https://admin.teams.microsoft.com). -2. Click to expand **External collaboration** and select **External access**. -3. Select the **Policies** tab -4. Click on the **Global (Org-wide default)** policy. -5. Set **People in my org can chat and have meetings with external users who have unmanaged Microsoft accounts** to **Off**. -6. Click **Save**. - ->Note: Configuring this setting at the organization level, in the **Organization settings** tab, to **Off** is also a compliant remediation. +Turning the same setting **Off** on the **Organization settings** tab also meets the recommendation, but blocks unmanaged-account access for everyone and cannot be overridden by a custom policy. ##### PowerShell @@ -41,15 +23,13 @@ To remediate using the UI: Set-CsExternalAccessPolicy -Identity Global -EnableTeamsConsumerAccess $false ``` ->Note: Configuring the organization settings to block communication is also in compliance with this control. - #### Related links -* [Microsoft 365 Teams Admin Center](https://admin.teams.microsoft.com) -* [IT Admins - Manage external meetings and chat with people and organizations using Microsoft identities](https://learn.microsoft.com/microsoftteams/trusted-organizations-external-meetings-chat?tabs=organization-settings) +* [Microsoft Teams admin center](https://admin.teams.microsoft.com) +* [Manage external meetings and chat with people and organizations using Microsoft identities](https://learn.microsoft.com/microsoftteams/trusted-organizations-external-meetings-chat) * [Midnight Blizzard conducts targeted social engineering over Microsoft Teams](https://www.microsoft.com/security/blog/2023/08/02/midnight-blizzard-conducts-targeted-social-engineering-over-microsoft-teams/) * [GIFShell Attack Lets Hackers Create Reverse Shell through Microsoft Teams GIFs](https://www.bitdefender.com/en-us/blog/hotforsecurity/gifshell-attack-lets-hackers-create-reverse-shell-through-microsoft-teams-gifs) -* [CIS Microsoft 365 Foundations Benchmark v7.0.0 - Page 512](https://www.cisecurity.org/benchmark/microsoft_365) +* [CIS Microsoft 365 Foundations Benchmark v7.0.0 - 8.2.2](https://www.cisecurity.org/benchmark/microsoft_365) %TestResult% diff --git a/tests/cis/Test.CIS.M365.8.2.2.ps1 b/tests/cis/Test.CIS.M365.8.2.2.ps1 index 9b02c19a97..8652dd8ef9 100644 --- a/tests/cis/Test.CIS.M365.8.2.2.ps1 +++ b/tests/cis/Test.CIS.M365.8.2.2.ps1 @@ -29,7 +29,7 @@ Control = ('cis-m365:8.2.2', 'nist-800-53-r5:AC-20'), Service = 'Teams', Author = 'HenrikPiecha', - Contributor = ('merill', 'Mynster9361') + Contributor = ('merill', 'Mynster9361', 'julien-ly') )] [CmdletBinding()] [OutputType([bool])] @@ -38,18 +38,30 @@ Write-Verbose 'Test-MtCisCommunicateWithUnmanagedTeamsUsers: Checking if communication with unmanaged Teams users is disabled' - $AllowTeamsConsumer = Get-CsTenantFederationConfiguration | Select-Object -ExpandProperty AllowTeamsConsumer - if ($AllowTeamsConsumer -eq $false) { - Add-MtTestResultDetail -Result 'Well done. Communication with unmanaged Teams users is disabled.' - return $true + $federation = Get-CsTenantFederationConfiguration + $orgSetting = $federation.AllowTeamsConsumer + $policySetting = $null + if ($orgSetting -ne $false) { + $externalAccessPolicy = Get-CsExternalAccessPolicy -Identity Global + $policySetting = $externalAccessPolicy.EnableTeamsConsumerAccess + } + $testResult = $orgSetting -eq $false -or $policySetting -eq $false + $passResult = '✅ Pass' + $failResult = '❌ Fail' + + $resultMarkdown = if ($testResult) { + "Well done. Communication with unmanaged Teams users is turned off by the audited Global external access policy or organization setting. Custom external access policies assigned to users are not checked.`n`n" } else { - $ExternalAccessPolicy = Get-CsExternalAccessPolicy -Identity Global - if ($ExternalAccessPolicy.EnableTeamsConsumerAccess -eq $false) { - Add-MtTestResultDetail -Result 'Well done. Communication with unmanaged Teams users is disabled.' - return $true - } else { - Add-MtTestResultDetail -Result 'Communication with unmanaged Teams users is enabled.' - return $false - } + "Communication with unmanaged Teams users is enabled. Turn it off in the Global external access policy or in the organization settings.`n`n" } + $resultMarkdown += "| Setting | Value | Result |`n" + $resultMarkdown += "| --- | --- | --- |`n" + $resultMarkdown += "| AllowTeamsConsumer (organization settings) | $(if ($null -eq $orgSetting) { 'Not found' } else { $orgSetting }) | $(if ($orgSetting -eq $false) { $passResult } else { $failResult }) |`n" + $policyValue = if ($orgSetting -eq $false) { 'Not checked' } elseif ($null -eq $policySetting) { 'Not found' } else { $policySetting } + $policyResult = if ($orgSetting -eq $false) { 'Not checked' } elseif ($policySetting -eq $false) { $passResult } else { $failResult } + $resultMarkdown += "| EnableTeamsConsumerAccess (Global external access policy) | $policyValue | $policyResult |`n" + $resultMarkdown += "`nEither setting turned off meets the CIS recommendation." + + Add-MtTestResultDetail -Result $resultMarkdown + return $testResult } diff --git a/tests/cis/Test.CIS.M365.8.2.3.md b/tests/cis/Test.CIS.M365.8.2.3.md index db6818c029..28802d7dc2 100644 --- a/tests/cis/Test.CIS.M365.8.2.3.md +++ b/tests/cis/Test.CIS.M365.8.2.3.md @@ -1,40 +1,18 @@ -8.2.3 (L1) Ensure external Teams users cannot initiate conversations +External users with unmanaged Microsoft accounts, such as Microsoft Teams (free), can't start chats or meetings with users in your organization. -This setting prevents external users who are not managed by an organization from initiating contact with users in the protected organization. The recommended state is to uncheck **External users with Teams accounts not managed by an organization can contact users in my organization**. +Little effort is needed to get a free or trial Teams account, so attackers use unmanaged accounts to contact users through external access. Attacks delivered this way include DarkGate malware, social engineering and phishing by Midnight Blizzard, GIFShell and username enumeration. This setting is a stop gap for CIS 8.2.2: if some users are allowed to communicate with unmanaged accounts, they still can't be contacted first. Turning off the parent setting in 8.2.2 also blocks inbound contact. Users with an exception can still join meetings that unmanaged users set up, depending on the parent setting. This setting isn't available in GCC, GCC High, DoD or private cloud environments. ->Note: Disabling this setting is used as an additional stop gap for the previous setting which disables communication with unmanaged Teams users entirely. If an organization chooses to have an exception to (L1) Ensure communication with unmanaged Teams users is disabled they can do so while also disabling the ability for the same group of users to initiate contact. Disabling communication entirely will also disable the ability for unmanaged users to initiate contact. - -#### Rationale - -Allowing users to communicate with unmanaged Teams users presents a potential security threat as little effort is required by threat actors to gain access to a trial or free Microsoft Teams account. - -Some real-world attacks and exploits delivered via Teams over external access channels include: - -* DarkGate malware -* Social engineering / Phishing attacks by "Midnight Blizzard" -* GIFShell -* Username enumeration - -#### Impact - -The impact of disabling this is very low. -Organizations may choose to create additional policies for specific groups that need to communicate with unmanaged external users. - ->Note: Chats and meetings with external unmanaged Teams users isn't available in GCC, GCC High, or DOD deployments, or in private cloud environments. +The test passes when the Global (Org-wide default) external access policy or the organization settings turn off inbound contact from unmanaged accounts. #### Remediation action -To remediate using the UI: +1. Sign in to the [Microsoft Teams admin center](https://admin.teams.microsoft.com). +2. Go to **External collaboration** > **External access** and open the **Policies** tab. +3. Select the **Global (Org-wide default)** policy. +4. Under **People in my org can chat and have meetings with external users who have unmanaged Microsoft accounts**, clear **People in my org can join external meetings and receive new chats from users who have unmanaged Microsoft accounts**. +5. Select **Save**. -1. Navigate to [Microsoft 365 Teams Admin Center](https://admin.teams.microsoft.com). -2. Click to expand **Users** select **External access**. -3. Select the **Policies** tab -4. Click on the **Global (Org-wide default)** policy. -5. Locate the parent setting **People in my organization can communicate with unmanaged Teams accounts**. -6. Uncheck **External users with Teams accounts not managed by an organization can contact users in my organization**. -7. Click **Save**. - ->Note: If People in my organization can communicate with unmanaged Teams accounts is already set to Off then this setting will not be visible and will satisfy the requirements of this recommendation. +If the parent setting is already **Off**, the option isn't shown and the recommendation is met. Clearing the same option on the **Organization settings** tab also meets the recommendation. ##### PowerShell @@ -45,15 +23,13 @@ To remediate using the UI: Set-CsExternalAccessPolicy -Identity Global -EnableTeamsConsumerInbound $false ``` ->Note: Configuring the organization settings to block inbound communication is also in compliance with this control. - #### Related links -* [Microsoft 365 Teams Admin Center](https://admin.teams.microsoft.com) -* [IT Admins - Manage external meetings and chat with people and organizations using Microsoft identities](https://learn.microsoft.com/microsoftteams/trusted-organizations-external-meetings-chat?tabs=organization-settings) +* [Microsoft Teams admin center](https://admin.teams.microsoft.com) +* [Manage external meetings and chat with people and organizations using Microsoft identities](https://learn.microsoft.com/microsoftteams/trusted-organizations-external-meetings-chat) * [Midnight Blizzard conducts targeted social engineering over Microsoft Teams](https://www.microsoft.com/security/blog/2023/08/02/midnight-blizzard-conducts-targeted-social-engineering-over-microsoft-teams/) * [GIFShell Attack Lets Hackers Create Reverse Shell through Microsoft Teams GIFs](https://www.bitdefender.com/en-us/blog/hotforsecurity/gifshell-attack-lets-hackers-create-reverse-shell-through-microsoft-teams-gifs) -* [CIS Microsoft 365 Foundations Benchmark v7.0.0 - Page 516](https://www.cisecurity.org/benchmark/microsoft_365) +* [CIS Microsoft 365 Foundations Benchmark v7.0.0 - 8.2.3](https://www.cisecurity.org/benchmark/microsoft_365) %TestResult% diff --git a/tests/cis/Test.CIS.M365.8.2.3.ps1 b/tests/cis/Test.CIS.M365.8.2.3.ps1 index f8ebdefc92..42852e79e2 100644 --- a/tests/cis/Test.CIS.M365.8.2.3.ps1 +++ b/tests/cis/Test.CIS.M365.8.2.3.ps1 @@ -29,7 +29,7 @@ Control = ('cis-m365:8.2.3', 'nist-800-53-r5:AC-20'), Service = 'Teams', Author = 'Mynster9361', - Contributor = 'merill' + Contributor = ('merill', 'julien-ly') )] [CmdletBinding()] [OutputType([bool])] @@ -38,20 +38,30 @@ Write-Verbose 'Test-MtCisCommunicateInitiateExternalTeamsUsers: Checking if external unmanaged Teams users cannot initiate conversations' - $AllowTeamsConsumerInbound = Get-CsTenantFederationConfiguration | Select-Object -ExpandProperty AllowTeamsConsumerInbound - if ($AllowTeamsConsumerInbound -eq $false) { - Add-MtTestResultDetail -Result 'Well done. External unmanaged Teams users cannot initiate conversations.' - return $true + $federation = Get-CsTenantFederationConfiguration + $orgSetting = $federation.AllowTeamsConsumerInbound + $policySetting = $null + if ($orgSetting -ne $false) { + $externalAccessPolicy = Get-CsExternalAccessPolicy -Identity Global + $policySetting = $externalAccessPolicy.EnableTeamsConsumerInbound } - else { - $ExternalAccessPolicy = Get-CsExternalAccessPolicy -Identity Global - if ($ExternalAccessPolicy.EnableTeamsConsumerInbound -eq $false) { - Add-MtTestResultDetail -Result 'Well done. External unmanaged Teams users cannot initiate conversations.' - return $true - } - else { - Add-MtTestResultDetail -Result 'External unmanaged Teams users can initiate conversations.' - return $false - } + $testResult = $orgSetting -eq $false -or $policySetting -eq $false + $passResult = '✅ Pass' + $failResult = '❌ Fail' + + $resultMarkdown = if ($testResult) { + "Well done. The audited Global external access policy or organization setting prevents external unmanaged Teams users from initiating conversations. Custom external access policies assigned to users are not checked.`n`n" + } else { + "External unmanaged Teams users can initiate conversations. Turn this off in the Global external access policy or in the organization settings.`n`n" } + $resultMarkdown += "| Setting | Value | Result |`n" + $resultMarkdown += "| --- | --- | --- |`n" + $resultMarkdown += "| AllowTeamsConsumerInbound (organization settings) | $(if ($null -eq $orgSetting) { 'Not found' } else { $orgSetting }) | $(if ($orgSetting -eq $false) { $passResult } else { $failResult }) |`n" + $policyValue = if ($orgSetting -eq $false) { 'Not checked' } elseif ($null -eq $policySetting) { 'Not found' } else { $policySetting } + $policyResult = if ($orgSetting -eq $false) { 'Not checked' } elseif ($policySetting -eq $false) { $passResult } else { $failResult } + $resultMarkdown += "| EnableTeamsConsumerInbound (Global external access policy) | $policyValue | $policyResult |`n" + $resultMarkdown += "`nEither setting turned off meets the CIS recommendation." + + Add-MtTestResultDetail -Result $resultMarkdown + return $testResult } diff --git a/tests/cis/Test.CIS.M365.8.2.4.md b/tests/cis/Test.CIS.M365.8.2.4.md index df834a3212..f6e40afd9c 100644 --- a/tests/cis/Test.CIS.M365.8.2.4.md +++ b/tests/cis/Test.CIS.M365.8.2.4.md @@ -1,10 +1,17 @@ Trial Teams tenants are tenants that have only trial licenses and no purchased licenses. They are short-lived, easy to create and often used for spam and phishing. If your organization can communicate with accounts in trial tenants, users can receive messages and meeting invitations from senders that have little accountability. -Blocking trial tenants keeps external communication limited to organizations that have purchased licenses. Users in your organization can still communicate with all other allowed external organizations. +Setting `ExternalAccessWithTrialTenants` to `Blocked` blocks communication with trial-only tenants and removes their users from existing chats, except for domains explicitly allowed by `AllowedTrialTenantDomains`. This test reads only `ExternalAccessWithTrialTenants`, so a passing result doesn't rule out those allowlisted exceptions. Users in your organization can still communicate with other allowed external organizations. #### Remediation action -Microsoft documents this setting for PowerShell only. Blocked is the default value, so a tenant fails this test only when the setting has been changed to Allowed. +1. Sign in to the [Microsoft Teams admin center](https://admin.teams.microsoft.com). +2. Go to **External collaboration** > **External access** and open the **Organization settings** tab. +3. Set **People in my organization can communicate with accounts in trial Teams tenants** to **Off**. +4. Select **Save**. + +Off (`Blocked`) is the default value, so a tenant fails this test only when the setting has been changed. + +##### PowerShell 1. Connect to Teams PowerShell using `Connect-MicrosoftTeams`. 2. Run the following command: diff --git a/tests/cis/Test.CIS.M365.8.4.1.md b/tests/cis/Test.CIS.M365.8.4.1.md index ba6bd15e35..5a2fa34994 100644 --- a/tests/cis/Test.CIS.M365.8.4.1.md +++ b/tests/cis/Test.CIS.M365.8.4.1.md @@ -1,39 +1,37 @@ -8.4.1 (L1) Ensure app permission policies are configured +Users can't install third-party or custom Teams apps by default, and can't interact with custom apps in preview. -This policy setting controls which class of apps are available for users to install. +Third-party and custom apps can read and act on Teams data on behalf of users. An app that a user adds without review may be malicious, unverified or over-privileged, and custom apps in preview can be uploaded without admin approval. Turning these defaults off means that only apps an admin has made available can be used. Admins can still make individual apps available to everyone or to specific users and groups on the **Manage apps** page; the org-wide settings apply to apps whose availability hasn't been set. -#### Rationale - -Allowing users to install third-party or unverified apps poses a potential risk of introducing malicious software to the environment. - -#### Impact - -Users will only be able to install approved classes of apps. +The test reads the org-wide app settings with `Get-M365UnifiedTenantSettings` (`GlobalApp` for third-party apps and `PrivateApp` for custom apps must be `None`) and `Get-CsTeamsSettingsCustomApp` (`IsSideloadedAppsInteractionEnabled` must be `False`). Microsoft doesn't support `Get-M365UnifiedTenantSettings` with application-based Teams authentication, and the documented Graph teams-app-settings endpoint doesn't support application permissions for these settings. The test skips when the Teams settings cmdlet reports unsupported application authentication; it does not use `Get-MgContext`, which describes the separate Graph session. Run 8.4.1 with delegated Teams authentication. #### Remediation action -1. Navigate to [Microsoft Teams Admin Center](https://admin.teams.microsoft.com). -2. Click to expand **Teams apps**, then select **Permission policies**. -3. Select the **Global (Org-wide default)** policy. -4. Under **Third-party apps**, set to **Block all apps** (or **Allow specific apps and block all others**). -5. Under **Custom apps**, set to **Block all apps** (or **Allow specific apps and block all others**). -6. Click **Save**. +1. Sign in to the [Microsoft Teams admin center](https://admin.teams.microsoft.com). +2. Go to **Teams apps** > [**Manage apps**](https://admin.teams.microsoft.com/policies/manage-apps). +3. Select **Actions** > **Org-wide app settings**. +4. Under **Third-party apps**, turn off **Let users install and use available apps by default**. +5. Under **Custom apps**, turn off **Let users install and use available apps by default**. +6. Under **Custom apps**, turn off **Let users interact with custom apps in preview**. +7. Select **Save**. ##### PowerShell 1. Connect to Teams PowerShell using `Connect-MicrosoftTeams`. -2. Run the following command to block all third-party and custom apps: +2. Run the following commands: ```powershell -Set-CsTeamsAppPermissionPolicy -Identity Global -GlobalCatalogAppsType AllowedAppList -GlobalCatalogApps @() -PrivateCatalogAppsType AllowedAppList -PrivateCatalogApps @() +Update-M365UnifiedTenantSettings -SettingName GlobalApp -SettingValue None +Update-M365UnifiedTenantSettings -SettingName PrivateApp -SettingValue None +Set-CsTeamsSettingsCustomApp -isSideloadedAppsInteractionEnabled $false ``` #### Related links -* [Microsoft Teams Admin Center](https://admin.teams.microsoft.com). -* [Manage app permission policies in Microsoft Teams](https://learn.microsoft.com/microsoftteams/teams-app-permission-policies) -* [Set-CsTeamsAppPermissionPolicy](https://learn.microsoft.com/powershell/module/teams/set-csteamsapppermissionpolicy) -* [CIS Microsoft 365 Foundations Benchmark v7.0.0 - Page 526](https://www.cisecurity.org/benchmark/microsoft_365) +* [Microsoft Teams admin center - Manage apps](https://admin.teams.microsoft.com/policies/manage-apps) +* [App centric management to manage user access to Teams apps](https://learn.microsoft.com/microsoftteams/app-centric-management) +* [Manage custom app policies and settings](https://learn.microsoft.com/microsoftteams/teams-custom-app-policies-and-settings) +* [Update-M365UnifiedTenantSettings](https://learn.microsoft.com/powershell/module/microsoftteams/update-m365unifiedtenantsettings) +* [CIS Microsoft 365 Foundations Benchmark v7.0.0 - 8.4.1](https://www.cisecurity.org/benchmark/microsoft_365) %TestResult% diff --git a/tests/cis/Test.CIS.M365.8.4.1.ps1 b/tests/cis/Test.CIS.M365.8.4.1.ps1 index 8263757b0c..b71467aea6 100644 --- a/tests/cis/Test.CIS.M365.8.4.1.ps1 +++ b/tests/cis/Test.CIS.M365.8.4.1.ps1 @@ -4,14 +4,14 @@ Ensure app permission policies are configured .DESCRIPTION - The Global (Org-wide default) app permission policy should block third-party and custom Teams apps, - either entirely or by allowing only an approved list. + The Teams org-wide app settings should not let users install and use third-party or custom apps by default, + and should not let users interact with custom apps in preview. CIS Microsoft 365 Foundations Benchmark v7.0.0 (8.4.1, L1) .EXAMPLE Test-MtCisThirdPartyAndCustomApps - Returns true if the Global app permission policy blocks third-party and custom apps + Returns true if the org-wide app settings turn off third-party apps, custom apps and custom apps in preview by default .LINK https://maester.dev/docs/commands/Test-MtCisThirdPartyAndCustomApps @@ -37,47 +37,41 @@ [OutputType([bool])] param() - Write-Verbose 'Test-MtCisThirdPartyAndCustomApps: Checking if all or a majority of third-party and custom apps are blocked' + Write-Verbose 'Test-MtCisThirdPartyAndCustomApps: Checking the Teams org-wide app settings' - $return = $true - $appPermPolicy = Get-CsTeamsAppPermissionPolicy -Identity Global + try { + $tenantSettings = @(Get-M365UnifiedTenantSettings -SettingNames GlobalApp, PrivateApp -ErrorAction Stop) + } catch { + if ($_.Exception.Message -match '(?i)(application[- ]based|app[- ]only|application authentication).{0,100}(not supported|unsupported)|(not supported|unsupported).{0,100}(application[- ]based|app[- ]only|application authentication)') { + Add-MtTestResultDetail -SkippedBecause NotSupportedAppPermission + return $null + } + throw + } + $customAppSetting = Get-CsTeamsSettingsCustomApp - $passResult = '✅ Pass' - $failResult = '❌ Fail' + $thirdParty = ($tenantSettings | Where-Object { $_.SettingName -eq 'GlobalApp' } | Select-Object -First 1).SettingValue + $custom = ($tenantSettings | Where-Object { $_.SettingName -eq 'PrivateApp' } | Select-Object -First 1).SettingValue + $preview = $customAppSetting.IsSideloadedAppsInteractionEnabled - $result = "| Policy | Value | Status |`n" - $result += "| --- | --- | --- |`n" + $checks = @( + [pscustomobject]@{ Setting = 'Third-party apps: Let users install and use available apps by default'; Value = $thirdParty; Pass = $thirdParty -eq 'None' } + [pscustomobject]@{ Setting = 'Custom apps: Let users install and use available apps by default'; Value = $custom; Pass = $custom -eq 'None' } + [pscustomobject]@{ Setting = 'Custom apps: Let users interact with custom apps in preview'; Value = $preview; Pass = $preview -eq $false } + ) + $return = @($checks | Where-Object { -not $_.Pass }).Count -eq 0 - if (($appPermPolicy.GlobalCatalogAppsType -eq 'BlockedAppList') -and (-not $appPermPolicy.GlobalCatalogApps)) { - # Third-party apps - $result += "| Third-party apps | Allow all apps | $failResult |`n" - $return = $false - } elseif (($appPermPolicy.GlobalCatalogAppsType -eq 'AllowedAppList') -and ($appPermPolicy.GlobalCatalogApps)) { - $result += "| Third-party apps | Allow specific apps and block all others | $passResult |`n" - } elseif (($appPermPolicy.GlobalCatalogAppsType -eq 'BlockedAppList') -and ($appPermPolicy.GlobalCatalogApps)) { - $result += "| Third-party apps | Block specific apps and allow all others | $failResult |`n" - $return = $false - } else { - $result += "| Third-party apps | Block all apps | $passResult |`n" - } - - if (($appPermPolicy.PrivateCatalogAppsType -eq 'BlockedAppList') -and (-not $appPermPolicy.PrivateCatalogApps)) { - # Custom apps - $result += "| Custom apps | Allow all apps | $failResult |`n" - $return = $false - } elseif (($appPermPolicy.PrivateCatalogAppsType -eq 'AllowedAppList') -and ($appPermPolicy.PrivateCatalogApps)) { - $result += "| Custom apps | Allow specific apps and block all others | $passResult |`n" - } elseif (($appPermPolicy.PrivateCatalogAppsType -eq 'BlockedAppList') -and ($appPermPolicy.PrivateCatalogApps)) { - $result += "| Custom apps | Block specific apps and allow all others | $failResult |`n" - $return = $false - } else { - $result += "| Custom apps | Block all apps | $passResult |`n" + $result = "| Setting | Value | Status |`n" + $result += "| --- | --- | --- |`n" + foreach ($check in $checks) { + $displayValue = if ($null -eq $check.Value) { 'Not found' } else { $check.Value } + $result += "| $($check.Setting) | $displayValue | $(if ($check.Pass) { '✅ Pass' } else { '❌ Fail' }) |`n" } if ($return) { - $testResultMarkdown = "Well done. All or a majority of third-party and custom apps are blocked.`n`n%TestResult%" + $testResultMarkdown = "Well done. Users can't install third-party or custom apps by default or interact with custom apps in preview.`n`n%TestResult%" } else { - $testResultMarkdown = "All or a majority of third-party or custom apps are allowed.`n`n%TestResult%" + $testResultMarkdown = "The org-wide app settings let users install third-party or custom apps by default, or interact with custom apps in preview.`n`n%TestResult%" } $testResultMarkdown = $testResultMarkdown -replace '%TestResult%', $result diff --git a/tests/cis/Test.CIS.M365.8.5.1.md b/tests/cis/Test.CIS.M365.8.5.1.md index 8380a82235..480eeb72a6 100644 --- a/tests/cis/Test.CIS.M365.8.5.1.md +++ b/tests/cis/Test.CIS.M365.8.5.1.md @@ -5,10 +5,9 @@ Turning off anonymous join keeps meetings limited to people who have signed in. #### Remediation action 1. Sign in to the [Microsoft Teams admin center](https://admin.teams.microsoft.com). -2. Go to **Meetings** > **Meeting policies**. -3. Open the **Global (Org-wide default)** policy. -4. Under **Anonymous users can join a meeting**, select **Off**. -5. Select **Save**. +2. Go to **Settings & policies** > [**Global (Org-wide default) settings**](https://admin.teams.microsoft.com/one-policy/settings) and select **Meetings**. +3. Under **Meeting join & lobby**, set **Anonymous users can join a meeting unverified** to **Off**. +4. Select **Save**. ##### PowerShell diff --git a/tests/cis/Test.CIS.M365.8.5.2.md b/tests/cis/Test.CIS.M365.8.5.2.md index 7dff08bb76..76b1a9ad2b 100644 --- a/tests/cis/Test.CIS.M365.8.5.2.md +++ b/tests/cis/Test.CIS.M365.8.5.2.md @@ -1,14 +1,13 @@ Anonymous users are people who join a meeting without signing in to Microsoft Teams, and dial-in callers join by phone. If either can start a meeting, it can begin without anyone from the organization present, so nobody who is responsible for the meeting is there to control it. -When the setting is off, anonymous users and dial-in callers wait in the lobby until someone from your organization, a guest, or a user from a trusted organization starts the meeting. The setting only has an effect when anonymous users can join meetings and **Who can bypass the lobby** is set to **Everyone**. +When the setting is off, anonymous users and dial-in callers wait in the lobby until someone from your organization, a guest, or a user from a trusted organization starts the meeting. The setting only has an effect when **Who can bypass the lobby** is set to **Everyone**. If anonymous users can't join meetings, it applies only to dial-in callers. #### Remediation action 1. Sign in to the [Microsoft Teams admin center](https://admin.teams.microsoft.com). -2. Go to **Meetings** > **Meeting policies**. -3. Open the **Global (Org-wide default)** policy. -4. Under **Anonymous users and dial-in callers can start a meeting**, select **Off**. -5. Select **Save**. +2. Go to **Settings & policies** > [**Global (Org-wide default) settings**](https://admin.teams.microsoft.com/one-policy/settings) and select **Meetings**. +3. Under **Meeting join & lobby**, set **Anonymous users and dial-in callers can start a meeting** to **Off**. +4. Select **Save**. ##### PowerShell diff --git a/tests/cis/Test.CIS.M365.8.5.3.md b/tests/cis/Test.CIS.M365.8.5.3.md index 37b2a3bacd..b7954b69e7 100644 --- a/tests/cis/Test.CIS.M365.8.5.3.md +++ b/tests/cis/Test.CIS.M365.8.5.3.md @@ -1,43 +1,35 @@ -8.5.3 (L1) Ensure only people in my org can bypass the lobby +Only invited people, people in your organization, or organizers and co-organizers can bypass the meeting lobby. -This policy setting controls who can join a meeting directly and who must wait in the lobby until they're admitted by an organizer, co-organizer, or presenter of the meeting. +The lobby lets an organizer, co-organizer or presenter see who is joining before admitting them. With **People who were invited** (`InvitedUsers`), invited external participants can bypass the lobby, including people who receive a forwarded invitation and invitees on a distribution list. People who have only the meeting link, but no invitation, and participants who are not signed in must wait in the lobby. Choose **People in my org** or **Only organizers and co-organizers** if invited external participants should also wait. -The recommended state is **People who were invited** or more restrictive. +This test checks only the Global meeting policy default; organizers can change **Who can bypass the lobby** in Meeting options. Phone dial-in callers use the separate **People dialing in can bypass the lobby** setting, which organizers can also change in Meeting options. When that setting is on, callers may bypass the lobby after the meeting starts even when this test passes. Review the dial-in setting separately. -#### Rationale - -For meetings that could contain sensitive information, it is best to allow the meeting organizer to vet anyone not directly sent an invite before admitting them to the meeting. This will also prevent the anonymous user from using the meeting link to have meetings at unscheduled times. - -#### Impact - -Individuals who are not part of the organization will have to wait in the lobby until they're admitted by an organizer, co-organizer, or presenter of the meeting. - -Any individual who dials into the meeting regardless of status will also have to wait in the lobby. This includes internal users who are considered unauthenticated when dialing in. +The test passes when **Who can bypass the lobby** in the Global (Org-wide default) meeting policy is **People who were invited** (`InvitedUsers`), **People in my org** (`EveryoneInCompanyExcludingGuests`) or **Only organizers and co-organizers** (`OrganizerOnly`). #### Remediation action -1. Navigate to [Microsoft Teams Admin Center](https://admin.teams.microsoft.com). -2. Select **Settings & policies** > **Global (Org-wide default) settings**. -3. Select **Meetings** to open the **meeting settings** section. -4. Under meeting join & lobby set **Who can bypass the lobby** to **People who were invited** or a more restrictive value: **People in my org, Only organizers and co-organizers**. +1. Sign in to the [Microsoft Teams admin center](https://admin.teams.microsoft.com). +2. Go to **Settings & policies** > [**Global (Org-wide default) settings**](https://admin.teams.microsoft.com/one-policy/settings) and select **Meetings**. +3. Under **Meeting join & lobby**, set **Who can bypass the lobby** to **People who were invited**, **People in my org** or **Only organizers and co-organizers**. +4. Select **Save**. ##### PowerShell 1. Connect to Teams PowerShell using `Connect-MicrosoftTeams`. -2. Run the following command to set the recommended state: +2. Run one of the following commands: ```powershell Set-CsTeamsMeetingPolicy -Identity Global -AutoAdmittedUsers "InvitedUsers" +Set-CsTeamsMeetingPolicy -Identity Global -AutoAdmittedUsers "EveryoneInCompanyExcludingGuests" +Set-CsTeamsMeetingPolicy -Identity Global -AutoAdmittedUsers "OrganizerOnly" ``` ->Note: More restrictive values EveryoneInCompanyExcludingGuests or OrganizerOnly are also in compliance. - #### Related links -* [Microsoft Teams Admin Center](https://admin.teams.microsoft.com). +* [Microsoft Teams admin center - Settings & policies](https://admin.teams.microsoft.com/one-policy/settings) * [Overview of lobby settings and policies](https://learn.microsoft.com/microsoftteams/who-can-bypass-meeting-lobby#overview-of-lobby-settings-and-policies) -* [Set-CsTeamsMeetingPolicy](https://learn.microsoft.com/powershell/module/microsoftteams/set-csteamsmeetingpolicy?view=teams-ps&viewFallbackFrom=skype-ps) -* [CIS Microsoft 365 Foundations Benchmark v7.0.0 - Page 535](https://www.cisecurity.org/benchmark/microsoft_365) +* [Set-CsTeamsMeetingPolicy](https://learn.microsoft.com/powershell/module/microsoftteams/set-csteamsmeetingpolicy) +* [CIS Microsoft 365 Foundations Benchmark v7.0.0 - 8.5.3](https://www.cisecurity.org/benchmark/microsoft_365) %TestResult% diff --git a/tests/cis/Test.CIS.M365.8.5.4.md b/tests/cis/Test.CIS.M365.8.5.4.md index 78c8d30414..479efae570 100644 --- a/tests/cis/Test.CIS.M365.8.5.4.md +++ b/tests/cis/Test.CIS.M365.8.5.4.md @@ -5,10 +5,9 @@ Requiring dial-in callers to wait in the lobby means the organizer or a presente #### Remediation action 1. Sign in to the [Microsoft Teams admin center](https://admin.teams.microsoft.com). -2. Go to **Meetings** > **Meeting policies**. -3. Open the **Global (Org-wide default)** policy. -4. Under **People dialing in can bypass the lobby**, select **Off**. -5. Select **Save**. +2. Go to **Settings & policies** > [**Global (Org-wide default) settings**](https://admin.teams.microsoft.com/one-policy/settings) and select **Meetings**. +3. Under **Meeting join & lobby**, set **People dialing in can bypass the lobby** to **Off**. +4. Select **Save**. ##### PowerShell diff --git a/tests/cis/Test.CIS.M365.8.5.5.md b/tests/cis/Test.CIS.M365.8.5.5.md index 8d3fafe270..98a2247876 100644 --- a/tests/cis/Test.CIS.M365.8.5.5.md +++ b/tests/cis/Test.CIS.M365.8.5.5.md @@ -5,10 +5,9 @@ Limiting meeting chat to signed-in participants keeps the chat to people whose i #### Remediation action 1. Sign in to the [Microsoft Teams admin center](https://admin.teams.microsoft.com). -2. Go to **Meetings** > **Meeting policies**. -3. Open the **Global (Org-wide default)** policy. -4. Under **Meeting chat**, select **On for everyone but anonymous users** or **Off**. -5. Select **Save**. +2. Go to **Settings & policies** > [**Global (Org-wide default) settings**](https://admin.teams.microsoft.com/one-policy/settings) and select **Meetings**. +3. Under **Meeting engagement**, set **Meeting chat** to **On for everyone but anonymous users**, or to the more restrictive **In-meeting only except anonymous** or **Off**. +4. Select **Save**. ##### PowerShell diff --git a/tests/cis/Test.CIS.M365.8.5.6.md b/tests/cis/Test.CIS.M365.8.5.6.md index 6718e28549..f47802fc52 100644 --- a/tests/cis/Test.CIS.M365.8.5.6.md +++ b/tests/cis/Test.CIS.M365.8.5.6.md @@ -5,10 +5,9 @@ Limiting the presenter role to organizers and co-organizers keeps control of sha #### Remediation action 1. Sign in to the [Microsoft Teams admin center](https://admin.teams.microsoft.com). -2. Go to **Meetings** > **Meeting policies**. -3. Open the **Global (Org-wide default)** policy. -4. Under **Who can present**, select **Only organizers and co-organizers**. -5. Select **Save**. +2. Go to **Settings & policies** > [**Global (Org-wide default) settings**](https://admin.teams.microsoft.com/one-policy/settings) and select **Meetings**. +3. Under **Content sharing**, set **Who can present** to **Only organizers and co-organizers**. +4. Select **Save**. ##### PowerShell diff --git a/tests/cis/Test.CIS.M365.8.5.7.md b/tests/cis/Test.CIS.M365.8.5.7.md index 214d702890..afb7cad3ab 100644 --- a/tests/cis/Test.CIS.M365.8.5.7.md +++ b/tests/cis/Test.CIS.M365.8.5.7.md @@ -5,10 +5,9 @@ Turning this off means external participants can't give or request control of sh #### Remediation action 1. Sign in to the [Microsoft Teams admin center](https://admin.teams.microsoft.com). -2. Go to **Meetings** > **Meeting policies**. -3. Open the **Global (Org-wide default)** policy. -4. Under **External participants can give or request control**, select **Off**. -5. Select **Save**. +2. Go to **Settings & policies** > [**Global (Org-wide default) settings**](https://admin.teams.microsoft.com/one-policy/settings) and select **Meetings**. +3. Under **Content sharing**, set **External participants can give or request control** to **Off**. +4. Select **Save**. ##### PowerShell diff --git a/tests/cis/Test.CIS.M365.8.5.8.md b/tests/cis/Test.CIS.M365.8.5.8.md index 60d8f9a834..9c097a5302 100644 --- a/tests/cis/Test.CIS.M365.8.5.8.md +++ b/tests/cis/Test.CIS.M365.8.5.8.md @@ -5,10 +5,9 @@ Turning this off keeps your users out of the chat in meetings hosted by untruste #### Remediation action 1. Sign in to the [Microsoft Teams admin center](https://admin.teams.microsoft.com). -2. Go to **Meetings** > **Meeting policies**. -3. Open the **Global (Org-wide default)** policy. -4. Under **External meeting chat**, select **Off**. -5. Select **Save**. +2. Go to **Settings & policies** > [**Global (Org-wide default) settings**](https://admin.teams.microsoft.com/one-policy/settings) and select **Meetings**. +3. Under **Meeting engagement**, set **External meeting chat** to **Off**. +4. Select **Save**. ##### PowerShell diff --git a/tests/cis/Test.CIS.M365.8.5.9.md b/tests/cis/Test.CIS.M365.8.5.9.md index 7cc08a2a52..fa55147930 100644 --- a/tests/cis/Test.CIS.M365.8.5.9.md +++ b/tests/cis/Test.CIS.M365.8.5.9.md @@ -5,10 +5,9 @@ Turning meeting recording off in the Global policy means nobody who has that pol #### Remediation action 1. Sign in to the [Microsoft Teams admin center](https://admin.teams.microsoft.com). -2. Go to **Meetings** > **Meeting policies**. -3. Open the **Global (Org-wide default)** policy. -4. Under **Recording**, turn off **Meeting recording**. -5. Select **Save**. +2. Go to **Settings & policies** > [**Global (Org-wide default) settings**](https://admin.teams.microsoft.com/one-policy/settings) and select **Meetings**. +3. Under **Recording & transcription**, set **Meeting recording** to **Off**. +4. Select **Save**. ##### PowerShell diff --git a/tests/cis/Test.CIS.M365.8.6.1.md b/tests/cis/Test.CIS.M365.8.6.1.md index 4c23afa7bd..9796ea9d0a 100644 --- a/tests/cis/Test.CIS.M365.8.6.1.md +++ b/tests/cis/Test.CIS.M365.8.6.1.md @@ -1,49 +1,29 @@ -8.6.1 (L1) Ensure users can report security concerns in Teams +Users can report security concerns in Microsoft Teams, and reported items go only to the organization's reporting mailbox. -User reporting settings allow a user to report a message as malicious for further analysis. This recommendation is composed of 3 different settings and all be configured to pass: +User reporting lets people flag suspicious Teams messages quickly, so the security team can act on phishing and malicious content. Reported items can contain sensitive or personal information, and reports can include messages that are threatening or harassing, so they should stay inside the organization and be reviewed by staff who can route them to the right team, such as Human Resources. Sending reports to Microsoft should follow company policy. -* **In the Teams admin center:** On by default and controls whether users are able to report messages from Teams. When this setting is turned off, users can't report messages within Teams, so the corresponding setting in the Microsoft 365 Defender portal is irrelevant. -* **In the Microsoft 365 Defender portal:** On by default for new tenants. Existing tenants need to enable it. If user reporting of messages is turned on in the Teams admin center, it also needs to be turned on the Defender portal for user reported messages to show up correctly on the User reported tab on the Submissions page. -* **Defender - Report message destinations:** This applies to more than just Microsoft Teams and allows for an organization to keep their reports contained. Due to how the parameters are configured on the backend it is included in this assessment as a requirement. - -#### Rationale - -Users will be able to more quickly and systematically alert administrators of suspicious malicious messages within Teams. The content of these messages may be sensitive in nature and therefore should be kept within the organization and not shared with Microsoft without first consulting company policy. - ->Note -> ->* The reported message remains visible to the user in the Teams client. ->* Users can report the same message multiple times. ->* The message sender isn't notified that messages were reported. - -#### Impact - -Enabling message reporting has an impact beyond just addressing security concerns. When users of the platform report a message, the content could include messages that are threatening or harassing in nature, possibly stemming from colleagues. -Due to this the security staff responsible for reviewing and acting on these reports should be equipped with the skills to discern and appropriately direct such messages to the relevant departments, such as Human Resources (HR). +CIS requires **Report a security concern** in the Teams Global messaging policy, **Monitor reported items in Microsoft Teams** in the Microsoft Defender portal, and reported items sent to **My reporting mailbox only**. The test reads `Get-CsTeamsMessagingPolicy -Identity Global` and the report submission policy. Reporting must be on, Teams and email reports must go to the same reporting mailbox and not to Microsoft (`ReportChatMessageEnabled` and `EnableReportToMicrosoft` are `False`). Microsoft Defender for Office 365 Plan 1 or Plan 2, or Microsoft Defender XDR, licences are required. #### Remediation action -1. Navigate to [Microsoft Teams Admin Center](https://admin.teams.microsoft.com). -2. Select **Settings & policies** > **Global (Org-wide default) settings**. -3. Select **Messaging** to open the **messaging settings** section. -4. Set **Report a security concern** to **On**. -5. Next, navigate to [Microsoft 365 Defender](https://security.microsoft.com). -6. Click on **Settings** > **Email & collaboration** > **User reported settings**. -7. Scroll to **Microsoft Teams**. -8. Check **Monitor reported messages in Microsoft Teams** and **Save**. -9. Set **Send reported messages to:** to **My reporting mailbox only** with reports configured to be sent to authorized staff. +1. Sign in to the [Microsoft Teams admin center](https://admin.teams.microsoft.com). +2. Go to **Settings & policies** > [**Global (Org-wide default) settings**](https://admin.teams.microsoft.com/one-policy/settings) and select **Messaging**. +3. Set **Report a security concern** to **On** and select **Save**. +4. Sign in to the [Microsoft Defender portal](https://security.microsoft.com). +5. Go to **System** > **Settings** > **Email & collaboration** > [**Teams user reported settings**](https://security.microsoft.com/securitysettings/teamsUserSubmission). +6. Under **Microsoft Teams**, select **Monitor reported items in Microsoft Teams**, set **Send reported items to** to **My reporting mailbox only**, add the reporting mailbox for authorized staff and select **Save**. +7. Go to [**User reported settings**](https://security.microsoft.com/securitysettings/userSubmission), set **Send reported items to** to **My reporting mailbox only** with the same reporting mailbox and select **Save**. ##### PowerShell -1. Connect to Teams PowerShell using `Connect-MicrosoftTeams`. -2. Connect to Exchange Online PowerShell using `Connect-ExchangeOnline`. -3. Run the following cmdlet: +1. Connect to Teams PowerShell using `Connect-MicrosoftTeams` and to Exchange Online PowerShell using `Connect-ExchangeOnline`. +2. Run the following command: ```powershell Set-CsTeamsMessagingPolicy -Identity Global -AllowSecurityEndUserReporting $true ``` -1. To configure the Defender reporting policies, edit and run this script: +3. Change the reporting mailbox in the following script and run it: ```powershell $usersub = "userreportedmessages@fabrikam.com" # Change this. @@ -52,6 +32,7 @@ $params = @{ EnableReportToMicrosoft = $false ReportChatMessageEnabled = $false ReportChatMessageToCustomizedAddressEnabled = $true + ReportChatMessageAddresses = $usersub ReportJunkToCustomizedAddress = $true ReportNotJunkToCustomizedAddress = $true ReportPhishToCustomizedAddress = $true @@ -60,16 +41,19 @@ $params = @{ ReportPhishAddresses = $usersub } Set-ReportSubmissionPolicy @params -New-ReportSubmissionRule -Name DefaultReportSubmissionRule -ReportSubmissionPolicy DefaultReportSubmissionPolicy -SentTo $usersub +if (-not (Get-ReportSubmissionRule)) { + New-ReportSubmissionRule -Name DefaultReportSubmissionRule -ReportSubmissionPolicy DefaultReportSubmissionPolicy -SentTo $usersub +} ``` #### Related links -* [Microsoft Teams Admin Center](https://admin.teams.microsoft.com) -* [Microsoft 365 Defender](https://security.microsoft.com) -* [User reported settings in Microsoft Teams](https://learn.microsoft.com/defender-office-365/submissions-teams?view=o365-worldwide) -* [CIS Microsoft 365 Foundations Benchmark v7.0.0 - Page 554](https://www.cisecurity.org/benchmark/microsoft_365) +* [Microsoft Teams admin center - Settings & policies](https://admin.teams.microsoft.com/one-policy/settings) +* [Microsoft Defender portal - Teams user reported settings](https://security.microsoft.com/securitysettings/teamsUserSubmission) +* [User reported settings in Teams](https://learn.microsoft.com/defender-office-365/submissions-teams) +* [Configure user reported message settings](https://learn.microsoft.com/defender-office-365/submissions-user-reported-messages-custom-mailbox) +* [CIS Microsoft 365 Foundations Benchmark v7.0.0 - 8.6.1](https://www.cisecurity.org/benchmark/microsoft_365) %TestResult% diff --git a/tests/cis/Test.CIS.M365.8.6.1.ps1 b/tests/cis/Test.CIS.M365.8.6.1.ps1 index b36a6b56da..880a39232b 100644 --- a/tests/cis/Test.CIS.M365.8.6.1.ps1 +++ b/tests/cis/Test.CIS.M365.8.6.1.ps1 @@ -4,13 +4,14 @@ Ensure users can report security concerns in Teams .DESCRIPTION - Ensures users can report security concerns in Teams, with reports directed only to an internal destination. + Checks that users can report security concerns in Teams and that configured report destinations use + the organization's reporting mailbox. CIS Microsoft 365 Foundations Benchmark v7.0.0 (8.6.1, E5 L1) .EXAMPLE Test-MtCisTeamsReportSecurityConcerns - Returns true if configured properly + Returns true if users can report security concerns in Teams and reports go only to the reporting mailbox .LINK https://maester.dev/docs/commands/Test-MtCisTeamsReportSecurityConcerns @@ -27,8 +28,9 @@ UserImpact = 'Low', ImplementationCost = 'Low', Mitre = 'T1566', - Control = 'cis-m365:8.6.1', + Control = ('cis-m365:8.6.1', 'nist-800-53-r5:IR-6'), Service = ('Teams', 'ExchangeOnline'), + License = ('ATP_ENTERPRISE', 'DEFENDER_XDR'), Author = 'HenrikPiecha', Contributor = 'merill' )] @@ -39,75 +41,69 @@ Write-Verbose 'Test-MtCisTeamsReportSecurityConcerns: Checking if users can report security concerns in Teams to internal destination' - $return = $true - $MicrosoftTeamsCheck = Get-CsTeamsMessagingPolicy -Identity Global | Select-Object AllowSecurityEndUserReporting - $MicrosoftReportPolicy = Get-ReportSubmissionPolicy | Select-Object ReportJunkToCustomizedAddress, ReportNotJunkToCustomizedAddress, ReportPhishToCustomizedAddress, ReportJunkAddresses, ReportNotJunkAddresses, ReportPhishAddresses, ReportChatMessageEnabled, ReportChatMessageToCustomizedAddressEnabled - - $passResult = '✅ Pass' - $failResult = '❌ Fail' - - $result = "| Policy | Value | Status |`n" - $result += "| --- | --- | --- |`n" - - if ($MicrosoftTeamsCheck.AllowSecurityEndUserReporting -eq $false) { - $result += "| AllowSecurityEndUserReporting | $($MicrosoftTeamsCheck.AllowSecurityEndUserReporting) | $failResult |`n" - $return = $false - } else { - $result += "| AllowSecurityEndUserReporting | $($MicrosoftTeamsCheck.AllowSecurityEndUserReporting) | $passResult |`n" + $messagingPolicy = Get-CsTeamsMessagingPolicy -Identity Global + $reportPolicy = @(Get-MtExo -Request ReportSubmissionPolicy) | Select-Object -First 1 + $destinationValues = [ordered]@{ + ReportJunkAddresses = @($reportPolicy.ReportJunkAddresses) + ReportNotJunkAddresses = @($reportPolicy.ReportNotJunkAddresses) + ReportPhishAddresses = @($reportPolicy.ReportPhishAddresses) + ReportChatMessageAddresses = @($reportPolicy.ReportChatMessageAddresses) } - if ($MicrosoftReportPolicy.ReportJunkToCustomizedAddress -eq $false) { - $result += "| ReportJunkToCustomizedAddress | $($MicrosoftReportPolicy.ReportJunkToCustomizedAddress) | $failResult |`n" - $return = $false - } else { - $result += "| ReportJunkToCustomizedAddress | $($MicrosoftReportPolicy.ReportJunkToCustomizedAddress) | $passResult |`n" + $reportingMailbox = @( + $destinationValues.Values | + ForEach-Object { $_ } | + Where-Object { -not [string]::IsNullOrWhiteSpace("$($_)") } | + Select-Object -First 1 + )[0] + $normalizedMailbox = if ($reportingMailbox) { "$reportingMailbox".Trim().ToLowerInvariant() } else { $null } + $destinationChecks = foreach ($destination in $destinationValues.GetEnumerator()) { + $addresses = @( + $destination.Value | + Where-Object { -not [string]::IsNullOrWhiteSpace("$($_)") } | + ForEach-Object { "$_".Trim().ToLowerInvariant() } | + Sort-Object -Unique + ) + $displayAddresses = @( + $destination.Value | + Where-Object { -not [string]::IsNullOrWhiteSpace("$($_)") } | + ForEach-Object { "$_".Trim() } | + Sort-Object -Unique + ) + [pscustomobject]@{ + Setting = $destination.Key + Value = $displayAddresses -join ', ' + Expected = if ($reportingMailbox) { $reportingMailbox } else { 'One reporting mailbox' } + Pass = $null -ne $normalizedMailbox -and $addresses.Count -eq 1 -and $addresses[0] -eq $normalizedMailbox + } } + $teamsAddressCheck = $destinationChecks | Where-Object { $_.Setting -eq 'ReportChatMessageAddresses' } - if ($MicrosoftReportPolicy.ReportNotJunkToCustomizedAddress -eq $false) { - $result += "| ReportNotJunkToCustomizedAddress | $($MicrosoftReportPolicy.ReportNotJunkToCustomizedAddress) | $failResult |`n" - $return = $false - } else { - $result += "| ReportNotJunkToCustomizedAddress | $($MicrosoftReportPolicy.ReportNotJunkToCustomizedAddress) | $passResult |`n" - } - if ($MicrosoftReportPolicy.ReportPhishToCustomizedAddress -eq $false) { - $result += "| ReportPhishToCustomizedAddress | $($MicrosoftReportPolicy.ReportPhishToCustomizedAddress) | $failResult |`n" - $return = $false - } else { - $result += "| ReportPhishToCustomizedAddress | $($MicrosoftReportPolicy.ReportPhishToCustomizedAddress) | $passResult |`n" - } - if ([string]::IsNullOrEmpty($MicrosoftReportPolicy.ReportJunkAddresses)) { - $result += "| ReportJunkAddresses | NULL | $failResult |`n" - $return = $false - } else { - $result += "| ReportJunkAddresses | $($MicrosoftReportPolicy.ReportJunkAddresses) | $passResult |`n" - } - if ([string]::IsNullOrEmpty($MicrosoftReportPolicy.ReportNotJunkAddresses)) { - $result += "| ReportNotJunkAddresses | NULL | $failResult |`n" - $return = $false - } else { - $result += "| ReportNotJunkAddresses | $($MicrosoftReportPolicy.ReportNotJunkAddresses) | $passResult |`n" - } - if ([string]::IsNullOrEmpty($MicrosoftReportPolicy.ReportPhishAddresses)) { - $result += "| ReportPhishAddresses | NULL | $failResult |`n" - $return = $false - } else { - $result += "| ReportPhishAddresses | $($MicrosoftReportPolicy.ReportPhishAddresses) | $passResult |`n" - } - if ($MicrosoftReportPolicy.ReportChatMessageEnabled -eq $true) { - $result += "| ReportChatMessageEnabled | $($MicrosoftReportPolicy.ReportChatMessageEnabled) | $failResult |`n" - $return = $false - } else { - $result += "| ReportChatMessageEnabled | $($MicrosoftReportPolicy.ReportChatMessageEnabled) | $passResult |`n" - } - if ($MicrosoftReportPolicy.ReportChatMessageToCustomizedAddressEnabled -eq $false) { - $result += "| ReportChatMessageToCustomizedAddressEnabled | $($MicrosoftReportPolicy.ReportChatMessageToCustomizedAddressEnabled) | $failResult |`n" - $return = $false - } else { - $result += "| ReportChatMessageToCustomizedAddressEnabled | $($MicrosoftReportPolicy.ReportChatMessageToCustomizedAddressEnabled) | $passResult |`n" + $checks = @( + [pscustomobject]@{ Setting = 'AllowSecurityEndUserReporting (Teams Global messaging policy)'; Value = $messagingPolicy.AllowSecurityEndUserReporting; Expected = 'True'; Pass = $messagingPolicy.AllowSecurityEndUserReporting -eq $true } + [pscustomobject]@{ Setting = 'ReportChatMessageEnabled'; Value = $reportPolicy.ReportChatMessageEnabled; Expected = 'False'; Pass = $reportPolicy.ReportChatMessageEnabled -eq $false } + [pscustomobject]@{ Setting = 'ReportChatMessageToCustomizedAddressEnabled'; Value = $reportPolicy.ReportChatMessageToCustomizedAddressEnabled; Expected = 'True'; Pass = $reportPolicy.ReportChatMessageToCustomizedAddressEnabled -eq $true -and $teamsAddressCheck.Pass } + [pscustomobject]@{ Setting = 'EnableReportToMicrosoft'; Value = $reportPolicy.EnableReportToMicrosoft; Expected = 'False'; Pass = $reportPolicy.EnableReportToMicrosoft -eq $false } + [pscustomobject]@{ Setting = 'ReportJunkToCustomizedAddress'; Value = $reportPolicy.ReportJunkToCustomizedAddress; Expected = 'True'; Pass = $reportPolicy.ReportJunkToCustomizedAddress -eq $true } + [pscustomobject]@{ Setting = 'ReportNotJunkToCustomizedAddress'; Value = $reportPolicy.ReportNotJunkToCustomizedAddress; Expected = 'True'; Pass = $reportPolicy.ReportNotJunkToCustomizedAddress -eq $true } + [pscustomobject]@{ Setting = 'ReportPhishToCustomizedAddress'; Value = $reportPolicy.ReportPhishToCustomizedAddress; Expected = 'True'; Pass = $reportPolicy.ReportPhishToCustomizedAddress -eq $true } + ) + @($destinationChecks) + $return = $null -ne $messagingPolicy -and $null -ne $reportPolicy -and @($checks | Where-Object { -not $_.Pass }).Count -eq 0 + + $result = "| Setting | Value | Expected | Status |`n" + $result += "| --- | --- | --- | --- |`n" + foreach ($check in $checks) { + $displayValue = if ($null -eq $check.Value -or "$($check.Value)" -eq '') { 'Not set' } else { $check.Value } + $safeValue = Get-MtSafeMarkdown -Text "$displayValue" + $safeExpected = Get-MtSafeMarkdown -Text "$($check.Expected)" + $result += "| $($check.Setting) | $safeValue | $safeExpected | $(if ($check.Pass) { '✅ Pass' } else { '❌ Fail' }) |`n" } + if ($return) { - $testResultMarkdown = "Well done. All report submission policies are configured properly.`n`n%TestResult%" + $testResultMarkdown = "Well done. Users can report security concerns in Teams, and reports go only to your reporting mailbox.`n`n%TestResult%" + } elseif ($null -eq $reportPolicy) { + $testResultMarkdown = "No report submission policy was returned, so the reporting destination could not be confirmed. Configure the user reported settings in the Microsoft Defender portal.`n`n%TestResult%" } else { - $testResultMarkdown = "All or specific report submission policies are missing proper configuration.`n`n%TestResult%" + $testResultMarkdown = "Users can't report security concerns in Teams, or reports are not sent only to your reporting mailbox.`n`n%TestResult%" } $testResultMarkdown = $testResultMarkdown -replace '%TestResult%', $result diff --git a/website/scripts/generate-test-docs.mjs b/website/scripts/generate-test-docs.mjs index f3cbbdf6f3..83e40b57d3 100644 --- a/website/scripts/generate-test-docs.mjs +++ b/website/scripts/generate-test-docs.mjs @@ -75,8 +75,11 @@ const suiteConfig = { title: "CIS Benchmark Tests", sidebarLabel: "🌀 CIS", description: "CIS Benchmark controls implemented as Maester tests.", - overview: - "These tests verify tenant and organization configuration against CIS Benchmark recommendations.", + overview: `These tests verify tenant and organization configuration against CIS Benchmark recommendations. + +The CIS Microsoft 365 Foundations Benchmark v7.0.0 designates the following recommendations for manual assessment. Complete these assessments in addition to running Maester's automated checks. Although CIS marks 8.4.1 manual, Maester includes an automated check for it. + +**Manual assessment recommendation IDs:** 1.1.2, 1.3.8, 2.2.1, 2.4.3, 2.4.5, 5.1.2.1, 5.1.2.4, 5.1.2.5, 5.1.2.6, 5.1.3.2, 5.1.3.3, 5.2.4.1, 5.2.4.2, 5.2.4.3, 5.2.4.4, 5.2.4.5, 8.4.1.`, }, orca: { label: "ORCA",