From 2f71159c06304001ad8b4b42e001d7cc622c9de3 Mon Sep 17 00:00:00 2001 From: Merill Fernando Date: Tue, 10 Nov 2026 07:36:31 +1100 Subject: [PATCH 01/19] feat(disa): add DISA STIG frameworks for Entra ID and Intune with 19 checks (#2739) Add a DISA suite (tests/disa, IDs DISA.V-xxxxxx named after the STIG rule) with three framework catalogues: disa-stig-entra-id (V1R2), disa-stig-intune-mdm (V1R2) and disa-stig-intune-desktop (V1R1). Each lists every rule of its STIG with Category (CAT I-III), RuleId, StigId and the NIST SP 800-53 Rev. 5 controls of its CCIs as Related. Checks: - New (Preview): DISA.V-273867 idle session timeout in minutes, DISA.V-270204 inactive accounts for all users, DISA.V-270209 DoD sign-in banner, DISA.V-270239 maximum password lifetime, DISA.V-270255 PIM activation alert recipients on every assigned role. - Shims: 14 rules run CIS 5.2.2.2, 5.2.3.2, 5.2.3.8, CISA MS.AAD.4.1, 7.4, MT.1096, MT.1100 or one of the new checks, with DISA's values. - Six Intune Desktop rules (acknowledged banner, ISSO account alerts) have no check. Parameters for the shims: CIS 5.2.3.8 MinimumLockoutDurationSeconds (default 0, CIS unchanged), CISA MS.AAD.4.1 RequiredLogCategory (default CISA's list), MT.1096 RequiredPolicyType (default any). Shared Entra helpers in internal/services/entra: Get-MtActivityBasedTimeout (CIS 1.3.2), Get-MtUserLastSignIn (ASD ISM-1648), Get-MtDomainPasswordValidity (CIS 1.3.1) and Get-MtRoleActivationNotificationRecipient (CISA 7.8/7.9). Register the suite and the DISA. prefix in the schema, pack tags, layout, lint, source and framework unit tests, the report labels, the website generators, sidebar and home page, and the docs. Regenerate the test builder data and the 2.x golden selection fixture. Refs #2738 Entire-Checkpoint: 01M6YVDH5BDHSCP1YTPFF5BXZF Co-authored-by: Claude Opus 5.5 --- .github/skills/maester-test-expert/SKILL.md | 4 +- AGENTS.md | 11 +- powershell/assets/MaesterTestSchema.psd1 | 2 +- .../Test-MtCisaActivationNotification.ps1 | 17 +- .../internal/packs/Test-MtPackContent.ps1 | 2 +- .../entra/Get-MtActivityBasedTimeout.ps1 | 40 +++ .../entra/Get-MtDomainPasswordValidity.ps1 | 37 +++ ...-MtRoleActivationNotificationRecipient.ps1 | 34 +++ .../services/entra/Get-MtUserLastSignIn.ps1 | 37 +++ powershell/public/run/Invoke-Maester.ps1 | 2 +- .../tests/fixtures/golden/selection.json | 111 +++++++- .../tests/functions/DisaChecks.Tests.ps1 | 151 ++++++++++ .../functions/engine/Frameworks.Tests.ps1 | 17 +- .../engine/Resolve-MtTestSource.Tests.ps1 | 2 +- .../general/NativeTestAttributes.Tests.ps1 | 4 +- .../tests/general/NativeTestLint.Tests.ps1 | 4 +- .../tests/general/RepositoryLayout.Tests.ps1 | 2 +- report/src/lib/model.ts | 5 +- report/src/pages/report/FrameworkPage.tsx | 7 +- tests/asd/entra/Test.ASD.ISM-1648.ps1 | 3 +- tests/cis/Test.CIS.M365.1.3.1.ps1 | 39 +-- tests/cis/Test.CIS.M365.1.3.2.ps1 | 11 +- tests/cis/Test.CIS.M365.5.2.3.8.ps1 | 31 +- tests/cisa/entra/Test.CISA.MS.AAD.4.1.ps1 | 11 +- tests/disa/README.md | 55 ++++ tests/disa/Test.DISA.V-267303.md | 19 ++ tests/disa/Test.DISA.V-267303.ps1 | 45 +++ tests/disa/Test.DISA.V-267309.md | 18 ++ tests/disa/Test.DISA.V-267309.ps1 | 45 +++ tests/disa/Test.DISA.V-267314.md | 19 ++ tests/disa/Test.DISA.V-267314.ps1 | 47 ++++ tests/disa/Test.DISA.V-267334.md | 20 ++ tests/disa/Test.DISA.V-267334.ps1 | 40 +++ tests/disa/Test.DISA.V-267341.md | 20 ++ tests/disa/Test.DISA.V-267341.ps1 | 40 +++ tests/disa/Test.DISA.V-267355.md | 18 ++ tests/disa/Test.DISA.V-267355.ps1 | 45 +++ tests/disa/Test.DISA.V-270200.md | 20 ++ tests/disa/Test.DISA.V-270200.ps1 | 45 +++ tests/disa/Test.DISA.V-270204.md | 22 ++ tests/disa/Test.DISA.V-270204.ps1 | 81 ++++++ tests/disa/Test.DISA.V-270208.md | 19 ++ tests/disa/Test.DISA.V-270208.ps1 | 47 ++++ tests/disa/Test.DISA.V-270209.md | 22 ++ tests/disa/Test.DISA.V-270209.ps1 | 82 ++++++ tests/disa/Test.DISA.V-270227.md | 20 ++ tests/disa/Test.DISA.V-270227.ps1 | 43 +++ tests/disa/Test.DISA.V-270233.md | 20 ++ tests/disa/Test.DISA.V-270233.ps1 | 40 +++ tests/disa/Test.DISA.V-270239.md | 23 ++ tests/disa/Test.DISA.V-270239.ps1 | 80 ++++++ tests/disa/Test.DISA.V-270255.md | 20 ++ tests/disa/Test.DISA.V-270255.ps1 | 100 +++++++ tests/disa/Test.DISA.V-270335.md | 19 ++ tests/disa/Test.DISA.V-270335.ps1 | 40 +++ tests/disa/Test.DISA.V-270475.md | 19 ++ tests/disa/Test.DISA.V-270475.ps1 | 40 +++ tests/disa/Test.DISA.V-273867.md | 20 ++ tests/disa/Test.DISA.V-273867.ps1 | 68 +++++ tests/disa/Test.DISA.V-273868.md | 20 ++ tests/disa/Test.DISA.V-273868.ps1 | 40 +++ tests/disa/Test.DISA.V-285327.md | 20 ++ tests/disa/Test.DISA.V-285327.ps1 | 43 +++ tests/disa/frameworks/disa-stig-entra-id.json | 103 +++++++ .../frameworks/disa-stig-intune-desktop.json | 121 ++++++++ .../disa/frameworks/disa-stig-intune-mdm.json | 39 +++ tests/disa/suite.json | 16 ++ tests/maester/intune/Test.MT.1096.ps1 | 45 ++- website/astro.config.mjs | 1 + .../docs/configuration/run-configuration.md | 2 +- website/docs/contributing.md | 4 +- website/docs/result-schema.md | 2 +- .../docs/writing-tests/attribute-rubric.md | 2 +- .../docs/writing-tests/first-custom-test.md | 2 +- website/docs/writing-tests/index.mdx | 6 +- website/scripts/catalog-explorer.mjs | 3 + website/scripts/generate-test-docs.mjs | 10 +- website/src/components/catalog/data.ts | 1 + .../src/components/overrides/PageTitle.astro | 2 +- website/src/data/test-builder.json | 264 +++++++++++++++++- website/src/pages/index.astro | 1 + 81 files changed, 2532 insertions(+), 120 deletions(-) create mode 100644 powershell/internal/services/entra/Get-MtActivityBasedTimeout.ps1 create mode 100644 powershell/internal/services/entra/Get-MtDomainPasswordValidity.ps1 create mode 100644 powershell/internal/services/entra/Get-MtRoleActivationNotificationRecipient.ps1 create mode 100644 powershell/internal/services/entra/Get-MtUserLastSignIn.ps1 create mode 100644 powershell/tests/functions/DisaChecks.Tests.ps1 create mode 100644 tests/disa/README.md create mode 100644 tests/disa/Test.DISA.V-267303.md create mode 100644 tests/disa/Test.DISA.V-267303.ps1 create mode 100644 tests/disa/Test.DISA.V-267309.md create mode 100644 tests/disa/Test.DISA.V-267309.ps1 create mode 100644 tests/disa/Test.DISA.V-267314.md create mode 100644 tests/disa/Test.DISA.V-267314.ps1 create mode 100644 tests/disa/Test.DISA.V-267334.md create mode 100644 tests/disa/Test.DISA.V-267334.ps1 create mode 100644 tests/disa/Test.DISA.V-267341.md create mode 100644 tests/disa/Test.DISA.V-267341.ps1 create mode 100644 tests/disa/Test.DISA.V-267355.md create mode 100644 tests/disa/Test.DISA.V-267355.ps1 create mode 100644 tests/disa/Test.DISA.V-270200.md create mode 100644 tests/disa/Test.DISA.V-270200.ps1 create mode 100644 tests/disa/Test.DISA.V-270204.md create mode 100644 tests/disa/Test.DISA.V-270204.ps1 create mode 100644 tests/disa/Test.DISA.V-270208.md create mode 100644 tests/disa/Test.DISA.V-270208.ps1 create mode 100644 tests/disa/Test.DISA.V-270209.md create mode 100644 tests/disa/Test.DISA.V-270209.ps1 create mode 100644 tests/disa/Test.DISA.V-270227.md create mode 100644 tests/disa/Test.DISA.V-270227.ps1 create mode 100644 tests/disa/Test.DISA.V-270233.md create mode 100644 tests/disa/Test.DISA.V-270233.ps1 create mode 100644 tests/disa/Test.DISA.V-270239.md create mode 100644 tests/disa/Test.DISA.V-270239.ps1 create mode 100644 tests/disa/Test.DISA.V-270255.md create mode 100644 tests/disa/Test.DISA.V-270255.ps1 create mode 100644 tests/disa/Test.DISA.V-270335.md create mode 100644 tests/disa/Test.DISA.V-270335.ps1 create mode 100644 tests/disa/Test.DISA.V-270475.md create mode 100644 tests/disa/Test.DISA.V-270475.ps1 create mode 100644 tests/disa/Test.DISA.V-273867.md create mode 100644 tests/disa/Test.DISA.V-273867.ps1 create mode 100644 tests/disa/Test.DISA.V-273868.md create mode 100644 tests/disa/Test.DISA.V-273868.ps1 create mode 100644 tests/disa/Test.DISA.V-285327.md create mode 100644 tests/disa/Test.DISA.V-285327.ps1 create mode 100644 tests/disa/frameworks/disa-stig-entra-id.json create mode 100644 tests/disa/frameworks/disa-stig-intune-desktop.json create mode 100644 tests/disa/frameworks/disa-stig-intune-mdm.json create mode 100644 tests/disa/suite.json diff --git a/.github/skills/maester-test-expert/SKILL.md b/.github/skills/maester-test-expert/SKILL.md index 3ec07b238a..fc00c82f75 100644 --- a/.github/skills/maester-test-expert/SKILL.md +++ b/.github/skills/maester-test-expert/SKILL.md @@ -76,12 +76,12 @@ background to avoid user confusion. | `Test..ps1` | `tests//[/]` | One function with a `[MaesterTest(...)]` attribute. Reads the tenant, decides, calls `Add-MtTestResultDetail`, returns `$true`/`$false`. | | `Test..md` | Same folder, same base name | Description, `#### Remediation action`, optional `#### Related links`, then `` and `%TestResult%`. Shown in the report. | | `suite.json` | Each suite folder (already exists) | The suite's ID, name, `Source` and help URL template. Do not edit for a single check. | -| `frameworks/.json` | Beside the `suite.json` of the CIS, CISA and ASD suites | The catalogue of the benchmark: its name and version, and one entry per requirement with its level, profiles or criticality (ASD: maturity level and strategy, or ISM guideline, section and applicability). It does not list tests. A CIS, CISA or ASD check names its requirement in `Control`; add the requirement here in the same pull request if it is new, or the build fails. The ASD files are generated by `build/asd/Update-AsdFramework.ps1`. | +| `frameworks/.json` | Beside the `suite.json` of the CIS, CISA, ASD and DISA suites | The catalogue of the benchmark: its name and version, and one entry per requirement with its level, profiles or criticality (ASD: maturity level and strategy, or ISM guideline, section and applicability). It does not list tests. A CIS, CISA or ASD check names its requirement in `Control`; add the requirement here in the same pull request if it is new, or the build fails. The ASD files are generated by `build/asd/Update-AsdFramework.ps1`. | Suite folders: `tests/maester//` (`MT.xxxx`; services such as `entra`, `exchange`, `teams`, `defender`, `azure`, `intune`, and `xspm` for exposure management, which has its own `suite.json`), `tests/cisa//` (`CISA.MS.*`), `tests/cis/` (`CIS.M365.*`), `tests/asd//` (`ASD.ISM-xxxx`, named after the ISM control the -check implements), `tests/ad//` (`AD-*`), and the generated `tests/eidsca/` and +check implements), `tests/disa/` (`DISA.V-xxxxxx`, named after the STIG rule), `tests/ad//` (`AD-*`), and the generated `tests/eidsca/` and `tests/orca/`. Every folder name is lowercase kebab-case; see the repository layout in [the contributing guide](../../../website/docs/contributing.md#repository-layout). diff --git a/AGENTS.md b/AGENTS.md index de6f66ec5b..31f900365c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -51,17 +51,20 @@ maester.dev), `report/` (React app that builds the HTML report template). - A test is mapped to a framework in one place: the `Control` attribute, `:`. A CIS test carries `Control = 'cis-m365:5.1.5.1'`, a CISA test `Control = 'cisa-scuba:MS.AAD.3.1'`, and any other test may name the same requirements. An ASD test carries `Control = 'essential-eight:ISM-1504'` (or `ism:` for a - control outside the maturity model). Every test in `tests/cis`, `tests/cisa` and `tests/asd` must name a requirement of its + control outside the maturity model). A DISA test carries the STIG rule it checks, `Control = 'disa-stig-entra-id:V-270233'`. + Every test in `tests/cis`, `tests/cisa`, `tests/asd` and `tests/disa` must name a requirement of its suite's framework. The engine builds `Benchmark` from the first `Control` that a framework file knows and adds that requirement's `Related` references to `Control`; do not repeat those, and do not add benchmark tags. - A framework file is a catalogue, not a list of tests: `tests//frameworks/.json` (`tests/cis/frameworks/cis-m365.json`, `tests/cis/frameworks/cis-github.json`, `tests/cisa/frameworks/cisa-scuba.json`, and the generated `tests/asd/frameworks/essential-eight.json` and - `tests/asd/frameworks/ism.json`, written by `build/asd/Update-AsdFramework.ps1` from the ISM OSCAL release), + `tests/asd/frameworks/ism.json`, written by `build/asd/Update-AsdFramework.ps1` from the ISM OSCAL release, and + the DISA STIG files `tests/disa/frameworks/disa-stig-entra-id.json`, `disa-stig-intune-mdm.json` and + `disa-stig-intune-desktop.json`), declared in the suite's `suite.json` (`Frameworks`: `Key`, `Version`). It holds the framework's name and version and each requirement's `Id` and facts (CIS `Level` and `Profile`; CISA `Criticality`, `Upstream` and `Related` NIST references; Essential Eight `Level` and `Strategy`; - ISM `Guideline`, `Section` and `Applicability`), never the text of a benchmark and + ISM `Guideline`, `Section` and `Applicability`; DISA STIG `Category`, `RuleId` and `StigId`), never the text of a benchmark and never a `Tests` list. When a new test implements a requirement the file does not have, add the requirement in the same commit, or `./build/Build-MaesterModule.ps1` and the unit tests fail. - Checks read through the session cache. A run reports on one snapshot of the tenant, so no check, pack or helper @@ -87,7 +90,7 @@ enforces them. When writing or reviewing a change, check every added, moved or r framework files, `frameworks/.json` beside its `suite.json` (lowercase key; nothing else goes in a `frameworks/` folder). Suites: `maester//` (plus `drift/`; `maester/xspm/` has its own suite.json), - `cis/`, `cisa//`, `asd//`, `ad//`, generated `eidsca/` and `orca/`, and `custom/` + `cis/`, `cisa//`, `asd//`, `disa/`, `ad//`, generated `eidsca/` and `orca/`, and `custom/` (reserved for users; never commit tests there). - `powershell/public/` (exported) is grouped by job: `run/`, `connect/`, `report/`, `app/`, `packs/`, `services//`. `powershell/internal/` uses `engine/`, `session/`, `connect/`, diff --git a/powershell/assets/MaesterTestSchema.psd1 b/powershell/assets/MaesterTestSchema.psd1 index fdf7250ec4..d95d876b80 100644 --- a/powershell/assets/MaesterTestSchema.psd1 +++ b/powershell/assets/MaesterTestSchema.psd1 @@ -29,7 +29,7 @@ # ID prefixes that belong to tests shipped with Maester, MP. for Maester Packs, and the codes of the packs # that ship with Maester, whose IDs have no MP. prefix (ZTA. for the Zero Trust Assessment pack). - ReservedPrefixes = @('MT.', 'CISA.', 'CIS.', 'EIDSCA.', 'ORCA.', 'AD-', 'AZDO.', 'MT1060.', 'ASD.', 'MP.', 'ZTA.') + ReservedPrefixes = @('MT.', 'CISA.', 'CIS.', 'EIDSCA.', 'ORCA.', 'AD-', 'AZDO.', 'MT1060.', 'ASD.', 'DISA.', 'MP.', 'ZTA.') # Names reserved for future properties. Adding one later does not break existing tests. ReservedNames = @('OptionalService', 'TimeoutSeconds') diff --git a/powershell/internal/checks/cisa/entra/Test-MtCisaActivationNotification.ps1 b/powershell/internal/checks/cisa/entra/Test-MtCisaActivationNotification.ps1 index b03def9439..451ab07cfb 100644 --- a/powershell/internal/checks/cisa/entra/Test-MtCisaActivationNotification.ps1 +++ b/powershell/internal/checks/cisa/entra/Test-MtCisaActivationNotification.ps1 @@ -52,21 +52,8 @@ role = $role.displayName activationNotify = $false } - $policySplat = @{ - ApiVersion = "v1.0" - RelativeUri = "policies/roleManagementPolicyAssignments" - Filter = "scopeId eq '/' and scopeType eq 'DirectoryRole' and roleDefinitionId eq '$($role.id)'" - QueryParameters = @{ - expand = "policy(expand=rules)" - } - } - $policy = Invoke-MtGraphRequest @policySplat - - $activationNotify = $policy.policy.rules | Where-Object {` - $_.id -eq "Notification_Admin_EndUser_Assignment" -and ` - $_.notificationRecipients - } - $rolePolicy.activationNotify = -not $null -eq $activationNotify + $recipients = @(Get-MtRoleActivationNotificationRecipient -RoleDefinitionId $role.id) + $rolePolicy.activationNotify = $recipients.Count -gt 0 $rolePolicies += $rolePolicy } diff --git a/powershell/internal/packs/Test-MtPackContent.ps1 b/powershell/internal/packs/Test-MtPackContent.ps1 index d685c3f129..8b0eba56de 100644 --- a/powershell/internal/packs/Test-MtPackContent.ps1 +++ b/powershell/internal/packs/Test-MtPackContent.ps1 @@ -265,7 +265,7 @@ function Get-MtPackReservedTag { [CmdletBinding()] [OutputType([string[]])] param() - [string[]]@('Maester', 'MT', 'CIS', 'CISA', 'EIDSCA', 'ORCA', 'AD', 'ASD', 'AZDO', 'XSPM', 'All', 'Custom') + [string[]]@('Maester', 'MT', 'CIS', 'CISA', 'EIDSCA', 'ORCA', 'AD', 'ASD', 'DISA', 'AZDO', 'XSPM', 'All', 'Custom') } function Test-MtPackScriptFile { diff --git a/powershell/internal/services/entra/Get-MtActivityBasedTimeout.ps1 b/powershell/internal/services/entra/Get-MtActivityBasedTimeout.ps1 new file mode 100644 index 0000000000..f3eebc95c9 --- /dev/null +++ b/powershell/internal/services/entra/Get-MtActivityBasedTimeout.ps1 @@ -0,0 +1,40 @@ +function Get-MtActivityBasedTimeout { + <# + .SYNOPSIS + Returns the web session idle timeout that the tenant's activity-based timeout policy sets. + + .DESCRIPTION + The idle session timeout in the Microsoft 365 admin center (Settings > Org settings > Security & privacy > + Idle session timeout) is stored as an activity-based timeout policy in Microsoft Entra ID. Its definition is a + JSON string whose WebSessionIdleTimeout value is a time span, such as 03:00:00. + + Returns an object with Timeout (a [timespan], or $null when no policy sets a timeout) and PolicyName (the + display name of the policy that was read, or $null when there is none). + + .EXAMPLE + (Get-MtActivityBasedTimeout).Timeout + + Returns the idle timeout as a time span, or $null when none is set. + #> + [CmdletBinding()] + [OutputType([pscustomobject])] + param () + + $policies = @(Invoke-MtGraphRequest -RelativeUri 'policies/activityBasedTimeoutPolicies' | Where-Object { $_ }) + + $timeout = $null + $policyName = $null + if ($policies.Count -gt 0) { + $policyName = $policies[0].displayName + $definition = @($policies[0].definition)[0] | ConvertFrom-Json + $value = $definition.ActivityBasedTimeoutPolicy.ApplicationPolicies[0].WebSessionIdleTimeout + if ($value) { + $timeout = [timespan]::Parse($value) + } + } + + [pscustomobject]@{ + Timeout = $timeout + PolicyName = $policyName + } +} diff --git a/powershell/internal/services/entra/Get-MtDomainPasswordValidity.ps1 b/powershell/internal/services/entra/Get-MtDomainPasswordValidity.ps1 new file mode 100644 index 0000000000..170724c9f5 --- /dev/null +++ b/powershell/internal/services/entra/Get-MtDomainPasswordValidity.ps1 @@ -0,0 +1,37 @@ +function Get-MtDomainPasswordValidity { + <# + .SYNOPSIS + Returns the password expiration period of each domain of the tenant. + + .DESCRIPTION + The password expiration policy is stored per domain, as passwordValidityPeriodInDays. It applies only to + domains that are verified and managed (not federated), so each domain is returned with IsApplicable. + + ValidityDays is the number of days a password is valid. NeverExpires is true when the value is the one + Microsoft Entra ID uses for "never expire" (2147483647). IsSet is false when the domain stores no value; what + applies then is not stated by the API, so each check decides how to report it. + + .EXAMPLE + Get-MtDomainPasswordValidity | Where-Object IsApplicable + + Returns the verified, managed domains with their password expiration period. + #> + [CmdletBinding()] + [OutputType([pscustomobject])] + param () + + $neverExpires = [int]::MaxValue + foreach ($domain in @(Invoke-MtGraphRequest -RelativeUri 'domains')) { + $raw = $domain.passwordValidityPeriodInDays + $days = 0 + # A boolean or a value that is not a number means no period is stored. + $isSet = ($null -ne $raw) -and ($raw -isnot [bool]) -and [int]::TryParse($raw.ToString(), [ref]$days) + [pscustomobject]@{ + Id = $domain.id + IsApplicable = ($domain.authenticationType -eq 'Managed') -and ($domain.isVerified -eq $true) + IsSet = $isSet + ValidityDays = if ($isSet) { $days } else { $null } + NeverExpires = $isSet -and $days -eq $neverExpires + } + } +} diff --git a/powershell/internal/services/entra/Get-MtRoleActivationNotificationRecipient.ps1 b/powershell/internal/services/entra/Get-MtRoleActivationNotificationRecipient.ps1 new file mode 100644 index 0000000000..f44b72e249 --- /dev/null +++ b/powershell/internal/services/entra/Get-MtRoleActivationNotificationRecipient.ps1 @@ -0,0 +1,34 @@ +function Get-MtRoleActivationNotificationRecipient { + <# + .SYNOPSIS + Returns the additional recipients of the role activation alert of a directory role. + + .DESCRIPTION + Privileged Identity Management sends a "Role activation alert" to the administrators when an eligible member + activates a role. Its additional recipients are stored in the role's management policy, in the rule + Notification_Admin_EndUser_Assignment (notificationRecipients). Returns those addresses, or nothing when the + role sends the alert to no additional recipient. + + .EXAMPLE + Get-MtRoleActivationNotificationRecipient -RoleDefinitionId '62e90394-69f5-4237-9190-012177145e10' + + Returns the additional recipients of the activation alert of the Global Administrator role. + #> + [CmdletBinding()] + [OutputType([string[]])] + param ( + # The ID of the directory role definition. + [Parameter(Mandatory)] + [string] $RoleDefinitionId + ) + + $policySplat = @{ + ApiVersion = 'v1.0' + RelativeUri = 'policies/roleManagementPolicyAssignments' + Filter = "scopeId eq '/' and scopeType eq 'DirectoryRole' and roleDefinitionId eq '$RoleDefinitionId'" + QueryParameters = @{ expand = 'policy(expand=rules)' } + } + $assignment = Invoke-MtGraphRequest @policySplat + $rule = @($assignment.policy.rules) | Where-Object { $_.id -eq 'Notification_Admin_EndUser_Assignment' } | Select-Object -First 1 + return [string[]]@($rule.notificationRecipients | Where-Object { $_ }) +} diff --git a/powershell/internal/services/entra/Get-MtUserLastSignIn.ps1 b/powershell/internal/services/entra/Get-MtUserLastSignIn.ps1 new file mode 100644 index 0000000000..0c507e8a0f --- /dev/null +++ b/powershell/internal/services/entra/Get-MtUserLastSignIn.ps1 @@ -0,0 +1,37 @@ +function Get-MtUserLastSignIn { + <# + .SYNOPSIS + Returns the time of a user's most recent sign-in, in UTC, from the signInActivity of a user object. + + .DESCRIPTION + Reads the signInActivity that a users request returns when it selects that property. By default the latest of + the interactive and the non-interactive sign-in is returned. With -InteractiveOnly only lastSignInDateTime is + read, as some audit procedures do. + + Returns $null when the user has no recorded sign-in of the kind asked for. + + .EXAMPLE + Get-MtUserLastSignIn -User $user + + Returns the latest interactive or non-interactive sign-in of $user, or $null. + #> + [CmdletBinding()] + [OutputType([datetime])] + param ( + # A user object from Microsoft Graph that includes signInActivity. + [Parameter(Mandatory)] + [object] $User, + + # Read only the interactive sign-in (lastSignInDateTime). + [switch] $InteractiveOnly + ) + + $values = if ($InteractiveOnly) { + @($User.signInActivity.lastSignInDateTime) + } else { + @($User.signInActivity.lastSignInDateTime, $User.signInActivity.lastNonInteractiveSignInDateTime) + } + $signIns = @($values | Where-Object { $_ } | ForEach-Object { ([datetime]$_).ToUniversalTime() }) + if ($signIns.Count -eq 0) { return $null } + return ($signIns | Measure-Object -Maximum).Maximum +} diff --git a/powershell/public/run/Invoke-Maester.ps1 b/powershell/public/run/Invoke-Maester.ps1 index 357fa7d1f9..fa65675ee3 100644 --- a/powershell/public/run/Invoke-Maester.ps1 +++ b/powershell/public/run/Invoke-Maester.ps1 @@ -198,7 +198,7 @@ # A severity set for a test in the run configuration is the one that counts. [string[]] $Severity, - # Only run the tests of these suites, for example Maester, CISA, CIS, ASD, EIDSCA, ORCA or AD. '*' wildcards are allowed. + # Only run the tests of these suites, for example Maester, CISA, CIS, ASD, DISA, EIDSCA, ORCA or AD. '*' wildcards are allowed. [string[]] $Suite, # Run these Maester Packs, by pack ID or code, for example ZTA or maester.zero-trust-assessment. diff --git a/powershell/tests/fixtures/golden/selection.json b/powershell/tests/fixtures/golden/selection.json index ce3cdde573..ae970e7cfd 100644 --- a/powershell/tests/fixtures/golden/selection.json +++ b/powershell/tests/fixtures/golden/selection.json @@ -21,7 +21,7 @@ "AD" ] }, - "SelectedCount": 572, + "SelectedCount": 582, "SelectedFamilies": [ "MT.1024", "MT.1059", @@ -314,6 +314,16 @@ "CISA.MS.SHAREPOINT.3.1", "CISA.MS.SHAREPOINT.3.2", "CISA.MS.SHAREPOINT.3.3", + "DISA.V-267314", + "DISA.V-267334", + "DISA.V-267341", + "DISA.V-270208", + "DISA.V-270227", + "DISA.V-270233", + "DISA.V-270335", + "DISA.V-270475", + "DISA.V-273868", + "DISA.V-285327", "EIDSCA.AF01", "EIDSCA.AF02", "EIDSCA.AF03", @@ -761,7 +771,7 @@ "AD" ] }, - "SelectedCount": 528, + "SelectedCount": 538, "SelectedFamilies": [ "MT.1024", "MT.1059", @@ -1054,6 +1064,16 @@ "CISA.MS.SHAREPOINT.3.1", "CISA.MS.SHAREPOINT.3.2", "CISA.MS.SHAREPOINT.3.3", + "DISA.V-267314", + "DISA.V-267334", + "DISA.V-267341", + "DISA.V-270208", + "DISA.V-270227", + "DISA.V-270233", + "DISA.V-270335", + "DISA.V-270475", + "DISA.V-273868", + "DISA.V-285327", "EIDSCA.AP12", "EIDSCA.AP15", "EIDSCA.CR05", @@ -1310,7 +1330,7 @@ "AD" ] }, - "SelectedCount": 588, + "SelectedCount": 598, "SelectedFamilies": [ "MT.1024", "MT.1033", @@ -1606,6 +1626,16 @@ "CISA.MS.SHAREPOINT.3.1", "CISA.MS.SHAREPOINT.3.2", "CISA.MS.SHAREPOINT.3.3", + "DISA.V-267314", + "DISA.V-267334", + "DISA.V-267341", + "DISA.V-270208", + "DISA.V-270227", + "DISA.V-270233", + "DISA.V-270335", + "DISA.V-270475", + "DISA.V-273868", + "DISA.V-285327", "EIDSCA.AF01", "EIDSCA.AF02", "EIDSCA.AF03", @@ -1921,7 +1951,7 @@ "AD" ] }, - "SelectedCount": 590, + "SelectedCount": 609, "SelectedFamilies": [ "MT.1024", "MT.1059", @@ -2215,6 +2245,25 @@ "CISA.MS.SHAREPOINT.3.1", "CISA.MS.SHAREPOINT.3.2", "CISA.MS.SHAREPOINT.3.3", + "DISA.V-267303", + "DISA.V-267309", + "DISA.V-267314", + "DISA.V-267334", + "DISA.V-267341", + "DISA.V-267355", + "DISA.V-270200", + "DISA.V-270204", + "DISA.V-270208", + "DISA.V-270209", + "DISA.V-270227", + "DISA.V-270233", + "DISA.V-270239", + "DISA.V-270255", + "DISA.V-270335", + "DISA.V-270475", + "DISA.V-273867", + "DISA.V-273868", + "DISA.V-285327", "EIDSCA.AF01", "EIDSCA.AF02", "EIDSCA.AF03", @@ -2532,7 +2581,7 @@ "AD" ] }, - "SelectedCount": 620, + "SelectedCount": 639, "SelectedFamilies": [ "MT.1024", "MT.1033", @@ -2829,6 +2878,25 @@ "CISA.MS.SHAREPOINT.3.1", "CISA.MS.SHAREPOINT.3.2", "CISA.MS.SHAREPOINT.3.3", + "DISA.V-267303", + "DISA.V-267309", + "DISA.V-267314", + "DISA.V-267334", + "DISA.V-267341", + "DISA.V-267355", + "DISA.V-270200", + "DISA.V-270204", + "DISA.V-270208", + "DISA.V-270209", + "DISA.V-270227", + "DISA.V-270233", + "DISA.V-270239", + "DISA.V-270255", + "DISA.V-270335", + "DISA.V-270475", + "DISA.V-273867", + "DISA.V-273868", + "DISA.V-285327", "EIDSCA.AF01", "EIDSCA.AF02", "EIDSCA.AF03", @@ -3373,7 +3441,7 @@ "AD" ] }, - "SelectedCount": 528, + "SelectedCount": 538, "SelectedFamilies": [ "MT.1024", "MT.1059", @@ -3666,6 +3734,16 @@ "CISA.MS.SHAREPOINT.3.1", "CISA.MS.SHAREPOINT.3.2", "CISA.MS.SHAREPOINT.3.3", + "DISA.V-267314", + "DISA.V-267334", + "DISA.V-267341", + "DISA.V-270208", + "DISA.V-270227", + "DISA.V-270233", + "DISA.V-270335", + "DISA.V-270475", + "DISA.V-273868", + "DISA.V-285327", "EIDSCA.AP12", "EIDSCA.AP15", "EIDSCA.CR05", @@ -3928,7 +4006,7 @@ "AD" ] }, - "SelectedCount": 576, + "SelectedCount": 595, "SelectedFamilies": [ "MT.1024", "MT.1033", @@ -4225,6 +4303,25 @@ "CISA.MS.SHAREPOINT.3.1", "CISA.MS.SHAREPOINT.3.2", "CISA.MS.SHAREPOINT.3.3", + "DISA.V-267303", + "DISA.V-267309", + "DISA.V-267314", + "DISA.V-267334", + "DISA.V-267341", + "DISA.V-267355", + "DISA.V-270200", + "DISA.V-270204", + "DISA.V-270208", + "DISA.V-270209", + "DISA.V-270227", + "DISA.V-270233", + "DISA.V-270239", + "DISA.V-270255", + "DISA.V-270335", + "DISA.V-270475", + "DISA.V-273867", + "DISA.V-273868", + "DISA.V-285327", "EIDSCA.AP12", "EIDSCA.AP15", "EIDSCA.CR05", diff --git a/powershell/tests/functions/DisaChecks.Tests.ps1 b/powershell/tests/functions/DisaChecks.Tests.ps1 new file mode 100644 index 0000000000..37f160caf3 --- /dev/null +++ b/powershell/tests/functions/DisaChecks.Tests.ps1 @@ -0,0 +1,151 @@ +# The DISA STIG checks, the tests their shims run with DISA's values, and the Entra helpers they read through. Graph is mocked. + +BeforeAll { Import-Module "$PSScriptRoot/../../Maester.psd1" -Force -WarningAction SilentlyContinue } + +Describe 'DISA STIG checks' { + It 'The idle session timeout passes at 15 minutes and fails at an hour or when none is set' { + InModuleScope Maester { + Mock Add-MtTestResultDetail {} + $policy = { param($value) @([pscustomobject]@{ displayName = 'Timeout'; definition = @("{`"ActivityBasedTimeoutPolicy`":{`"Version`":1,`"ApplicationPolicies`":[{`"ApplicationId`":`"default`",`"WebSessionIdleTimeout`":`"$value`"}]}}") }) } + Mock Invoke-MtGraphRequest { & $policy '00:15:00' } -ParameterFilter { $RelativeUri -eq 'policies/activityBasedTimeoutPolicies' } + Test-MtDisaIdleSessionTimeout | Should -BeTrue + Test-MtDisaEntraIdleSessionTimeout | Should -BeTrue + Mock Invoke-MtGraphRequest { & $policy '01:00:00' } -ParameterFilter { $RelativeUri -eq 'policies/activityBasedTimeoutPolicies' } + Test-MtDisaIntuneDesktopIdleSessionTimeout | Should -BeFalse + Test-MtDisaIdleSessionTimeout -MaximumIdleTimeoutMinutes 60 | Should -BeTrue + Mock Invoke-MtGraphRequest { @() } -ParameterFilter { $RelativeUri -eq 'policies/activityBasedTimeoutPolicies' } + Test-MtDisaIdleSessionTimeout | Should -BeFalse + } + } + + It 'The lockout shims need a threshold of 3 and a duration of 900 seconds, and CIS 5.2.3.8 still ignores the duration' { + InModuleScope Maester { + Mock Add-MtTestResultDetail {} + $settings = { param($threshold, $duration) @([pscustomobject]@{ templateId = '5cf42378-d67d-4f36-ba46-e8b86229381d'; values = @( + [pscustomobject]@{ name = 'LockoutThreshold'; value = $threshold } + [pscustomobject]@{ name = 'LockoutDurationInSeconds'; value = $duration } + ) }) } + Mock Invoke-MtGraphRequest { & $settings '3' '900' } + Test-MtDisaEntraLockout | Should -BeTrue + Test-MtDisaIntuneDesktopLockout | Should -BeTrue + Mock Invoke-MtGraphRequest { & $settings '3' '60' } + Test-MtDisaEntraLockout | Should -BeFalse + Test-MtCisSmartLockoutThreshold | Should -BeTrue + Mock Invoke-MtGraphRequest { & $settings '5' '900' } + Test-MtDisaEntraLockout | Should -BeFalse + Mock Invoke-MtGraphRequest { @() } + Test-MtDisaEntraLockout | Should -BeFalse -Because 'the defaults are 10 attempts and 60 seconds' + } + } + + It 'The device wipe approval shim needs a deviceWipe or deviceAction policy, and MT.1096 accepts any policy' { + InModuleScope Maester { + Mock Add-MtTestResultDetail {} + Mock Invoke-MtGraphRequest { @([pscustomobject]@{ displayName = 'Scripts'; policyType = 'script' }) } + Test-MtOperationApprovalPolicies | Should -BeTrue + Test-MtDisaIntuneWipeApproval | Should -BeFalse + Mock Invoke-MtGraphRequest { @([pscustomobject]@{ displayName = 'Wipe'; policyType = 'deviceWipe' }) } + Test-MtDisaIntuneWipeApproval | Should -BeTrue + Mock Invoke-MtGraphRequest { @([pscustomobject]@{ displayName = 'Actions'; policyType = 'unknown'; policySet = [pscustomobject]@{ policyType = 'deviceAction' } }) } + Test-MtDisaIntuneWipeApproval | Should -BeTrue + Mock Invoke-MtGraphRequest { @() } + Test-MtOperationApprovalPolicies | Should -BeFalse + } + } + + It 'The log export shim asks for DISA''s eight categories, where CISA 4.1 asks for more' { + InModuleScope Maester { + Mock Add-MtTestResultDetail {} + $disa = 'SignInLogs', 'AuditLogs', 'ServicePrincipalSignInLogs', 'ManagedIdentitySignInLogs', 'UserRiskEvents', 'RiskyUsers', 'RiskyServicePrincipals', 'ServicePrincipalRiskEvents' + $all = $disa + 'NonInteractiveUserSignInLogs', 'MicrosoftGraphActivityLogs' + Mock Invoke-AzRestMethod { + if ($Path -like '*diagnosticSettingsCategories*') { + [pscustomobject]@{ StatusCode = 200; Content = (@{ value = @($all | ForEach-Object { @{ name = $_; properties = @{ categoryType = 'Logs' } } }) } | ConvertTo-Json -Depth 5) } + } else { + [pscustomobject]@{ StatusCode = 200; Content = (@{ value = @(@{ name = 'sentinel'; properties = @{ logs = @($disa | ForEach-Object { @{ category = $_; enabled = $true } }) } }) } | ConvertTo-Json -Depth 6) } + } + } + Test-MtDisaEntraLogExport | Should -BeTrue + Test-MtCisaDiagnosticSettings | Should -BeFalse + } + } + + It 'The sign-in banner passes with the full or the short banner and fails without branding' { + InModuleScope Maester { + Mock Add-MtTestResultDetail {} + Mock Invoke-MtGraphRequest { @([pscustomobject]@{ id = 'org1' }) } -ParameterFilter { $RelativeUri -eq 'organization' } + Mock Invoke-MtGraphRequest { [pscustomobject]@{ signInPageText = "You are accessing a U.S. Government (USG) Information System (IS) that is provided`nfor USG-authorized use only. By using this IS..." } } -ParameterFilter { $RelativeUri -eq 'organization/org1/branding' } + Test-MtDisaSignInBanner | Should -BeTrue + Mock Invoke-MtGraphRequest { [pscustomobject]@{ signInPageText = "I've read & consent to terms in IS user agreem't." } } -ParameterFilter { $RelativeUri -eq 'organization/org1/branding' } + Test-MtDisaSignInBanner | Should -BeTrue + Mock Invoke-MtGraphRequest { [pscustomobject]@{ signInPageText = 'Welcome to Contoso' } } -ParameterFilter { $RelativeUri -eq 'organization/org1/branding' } + Test-MtDisaSignInBanner | Should -BeFalse + Test-MtDisaSignInBanner -RequiredText 'welcome to CONTOSO' | Should -BeTrue + Mock Invoke-MtGraphRequest { throw 'Response status code does not indicate success: NotFound (Not Found).' } -ParameterFilter { $RelativeUri -eq 'organization/org1/branding' } + Test-MtDisaSignInBanner | Should -BeFalse + } + } + + It 'The password lifetime fails a domain that never expires or exceeds the maximum, and asks for review when none is stored' { + InModuleScope Maester { + $script:details = @() + Mock Add-MtTestResultDetail { $script:details += [pscustomobject]@{ Investigate = [bool]$Investigate } } + $domain = { param($id, $days, $type = 'Managed', $verified = $true) [pscustomobject]@{ id = $id; authenticationType = $type; isVerified = $verified; passwordValidityPeriodInDays = $days } } + Mock Invoke-MtGraphRequest { @((& $domain 'a.mil' 90), (& $domain 'fed.mil' 2147483647 'Federated')) } + Test-MtDisaPasswordLifetime | Should -BeTrue + Test-MtDisaIntuneDesktopPasswordLifetime | Should -BeFalse -Because 'the Intune STIG allows 60 days' + Test-MtCisPasswordExpiry | Should -BeFalse -Because 'CIS asks that passwords never expire' + Mock Invoke-MtGraphRequest { @((& $domain 'a.mil' 2147483647)) } + Test-MtDisaPasswordLifetime | Should -BeFalse + Test-MtCisPasswordExpiry | Should -BeTrue + $script:details = @() + Mock Invoke-MtGraphRequest { @((& $domain 'a.mil' $null)) } + Test-MtDisaPasswordLifetime | Should -BeTrue + $script:details[-1].Investigate | Should -BeTrue + Test-MtCisPasswordExpiry | Should -BeTrue + } + } + + It 'The role activation alert fails a role with no additional recipient, or without a required one' { + InModuleScope Maester { + Mock Add-MtTestResultDetail {} + Mock Get-MtDirectoryRoleAssignment { [pscustomobject]@{ Assignments = @( + [pscustomobject]@{ roleDefinitionId = 'r1'; AssignmentType = 'Active' } + [pscustomobject]@{ roleDefinitionId = 'r2'; AssignmentType = 'Eligible' } + ); EligibleChecked = $true } } + Mock Invoke-MtGraphRequest { @([pscustomobject]@{ id = 'r1'; displayName = 'Role one' }, [pscustomobject]@{ id = 'r2'; displayName = 'Role two' }) } -ParameterFilter { $RelativeUri -eq 'roleManagement/directory/roleDefinitions' } + $policy = { param($recipients) [pscustomobject]@{ policy = [pscustomobject]@{ rules = @([pscustomobject]@{ id = 'Notification_Admin_EndUser_Assignment'; notificationRecipients = $recipients }) } } } + Mock Invoke-MtGraphRequest { & $policy @('isso@contoso.mil', 'sa@contoso.mil') } -ParameterFilter { $RelativeUri -eq 'policies/roleManagementPolicyAssignments' } + Test-MtDisaRoleActivationNotification | Should -BeTrue + Test-MtDisaRoleActivationNotification -RequiredRecipient 'sa@contoso.mil', 'isso@contoso.mil' | Should -BeTrue + Test-MtDisaRoleActivationNotification -RequiredRecipient 'soc@contoso.mil' | Should -BeFalse + Mock Invoke-MtGraphRequest { & $policy @() } -ParameterFilter { $RelativeUri -eq 'policies/roleManagementPolicyAssignments' } + Test-MtDisaRoleActivationNotification | Should -BeFalse + Get-MtRoleActivationNotificationRecipient -RoleDefinitionId 'r1' | Should -BeNullOrEmpty + } + } + + It 'Inactive accounts follow the interactive sign-in and the creation date of accounts that never signed in' { + InModuleScope Maester { + Mock Add-MtTestResultDetail {} + $now = [datetime]::UtcNow + $user = { param($upn, $lastSignIn, $nonInteractive, $created) [pscustomobject]@{ id = $upn; userPrincipalName = $upn; userType = 'Member'; accountEnabled = $true; createdDateTime = $created.ToString('o'); signInActivity = [pscustomobject]@{ lastSignInDateTime = $lastSignIn; lastNonInteractiveSignInDateTime = $nonInteractive } } } + Mock Invoke-MtGraphRequest { @((& $user 'a@contoso.mil' $now.AddDays(-5).ToString('o') $null $now.AddDays(-400)), (& $user 'new@contoso.mil' $null $null $now.AddDays(-2))) } + Test-MtDisaInactiveAccount | Should -BeTrue + Mock Invoke-MtGraphRequest { @((& $user 'b@contoso.mil' $now.AddDays(-40).ToString('o') $now.AddDays(-1).ToString('o') $now.AddDays(-400))) } + Test-MtDisaInactiveAccount | Should -BeFalse -Because 'the STIG audit reads the interactive sign-in only' + Test-MtDisaIntuneDesktopInactiveAccount -InactiveDays 45 | Should -BeTrue + Mock Invoke-MtGraphRequest { @((& $user 'c@contoso.mil' $null $null $now.AddDays(-100))) } + Test-MtDisaInactiveAccount | Should -BeFalse + } + } + + It 'Get-MtUserLastSignIn returns the latest sign-in in UTC, or nothing' { + InModuleScope Maester { + $u = [pscustomobject]@{ signInActivity = [pscustomobject]@{ lastSignInDateTime = '2026-01-01T00:00:00Z'; lastNonInteractiveSignInDateTime = '2026-02-01T00:00:00Z' } } + (Get-MtUserLastSignIn -User $u).Month | Should -Be 2 + (Get-MtUserLastSignIn -User $u -InteractiveOnly).Month | Should -Be 1 + Get-MtUserLastSignIn -User ([pscustomobject]@{ signInActivity = $null }) | Should -BeNullOrEmpty + } + } +} diff --git a/powershell/tests/functions/engine/Frameworks.Tests.ps1 b/powershell/tests/functions/engine/Frameworks.Tests.ps1 index 83d62383af..06a6372fd8 100644 --- a/powershell/tests/functions/engine/Frameworks.Tests.ps1 +++ b/powershell/tests/functions/engine/Frameworks.Tests.ps1 @@ -145,8 +145,8 @@ Describe 'Frameworks of a suite' { } } $keys.Own | Should -Be @('contoso-baseline', 'contoso-cloud') -Because 'the tests shipped with Maester refer to nothing outside their own folder' - $keys.Custom | Should -Be @('cis-github', 'cis-m365', 'cisa-scuba', 'contoso-baseline', 'contoso-cloud', 'essential-eight', 'ism') -Because 'a custom test can also refer to a framework shipped with Maester' - $keys.None | Should -Be @('cis-github', 'cis-m365', 'cisa-scuba', 'essential-eight', 'ism') + $keys.Custom | Should -Be @('cis-github', 'cis-m365', 'cisa-scuba', 'contoso-baseline', 'contoso-cloud', 'disa-stig-entra-id', 'disa-stig-intune-desktop', 'disa-stig-intune-mdm', 'essential-eight', 'ism') -Because 'a custom test can also refer to a framework shipped with Maester' + $keys.None | Should -Be @('cis-github', 'cis-m365', 'cisa-scuba', 'disa-stig-entra-id', 'disa-stig-intune-desktop', 'disa-stig-intune-mdm', 'essential-eight', 'ism') } It 'Reports a key that two suites declare, names both files and keeps the first' { @@ -310,7 +310,7 @@ Describe 'Benchmark of the tests shipped with Maester' { $script:frameworkFiles = @(Get-ChildItem -Path (Join-Path $script:repoRoot 'tests') -Recurse -File -Filter '*.json' | Where-Object { $_.Directory.Name -eq 'frameworks' }) } - It 'Declares the benchmarks of the CIS, CISA and ASD suites in their suite.json' { + It 'Declares the benchmarks of the CIS, CISA, ASD and DISA suites in their suite.json' { $cis = Get-Content (Join-Path $script:repoRoot 'tests/cis/suite.json') -Raw | ConvertFrom-Json @($cis.Frameworks | ForEach-Object { "$($_.Key) $($_.Version)" }) | Should -Be @('cis-m365 7.0.0', 'cis-github 1.2.0') $cisa = Get-Content (Join-Path $script:repoRoot 'tests/cisa/suite.json') -Raw | ConvertFrom-Json @@ -323,10 +323,12 @@ Describe 'Benchmark of the tests shipped with Maester' { # Both come from one ISM OSCAL release, so they carry one version. @($asd.Frameworks.Version | Sort-Object -Unique).Count | Should -Be 1 $asd.Frameworks[0].Version | Should -Not -BeNullOrEmpty + $disa = Get-Content (Join-Path $script:repoRoot 'tests/disa/suite.json') -Raw | ConvertFrom-Json + @($disa.Frameworks | ForEach-Object { "$($_.Key) $($_.Version)" }) | Should -Be @('disa-stig-entra-id V1R2', 'disa-stig-intune-mdm V1R2', 'disa-stig-intune-desktop V1R1') } It 'Has a framework file for every declared framework and no problem in any of them' { - @($script:frameworkFiles.Name | Sort-Object) | Should -Be @('cis-github.json', 'cis-m365.json', 'cisa-scuba.json', 'essential-eight.json', 'ism.json') + @($script:frameworkFiles.Name | Sort-Object) | Should -Be @('cis-github.json', 'cis-m365.json', 'cisa-scuba.json', 'disa-stig-entra-id.json', 'disa-stig-intune-desktop.json', 'disa-stig-intune-mdm.json', 'essential-eight.json', 'ism.json') $problems = @(InModuleScope Maester { Get-MtFrameworkProblem -Test @(Get-MtTestCatalog) -Root (Get-MtMaesterTestFolderPath) }) $problems | Should -BeNullOrEmpty } @@ -336,6 +338,7 @@ Describe 'Benchmark of the tests shipped with Maester' { @{ Prefix = 'CIS.GH.'; Label = 'cis-github'; Framework = 'cis-github'; Version = '1.2.0'; Count = 5 } @{ Prefix = 'CISA.'; Label = 'cisa-scuba'; Framework = 'cisa-scuba'; Version = $null; Count = 79 } @{ Prefix = 'ASD.'; Label = 'essential-eight or ism'; Framework = @('essential-eight', 'ism'); Version = $null; Count = 14 } + @{ Prefix = 'DISA.'; Label = 'a DISA STIG'; Framework = @('disa-stig-entra-id', 'disa-stig-intune-mdm', 'disa-stig-intune-desktop'); Version = $null; Count = 19 } ) { $tests = @($script:builtIn | Where-Object { $_.Id.StartsWith($Prefix) }) $tests.Count | Should -Be $Count @@ -349,7 +352,7 @@ Describe 'Benchmark of the tests shipped with Maester' { } It 'Carries Benchmark as null on every other test' { - $others = @($script:builtIn | Where-Object { $_.Id -notlike 'CIS.*' -and $_.Id -notlike 'CISA.*' -and $_.Id -notlike 'ASD.*' }) + $others = @($script:builtIn | Where-Object { $_.Id -notlike 'CIS.*' -and $_.Id -notlike 'CISA.*' -and $_.Id -notlike 'ASD.*' -and $_.Id -notlike 'DISA.*' }) $others.Count | Should -BeGreaterThan 600 @($others | Where-Object { -not $_.PSObject.Properties['Benchmark'] -or $null -ne $_.Benchmark } | ForEach-Object Id) | Should -BeNullOrEmpty } @@ -404,7 +407,7 @@ Describe 'Benchmark of the tests shipped with Maester' { $content = Get-Content -LiteralPath $file.FullName -Raw | ConvertFrom-Json foreach ($requirement in $content.Requirements) { foreach ($name in $requirement.PSObject.Properties.Name) { - if ($name -cnotin 'Id', 'Related', 'Level', 'Profile', 'Criticality', 'Upstream', 'Strategy', 'Guideline', 'Section', 'Applicability') { "$($file.Name): requirement $($requirement.Id) has $name" } + if ($name -cnotin 'Id', 'Related', 'Level', 'Profile', 'Criticality', 'Upstream', 'Strategy', 'Guideline', 'Section', 'Applicability', 'Category', 'RuleId', 'StigId') { "$($file.Name): requirement $($requirement.Id) has $name" } } } } @@ -729,7 +732,7 @@ Describe 'Docs export' { } It 'Names every framework the tests use, with its version' { - @($script:export.Frameworks.Key) | Should -Be @('cis-github', 'cis-m365', 'cisa-scuba', 'essential-eight', 'ism') + @($script:export.Frameworks.Key) | Should -Be @('cis-github', 'cis-m365', 'cisa-scuba', 'disa-stig-entra-id', 'disa-stig-intune-desktop', 'disa-stig-intune-mdm', 'essential-eight', 'ism') ($script:export.Frameworks | Where-Object Key -EQ 'cis-m365').Name | Should -Be 'CIS Microsoft 365 Foundations Benchmark' ($script:export.Frameworks | Where-Object Key -EQ 'cis-m365').Version | Should -BeExactly '7.0.0' @($script:export.Tests | Where-Object { $_.Benchmark -and $_.Benchmark.Framework -cnotin $script:export.Frameworks.Key } | ForEach-Object Id) | Should -BeNullOrEmpty diff --git a/powershell/tests/functions/engine/Resolve-MtTestSource.Tests.ps1 b/powershell/tests/functions/engine/Resolve-MtTestSource.Tests.ps1 index f1e170a5b3..5a81557ff4 100644 --- a/powershell/tests/functions/engine/Resolve-MtTestSource.Tests.ps1 +++ b/powershell/tests/functions/engine/Resolve-MtTestSource.Tests.ps1 @@ -222,7 +222,7 @@ Describe 'Get-MtTestFileOrigin' { foreach ($folder in Get-ChildItem $root -Directory | Where-Object Name -NE 'Custom') { $manifest = Join-Path $folder.FullName 'suite.json' $manifest | Should -Exist -Because $folder.Name - (Get-Content $manifest -Raw | ConvertFrom-Json).Source | Should -BeIn @('Maester', 'CISA', 'CIS', 'EIDSCA', 'ORCA', 'ASD') -Because $folder.Name + (Get-Content $manifest -Raw | ConvertFrom-Json).Source | Should -BeIn @('Maester', 'CISA', 'CIS', 'EIDSCA', 'ORCA', 'ASD', 'DISA') -Because $folder.Name } } } diff --git a/powershell/tests/general/NativeTestAttributes.Tests.ps1 b/powershell/tests/general/NativeTestAttributes.Tests.ps1 index 132a1473a9..3b826f7325 100644 --- a/powershell/tests/general/NativeTestAttributes.Tests.ps1 +++ b/powershell/tests/general/NativeTestAttributes.Tests.ps1 @@ -164,8 +164,8 @@ Describe 'Attributes of the built-in tests' { } It 'Finds the suites that declare frameworks' { - @($script:frameworkSuites.Id | Sort-Object) | Should -Be @('ASD', 'CIS', 'CISA') - @($script:requirementsOf.Keys | Sort-Object) | Should -Be @('cis-github', 'cis-m365', 'cisa-scuba', 'essential-eight', 'ism') + @($script:frameworkSuites.Id | Sort-Object) | Should -Be @('ASD', 'CIS', 'CISA', 'DISA') + @($script:requirementsOf.Keys | Sort-Object) | Should -Be @('cis-github', 'cis-m365', 'cisa-scuba', 'disa-stig-entra-id', 'disa-stig-intune-desktop', 'disa-stig-intune-mdm', 'essential-eight', 'ism') } It 'Names an existing requirement when a Control refers to a framework shipped with Maester' { diff --git a/powershell/tests/general/NativeTestLint.Tests.ps1 b/powershell/tests/general/NativeTestLint.Tests.ps1 index 8fa91a31a5..ce59de3242 100644 --- a/powershell/tests/general/NativeTestLint.Tests.ps1 +++ b/powershell/tests/general/NativeTestLint.Tests.ps1 @@ -137,7 +137,7 @@ Describe 'Product of the built-in tests' { $script:builtIn = @(Get-MtTest | Where-Object BuiltIn) # The product of every test in a folder that is named after a service or a suite of one product. - # tests/cis is one folder for many products, so it is only checked against the list. + # tests/cis and tests/disa are one folder for many products, so they are only checked against the list. $script:folderProduct = [ordered]@{ 'maester/azure' = 'azure' 'maester/azure-devops' = 'azure-devops' @@ -224,7 +224,7 @@ Describe 'Product of the built-in tests' { It 'Has a product in the folder map for every service folder' { $missing = $script:builtIn | ForEach-Object { Get-TestFolder -File $_.File } | Select-Object -Unique | - Where-Object { $_ -ne 'cis' -and -not $script:folderProduct.Contains($_) -and -not $script:folderProduct.Contains(($_ -split '/')[0]) } + Where-Object { $_ -notin 'cis', 'disa' -and -not $script:folderProduct.Contains($_) -and -not $script:folderProduct.Contains(($_ -split '/')[0]) } $missing | Should -BeNullOrEmpty -Because 'a new test folder needs its product in the folder map of this test' } } diff --git a/powershell/tests/general/RepositoryLayout.Tests.ps1 b/powershell/tests/general/RepositoryLayout.Tests.ps1 index 99a8bd081f..bd5c5fc8cd 100644 --- a/powershell/tests/general/RepositoryLayout.Tests.ps1 +++ b/powershell/tests/general/RepositoryLayout.Tests.ps1 @@ -22,7 +22,7 @@ BeforeAll { ) # Areas of the maester suite that are not a service. $script:MaesterAreas = @('drift') - $script:Suites = @('ad', 'asd', 'cis', 'cisa', 'custom', 'eidsca', 'maester', 'orca') + $script:Suites = @('ad', 'asd', 'cis', 'cisa', 'custom', 'disa', 'eidsca', 'maester', 'orca') $script:PublicGroups = @('app', 'connect', 'packs', 'report', 'run', 'services') $script:InternalGroups = @('app', 'checks', 'connect', 'engine', 'generated', 'packs', 'report', 'services', 'session', 'utility') $script:KebabCase = '^[a-z0-9]+(-[a-z0-9]+)*$' diff --git a/report/src/lib/model.ts b/report/src/lib/model.ts index 36989bd06a..a8a116e8c8 100644 --- a/report/src/lib/model.ts +++ b/report/src/lib/model.ts @@ -51,10 +51,11 @@ export const TACTICS: [string, string][] = [ export const FRAMEWORK_LABEL: Record = { "cis-m365": "CIS Microsoft 365", "cis-github": "CIS GitHub", "cisa-scuba": "CISA SCuBA", "essential-eight": "Essential Eight", ism: "ASD ISM", "nist-800-53-r5": "NIST SP 800-53", + "disa-stig-entra-id": "DISA STIG Entra ID", "disa-stig-intune-mdm": "DISA STIG Intune MDM", "disa-stig-intune-desktop": "DISA STIG Intune Desktop", } -// The order frameworks are listed in everywhere: NIST, CISA, CIS, then ASD's ISM and Essential Eight, then any other. -const FRAMEWORK_ORDER = ["nist-800-53-r5", "cisa-scuba", "cis-m365", "cis-github", "ism", "essential-eight"] +// The order frameworks are listed in everywhere: NIST, CISA, CIS, then ASD's ISM and Essential Eight, then the DISA STIGs, then any other. +const FRAMEWORK_ORDER = ["nist-800-53-r5", "cisa-scuba", "cis-m365", "cis-github", "ism", "essential-eight", "disa-stig-entra-id", "disa-stig-intune-mdm", "disa-stig-intune-desktop"] export const frameworkRank = (key: string) => (FRAMEWORK_ORDER.indexOf(key) + 1 || FRAMEWORK_ORDER.length + 1) // Why a test did not run, as a heading and what to do about it. Codes: website/docs/configuration/applicability.md. diff --git a/report/src/pages/report/FrameworkPage.tsx b/report/src/pages/report/FrameworkPage.tsx index ec0fc9a1ea..72ea81b775 100644 --- a/report/src/pages/report/FrameworkPage.tsx +++ b/report/src/pages/report/FrameworkPage.tsx @@ -11,13 +11,14 @@ import { Segmented } from "./ProductPage" const CIS_SECTIONS: Record = { 1: "Microsoft 365 admin center", 2: "Microsoft 365 Defender", 3: "Microsoft Purview", 4: "Microsoft Intune", 5: "Microsoft Entra admin center", 6: "Exchange admin center", 7: "SharePoint admin center", 8: "Microsoft Teams admin center", 9: "Microsoft Fabric" } const CISA_SERVICES: Record = { "MS.AAD": "Entra ID", "MS.DEFENDER": "Defender", "MS.EXO": "Exchange Online", "MS.POWERBI": "Power BI", "MS.POWERPLATFORM": "Power Platform", "MS.SHAREPOINT": "SharePoint", "MS.TEAMS": "Teams", "MS.SECURITYSUITE": "Security suite" } -// The framework's own structure: CIS sections, CISA services, Essential Eight strategies, ISM guidelines, NIST families. +// The framework's own structure: CIS sections, CISA services, Essential Eight strategies, ISM guidelines, DISA STIG categories, NIST families. function sectionOf(key: string, r: Record): string { const id = String(r.Id) if (key.startsWith("cis-")) { const s = id.split(".")[0]; return CIS_SECTIONS[s] ? `${s} · ${CIS_SECTIONS[s]}` : s } if (key === "cisa-scuba") { const s = id.split(".").slice(0, 2).join("."); return CISA_SERVICES[s] ? `${s} · ${CISA_SERVICES[s]}` : s } if (key === "essential-eight") return (Array.isArray(r.Strategy) ? r.Strategy[0] : r.Strategy) as string || "Other" if (key === "ism") return (r.Guideline as string) || "Other" + if (key.startsWith("disa-stig-")) return (r.Category as string) || "Other" if (key.startsWith("nist")) return (r.Family as string) || id.split("-")[0] return "Requirements" } @@ -28,8 +29,8 @@ export default function FrameworkPage({ frameworkKey }: { frameworkKey: string } const [show, setShow] = useState("all") const f = model.frameworks.find((x) => x.Key === frameworkKey) if (!f) return

No tests map to this framework

- const levels = ["All", ...new Set(f.Requirements.map((r) => String(r.Level || r.Criticality || "")).filter(Boolean))].sort((a, b) => (a === "All" ? -1 : b === "All" ? 1 : a.localeCompare(b))) - const requirements = f.Requirements.filter((r) => level === "All" || r.Level === level || r.Criticality === level) + const levels = ["All", ...new Set(f.Requirements.map((r) => String(r.Level || r.Criticality || r.Category || "")).filter(Boolean))].sort((a, b) => (a === "All" ? -1 : b === "All" ? 1 : a.localeCompare(b))) + const requirements = f.Requirements.filter((r) => level === "All" || r.Level === level || r.Criticality === level || r.Category === level) const c = frameworkTally(model, f, requirements) const sections = new Map() for (const r of requirements) { const s = sectionOf(f.Key, r); if (!sections.has(s)) sections.set(s, []); sections.get(s)!.push(r) } diff --git a/tests/asd/entra/Test.ASD.ISM-1648.ps1 b/tests/asd/entra/Test.ASD.ISM-1648.ps1 index acb8228dad..a2b43c82ba 100644 --- a/tests/asd/entra/Test.ASD.ISM-1648.ps1 +++ b/tests/asd/entra/Test.ASD.ISM-1648.ps1 @@ -59,8 +59,7 @@ $users = @(Invoke-MtGraphRequest -RelativeUri 'users' -UniqueId @($rolesOf.Keys) -Select id, userPrincipalName, displayName, accountEnabled, createdDateTime, signInActivity) $inactive = foreach ($user in $users) { if ($user.accountEnabled -ne $true) { continue } - $signIns = @($user.signInActivity.lastSignInDateTime, $user.signInActivity.lastNonInteractiveSignInDateTime | Where-Object { $_ } | ForEach-Object { [datetime]$_ }) - $lastSignIn = if ($signIns.Count -gt 0) { ($signIns | Measure-Object -Maximum).Maximum.ToUniversalTime() } else { $null } + $lastSignIn = Get-MtUserLastSignIn -User $user $isInactive = if ($lastSignIn) { $lastSignIn -lt $cutoff } else { $user.createdDateTime -and ([datetime]$user.createdDateTime).ToUniversalTime() -lt $cutoff } if ($isInactive) { [pscustomobject]@{ diff --git a/tests/cis/Test.CIS.M365.1.3.1.ps1 b/tests/cis/Test.CIS.M365.1.3.1.ps1 index c8d8c83bab..07593fbf10 100644 --- a/tests/cis/Test.CIS.M365.1.3.1.ps1 +++ b/tests/cis/Test.CIS.M365.1.3.1.ps1 @@ -37,38 +37,9 @@ param() Write-Verbose 'Get domain details for the password expiry period' - $domains = Invoke-MtGraphRequest -RelativeUri 'domains' - - Write-Verbose 'Get verified and managed domains where passwords are set to expire' - - $noPasswordExpiryPeriodInDays = [int]::MaxValue - - $excludedDomains = @() - $applicableDomains = @() - foreach ($domain in $domains) { - # Password policy checks apply only to managed and verified domains. - if (($domain.authenticationType -ne "Managed") -or ($domain.isVerified -ne $true)) { - $excludedDomains += $domain - continue - } - - $applicableDomains += $domain - } - - $result = $applicableDomains | Where-Object { - $passwordValidityPeriodInDays = 0 - $domainPasswordValidityPeriodInDays = $_.PasswordValidityPeriodInDays - # If null or a boolean, the password expiry period is not set, and passwords do not expire. - # Return false to indicate this domain does not fail the test. - if (($null -eq $domainPasswordValidityPeriodInDays) -or ($domainPasswordValidityPeriodInDays -is [bool])) { - return $false - } - if (-not [int]::TryParse($domainPasswordValidityPeriodInDays.ToString(), [ref]$passwordValidityPeriodInDays)) { - return $false - } - # If valid integer, check if equal to the value that indicates no password expiry (MaxValue). - return $passwordValidityPeriodInDays -ne $noPasswordExpiryPeriodInDays - } + # Password policy checks apply only to managed and verified domains. A domain that stores no period does not expire passwords. + $domains = @(Get-MtDomainPasswordValidity) + $result = @($domains | Where-Object { $_.IsApplicable -and $_.IsSet -and -not $_.NeverExpires }) $testResult = ($result | Measure-Object).Count -eq 0 @@ -82,9 +53,9 @@ $resultMd += "| --- | --- |`n" foreach ($item in $domains) { $itemResult = '❌ Fail' - if ($item.id -in $excludedDomains.id) { + if (-not $item.IsApplicable) { $itemResult = '⏭️ Skip' - } elseif ($item.id -notin $result.id) { + } elseif ($item.Id -notin $result.Id) { $itemResult = '✅ Pass' } $resultMd += "| $($item.Id) | $($itemResult) |`n" diff --git a/tests/cis/Test.CIS.M365.1.3.2.ps1 b/tests/cis/Test.CIS.M365.1.3.2.ps1 index 724d88889d..3a5308d250 100644 --- a/tests/cis/Test.CIS.M365.1.3.2.ps1 +++ b/tests/cis/Test.CIS.M365.1.3.2.ps1 @@ -41,17 +41,8 @@ ) Write-Verbose 'Getting the activity-based timeout policy and Conditional Access policies...' - $timeoutPolicies = @(Invoke-MtGraphRequest -RelativeUri 'policies/activityBasedTimeoutPolicies' | Where-Object { $_ }) + $timeoutSpan = (Get-MtActivityBasedTimeout).Timeout $policies = Get-MtConditionalAccessPolicy - - $timeoutSpan = $null - if ($timeoutPolicies.Count -gt 0) { - $definition = @($timeoutPolicies[0].definition)[0] | ConvertFrom-Json - $timeout = $definition.ActivityBasedTimeoutPolicy.ApplicationPolicies[0].WebSessionIdleTimeout - if ($timeout) { - $timeoutSpan = [timespan]::Parse($timeout) - } - } $timeoutOk = $null -ne $timeoutSpan -and $timeoutSpan -le [timespan]::FromHours($MaximumIdleTimeoutHours) $candidates = @($policies | Where-Object { $_.sessionControls.applicationEnforcedRestrictions.isEnabled }) diff --git a/tests/cis/Test.CIS.M365.5.2.3.8.ps1 b/tests/cis/Test.CIS.M365.5.2.3.8.ps1 index 96897dd52f..07e827c74e 100644 --- a/tests/cis/Test.CIS.M365.5.2.3.8.ps1 +++ b/tests/cis/Test.CIS.M365.5.2.3.8.ps1 @@ -5,6 +5,7 @@ .DESCRIPTION Checks that the smart lockout threshold in Microsoft Entra password protection does not exceed the maximum, which limits how many wrong passwords an attacker can try before the account is locked out. When the threshold is not stored, Microsoft Entra uses its public cloud default of 10. + With MinimumLockoutDurationSeconds it also checks that an account stays locked for at least that long. When the duration is not stored, Microsoft Entra uses its default of 60 seconds. CIS does not ask for a duration, so it is not checked by default. CIS Microsoft 365 Foundations Benchmark v7.0.0 (5.2.3.8, L1) .EXAMPLE @@ -35,7 +36,11 @@ param( # Maximum number of failed sign-ins before the account is locked out. [ValidateRange(1, 50)] - [int] $MaximumLockoutThreshold = 10 + [int] $MaximumLockoutThreshold = 10, + + # Shortest lockout duration, in seconds, that is allowed. 0 does not check the duration. + [ValidateRange(0, 86400)] + [int] $MinimumLockoutDurationSeconds = 0 ) Write-Verbose 'Getting the password rule settings...' @@ -52,14 +57,30 @@ $isStored = $threshold -match '^\d+$' $effective = if ($isStored) { [int]$threshold } else { $default } $display = if ($isStored) { $threshold } else { "$default (default)" } - $testResult = $effective -le $MaximumLockoutThreshold + $thresholdOk = $effective -le $MaximumLockoutThreshold + + # Microsoft's default lockout duration applies when the setting is not stored. + $defaultDuration = 60 + $duration = "$($ruleValues['LockoutDurationInSeconds'])" + $isDurationStored = $duration -match '^\d+$' + $effectiveDuration = if ($isDurationStored) { [int]$duration } else { $defaultDuration } + $durationDisplay = if ($isDurationStored) { $duration } else { "$defaultDuration (default)" } + $durationOk = $MinimumLockoutDurationSeconds -eq 0 -or $effectiveDuration -ge $MinimumLockoutDurationSeconds + $testResult = $thresholdOk -and $durationOk $passText = "The lockout threshold is $effective." - $failText = "The lockout threshold is $effective. It should be $MaximumLockoutThreshold or less." + $failText = if (-not $thresholdOk) { "The lockout threshold is $effective. It should be $MaximumLockoutThreshold or less." } else { '' } + if ($MinimumLockoutDurationSeconds -gt 0) { + $passText += " Accounts stay locked for $effectiveDuration seconds." + if (-not $durationOk) { $failText = "$failText Accounts stay locked for $effectiveDuration seconds. It should be $MinimumLockoutDurationSeconds seconds or more.".Trim() } + } - $resultMd = "| Setting | Value | Maximum | Result |`n" + $resultMd = "| Setting | Value | Required | Result |`n" $resultMd += "| --- | --- | --- | --- |`n" - $resultMd += "| Lockout threshold | $display | $MaximumLockoutThreshold | $(if ($testResult) { '✅ Pass' } else { '❌ Fail' }) |`n" + $resultMd += "| Lockout threshold | $display | $MaximumLockoutThreshold or less | $(if ($thresholdOk) { '✅ Pass' } else { '❌ Fail' }) |`n" + if ($MinimumLockoutDurationSeconds -gt 0) { + $resultMd += "| Lockout duration (seconds) | $durationDisplay | $MinimumLockoutDurationSeconds or more | $(if ($durationOk) { '✅ Pass' } else { '❌ Fail' }) |`n" + } if ($testResult) { $testResultMarkdown = "Well done. $passText`n`n%TestResult%" diff --git a/tests/cisa/entra/Test.CISA.MS.AAD.4.1.ps1 b/tests/cisa/entra/Test.CISA.MS.AAD.4.1.ps1 index a5dc0e2a22..f2576ee5dc 100644 --- a/tests/cisa/entra/Test.CISA.MS.AAD.4.1.ps1 +++ b/tests/cisa/entra/Test.CISA.MS.AAD.4.1.ps1 @@ -6,6 +6,9 @@ .DESCRIPTION Security logs SHALL be sent to the agency's security operations center for monitoring. + By default the check requires the log categories that the CISA SCuBA baseline names. RequiredLogCategory + replaces that list, for a benchmark that names other categories. + .EXAMPLE Test-MtCisaDiagnosticSettings @@ -33,7 +36,10 @@ )] [CmdletBinding()] [OutputType([bool])] - param() + param( + # The log categories that a diagnostic setting must send. Empty uses the categories CISA names. + [string[]] $RequiredLogCategory + ) $cisaLogs = @( "AuditLogs", @@ -49,6 +55,9 @@ "MicrosoftGraphActivityLogs", "ManagedIdentitySignInLogs" ) + if ($RequiredLogCategory) { + $cisaLogs = @($RequiredLogCategory) + } $logs = Invoke-AzRestMethod -Method GET -Path "/providers/microsoft.aadiam/diagnosticSettingsCategories?api-version=2017-04-01-preview" $logs = ($logs.Content|ConvertFrom-Json).value diff --git a/tests/disa/README.md b/tests/disa/README.md new file mode 100644 index 0000000000..b70b77a544 --- /dev/null +++ b/tests/disa/README.md @@ -0,0 +1,55 @@ +# DISA STIGs + +Checks that verify a Microsoft 365 tenant against the +[Security Technical Implementation Guides](https://public.cyber.mil/stigs/) (STIGs) that the US Defense Information +Systems Agency (DISA) publishes for Microsoft's cloud services: + +| Framework key | STIG | Release | +| --- | --- | --- | +| `disa-stig-entra-id` | Microsoft Entra ID STIG | V1R2 (30 Sep 2026) | +| `disa-stig-intune-mdm` | Microsoft Intune MDM Service Desktop and Mobile STIG | V1R2 (01 Jul 2026) | +| `disa-stig-intune-desktop` | Microsoft Intune MDM Service Desktop STIG | V1R1 (24 Sep 2024) | + +DISA publishes no STIG for Exchange Online, SharePoint Online, Teams or Purview. The Defender for Endpoint and +Active Directory STIGs are not covered yet, and the device STIGs (Windows 11 and others) are checked on devices, +not in the tenant. + +## Layout + +- `suite.json` declares the suite (`DISA`) and its three frameworks. +- `frameworks/.json` is the catalogue of each STIG: one entry per rule with its `Id` (the vulnerability ID, + `V-270233`), `Category` (CAT I to CAT III), `RuleId` and `StigId`, and the NIST SP 800-53 Rev. 5 controls of the + CCIs the rule lists as `Related`. It holds every rule of the STIG, including those that no test checks. +- `Test.DISA..ps1` and `.md` are the checks, in one folder, because the rules of one STIG are fixed in more + than one product (the Intune STIGs ask for settings in Microsoft Entra ID and the Microsoft 365 admin center). + +## IDs and mapping + +A check is named after the STIG rule it implements: `DISA.V-270233` implements V-270233. Vulnerability IDs are +unique across STIGs, so the ID also tells you which STIG the rule comes from. The attribute names the rule in its +framework, `Control = 'disa-stig-entra-id:V-270233'`, and the framework file adds the rule's NIST controls to the +result. The `Benchmark` of a result carries the rule's `Category`, `RuleId` and `StigId`. + +## Checks that another suite already has + +Most DISA rules ask for a setting that a CIS, CISA or Maester test already checks. The DISA check is then a shim +that returns that test's result, with DISA's values as parameters where they differ (`DISA.V-270208` runs +CIS.M365.5.2.3.8 with a lockout threshold of 3 and a duration of 900 seconds). Rules the Intune and Entra ID STIGs +share (idle timeout, inactive accounts, lockout, MFA, password lifetime) are checked once and the other rules are +shims. See +[Tests that another suite already has](https://maester.dev/docs/next/writing-tests#tests-that-another-suite-already-has). + +## Rules without a check + +| Rule | Why | +| --- | --- | +| V-267315 (Intune Desktop: DoD banner the user must acknowledge) | The Entra sign-in page text shows a banner but cannot force an acknowledgement; DISA.V-270209 checks the banner. | +| V-267372, V-267373, V-267374, V-267375, V-267379 (Intune Desktop: notify the ISSO of account creation, change, disabling, removal and enabling) | DISA expects alerts from a log management server or SIEM, which the tenant does not show. | + +## DoD-specific and conflicting rules + +- The DoD Notice and Consent Banner (`DISA.V-270209`) fails outside DoD by design. +- The password lifetime rules (`DISA.V-270239`, 180 days; `DISA.V-267355`, 60 days) conflict with CIS.M365.1.3.1, + which asks that passwords never expire. A tenant passes one side at most. + +The checks with logic of their own are `Preview` until they have run against a DoD tenant. diff --git a/tests/disa/Test.DISA.V-267303.md b/tests/disa/Test.DISA.V-267303.md new file mode 100644 index 0000000000..45b006cd8d --- /dev/null +++ b/tests/disa/Test.DISA.V-267303.md @@ -0,0 +1,19 @@ +The Microsoft 365 idle session timeout signs users out after 15 minutes of inactivity or less. (DISA Microsoft Intune MDM Service Desktop STIG, V-267303, CAT II). + +A session left open on an unattended computer can be used by anyone who sits down at it. The Intune admin center follows the idle session timeout of Microsoft 365. + +The newer Intune MDM STIG has the same rule, so this test runs [DISA.V-273867](https://maester.dev/docs/tests/DISA.V-273867): the idle session timeout must be 15 minutes or less. + +#### Remediation action + +1. In the [Microsoft 365 admin center](https://admin.microsoft.com), go to **Settings** > **Org settings** > **Security & privacy** > **[Idle session timeout](https://admin.microsoft.com/#/Settings/SecurityPrivacy/:/Settings/L1/IdleSessionTimeout)**. +2. Turn on **Turn on to set the period of inactivity for users to be signed off of Microsoft 365 web apps**. +3. Choose **Custom**, set the period to **15 minutes** and select **Save**. + +#### Related links + +* [DISA Microsoft Intune MDM Service Desktop STIG: V-267303](https://cyber.trackr.live/stig/Intune_Service_Desktop/1/1/V-267303) +* [Idle session timeout for Microsoft 365](https://learn.microsoft.com/microsoft-365/admin/manage/idle-session-timeout-web-apps) + + +%TestResult% diff --git a/tests/disa/Test.DISA.V-267303.ps1 b/tests/disa/Test.DISA.V-267303.ps1 new file mode 100644 index 0000000000..8775406a0e --- /dev/null +++ b/tests/disa/Test.DISA.V-267303.ps1 @@ -0,0 +1,45 @@ +function Test-MtDisaIntuneDesktopIdleSessionTimeout { + <# + .SYNOPSIS + Checks that the Microsoft 365 idle session timeout is 15 minutes or less. + + .DESCRIPTION + DISA Microsoft Intune MDM Service Desktop STIG (V-267303, CAT II): Microsoft Intune service must initiate a session lock after a 15-minute period of inactivity. + + This test runs DISA.V-273867 (Test-MtDisaIdleSessionTimeout). See the guide for what DISA asks and how the two compare. + + .EXAMPLE + Test-MtDisaIntuneDesktopIdleSessionTimeout + + Returns the result of DISA.V-273867 with DISA's values. + + .LINK + https://maester.dev/docs/tests/DISA.V-267303 + #> + [MaesterTest( + Id = 'DISA.V-267303', + Title = 'Microsoft Intune service must initiate a session lock after a 15-minute period of inactivity.', + Product = 'microsoft-365', + RelatedProduct = 'entra', + Feature = 'organization-settings', + Area = 'authentication', + ResourceType = 'Tenant', + Severity = 'Medium', + UserImpact = 'Medium', + ImplementationCost = 'Low', + Mitre = 'T1550.004', + Control = 'disa-stig-intune-desktop:V-267303', + Service = 'Graph', + Lifecycle = 'Preview', + Author = 'merill' + )] + [CmdletBinding()] + [OutputType([bool])] + param( + # Longest idle session timeout that is allowed, in minutes. DISA sets 15. + [ValidateRange(1, 1440)] + [int] $MaximumIdleTimeoutMinutes = 15 + ) + + return Test-MtDisaIdleSessionTimeout -MaximumIdleTimeoutMinutes $MaximumIdleTimeoutMinutes +} diff --git a/tests/disa/Test.DISA.V-267309.md b/tests/disa/Test.DISA.V-267309.md new file mode 100644 index 0000000000..70a164a4b2 --- /dev/null +++ b/tests/disa/Test.DISA.V-267309.md @@ -0,0 +1,18 @@ +No enabled user account has gone 35 days or more without signing in. (DISA Microsoft Intune MDM Service Desktop STIG, V-267309, CAT II). + +Intune administrators and users sign in with Microsoft Entra ID, so DISA's Intune rule for inactive accounts is checked in Entra ID. A dormant account's stolen password is unlikely to be noticed. + +The Entra ID STIG has the same rule and audit script, so this test runs [DISA.V-270204](https://maester.dev/docs/tests/DISA.V-270204) with 35 days. + +#### Remediation action + +1. In the [Microsoft Entra admin center](https://entra.microsoft.com), go to **ID Governance** > **[Access reviews](https://entra.microsoft.com/#view/Microsoft_AAD_ERM/DashboardBlade/~/Controls/fromNav/Identity)** and create a recurring review of inactive users with **Days inactive** set to **35**. +2. Let the review disable accounts that nobody vouches for, or run a scheduled automation that disables the accounts this test lists. + +#### Related links + +* [DISA Microsoft Intune MDM Service Desktop STIG: V-267309](https://cyber.trackr.live/stig/Intune_Service_Desktop/1/1/V-267309) +* [How to manage inactive user accounts](https://learn.microsoft.com/entra/identity/monitoring-health/howto-manage-inactive-user-accounts) + + +%TestResult% diff --git a/tests/disa/Test.DISA.V-267309.ps1 b/tests/disa/Test.DISA.V-267309.ps1 new file mode 100644 index 0000000000..2ac40e4511 --- /dev/null +++ b/tests/disa/Test.DISA.V-267309.ps1 @@ -0,0 +1,45 @@ +function Test-MtDisaIntuneDesktopInactiveAccount { + <# + .SYNOPSIS + Checks that no enabled user account has been inactive for 35 days or more. + + .DESCRIPTION + DISA Microsoft Intune MDM Service Desktop STIG (V-267309, CAT II): Microsoft Intune service must automatically disable accounts after a 35-day period of account inactivity. + + This test runs DISA.V-270204 (Test-MtDisaInactiveAccount). See the guide for what DISA asks and how the two compare. + + .EXAMPLE + Test-MtDisaIntuneDesktopInactiveAccount + + Returns the result of DISA.V-270204 with DISA's values. + + .LINK + https://maester.dev/docs/tests/DISA.V-267309 + #> + [MaesterTest( + Id = 'DISA.V-267309', + Title = 'Microsoft Intune service must automatically disable accounts after a 35-day period of account inactivity.', + Product = 'entra', + Feature = 'identity-governance', + Area = 'identity-lifecycle', + ResourceType = 'User', + Severity = 'Medium', + UserImpact = 'Low', + ImplementationCost = 'Medium', + Mitre = 'T1078.004', + Control = 'disa-stig-intune-desktop:V-267309', + Service = 'Graph', + License = 'AAD_PREMIUM', + Lifecycle = 'Preview', + Author = 'merill' + )] + [CmdletBinding()] + [OutputType([bool])] + param( + # Days without a sign-in after which an account must be disabled. DISA sets 35. + [ValidateRange(1, 365)] + [int] $InactiveDays = 35 + ) + + return Test-MtDisaInactiveAccount -InactiveDays $InactiveDays +} diff --git a/tests/disa/Test.DISA.V-267314.md b/tests/disa/Test.DISA.V-267314.md new file mode 100644 index 0000000000..934edead6c --- /dev/null +++ b/tests/disa/Test.DISA.V-267314.md @@ -0,0 +1,19 @@ +Microsoft Entra smart lockout, which protects Intune sign-ins, locks an account after three failed sign-ins for at least 15 minutes. (DISA Microsoft Intune MDM Service Desktop STIG, V-267314, CAT II). + +Intune sign-ins are handled by Microsoft Entra ID, so the lockout rule is checked there. A low threshold with a long lockout limits online password guessing. + +This test runs the same check as [CIS.M365.5.2.3.8](https://maester.dev/docs/tests/CIS.M365.5.2.3.8) with DISA's values: a lockout threshold of 3 or fewer and a lockout duration of at least 900 seconds. + +#### Remediation action + +1. In the [Microsoft Entra admin center](https://entra.microsoft.com), go to **Entra ID** > **[Authentication methods](https://entra.microsoft.com/#view/Microsoft_AAD_IAM/AuthenticationMethodsMenuBlade/~/PasswordProtection)** > **Password protection**. +2. Set **Lockout threshold** to **3** and **Lockout duration in seconds** to **900** or more. +3. Select **Save**. + +#### Related links + +* [DISA Microsoft Intune MDM Service Desktop STIG: V-267314](https://cyber.trackr.live/stig/Intune_Service_Desktop/1/1/V-267314) +* [Protect user accounts from attacks with Microsoft Entra smart lockout](https://learn.microsoft.com/entra/identity/authentication/howto-password-smart-lockout) + + +%TestResult% diff --git a/tests/disa/Test.DISA.V-267314.ps1 b/tests/disa/Test.DISA.V-267314.ps1 new file mode 100644 index 0000000000..a19fc95247 --- /dev/null +++ b/tests/disa/Test.DISA.V-267314.ps1 @@ -0,0 +1,47 @@ +function Test-MtDisaIntuneDesktopLockout { + <# + .SYNOPSIS + Checks that smart lockout locks an account after three failed sign-ins for at least 15 minutes. + + .DESCRIPTION + DISA Microsoft Intune MDM Service Desktop STIG (V-267314, CAT II): Microsoft Intune service must enforce the limit of three consecutive invalid login attempts by a user during a 15-minute time period. + + This test runs CIS.M365.5.2.3.8 (Test-MtCisSmartLockoutThreshold). See the guide for what DISA asks and how the two compare. + + .EXAMPLE + Test-MtDisaIntuneDesktopLockout + + Returns the result of CIS.M365.5.2.3.8 with DISA's values. + + .LINK + https://maester.dev/docs/tests/DISA.V-267314 + #> + [MaesterTest( + Id = 'DISA.V-267314', + Title = 'Microsoft Intune service must enforce the limit of three consecutive invalid login attempts by a user during a 15-minute time period.', + Product = 'entra', + Feature = 'password-protection', + Area = 'authentication', + ResourceType = 'Tenant', + Severity = 'Medium', + UserImpact = 'Low', + ImplementationCost = 'Low', + Mitre = ('T1110.001', 'T1110.003'), + Control = 'disa-stig-intune-desktop:V-267314', + Service = 'Graph', + Author = 'merill' + )] + [CmdletBinding()] + [OutputType([bool])] + param( + # The most failed sign-ins allowed before an account is locked. DISA sets three. + [ValidateRange(1, 50)] + [int] $MaximumLockoutThreshold = 3, + + # Shortest lockout duration, in seconds. DISA sets 900 (15 minutes). + [ValidateRange(0, 86400)] + [int] $MinimumLockoutDurationSeconds = 900 + ) + + return Test-MtCisSmartLockoutThreshold -MaximumLockoutThreshold $MaximumLockoutThreshold -MinimumLockoutDurationSeconds $MinimumLockoutDurationSeconds +} diff --git a/tests/disa/Test.DISA.V-267334.md b/tests/disa/Test.DISA.V-267334.md new file mode 100644 index 0000000000..55dd6e0b88 --- /dev/null +++ b/tests/disa/Test.DISA.V-267334.md @@ -0,0 +1,20 @@ +An Intune diagnostic setting sends the Intune audit logs to a log store outside Intune. (DISA Microsoft Intune MDM Service Desktop STIG, V-267334, CAT II). + +DISA asks that Intune logs are moved to another server at least every seven days. A diagnostic setting streams them continuously, which meets that. + +This test runs [MT.1100](https://maester.dev/docs/tests/MT.1100), which checks that an Intune diagnostic setting includes the audit logs. A site that exports the logs by hand must show that process instead. + +#### Remediation action + +1. In the [Microsoft Intune admin center](https://intune.microsoft.com), go to **Reports** > **[Diagnostic settings](https://intune.microsoft.com/#view/Microsoft_Intune_Enrollment/DiagnosticsSettingsBlade)**. +2. Select **Add diagnostic setting**. +3. Select the **AuditLogs** category (and any other Intune logs you need) and send them to a Log Analytics workspace, a storage account, an event hub or a partner solution. +4. Select **Save**. + +#### Related links + +* [DISA Microsoft Intune MDM Service Desktop STIG: V-267334](https://cyber.trackr.live/stig/Intune_Service_Desktop/1/1/V-267334) +* [Send Intune log data to storage, event hubs, or Log Analytics](https://learn.microsoft.com/intune/intune-service/fundamentals/review-logs-using-azure-monitor) + + +%TestResult% diff --git a/tests/disa/Test.DISA.V-267334.ps1 b/tests/disa/Test.DISA.V-267334.ps1 new file mode 100644 index 0000000000..fc18ac245e --- /dev/null +++ b/tests/disa/Test.DISA.V-267334.ps1 @@ -0,0 +1,40 @@ +function Test-MtDisaIntuneDesktopLogExport { + <# + .SYNOPSIS + Checks that an Intune diagnostic setting sends the audit logs to another store. + + .DESCRIPTION + DISA Microsoft Intune MDM Service Desktop STIG (V-267334, CAT II): Microsoft Intune service must be configured to transfer Intune logs to another server for storage, analysis, and reporting at least every seven days. + + This test runs MT.1100 (Test-MtIntuneDiagnosticSettings). See the guide for what DISA asks and how the two compare. + + .EXAMPLE + Test-MtDisaIntuneDesktopLogExport + + Returns the result of MT.1100 with DISA's values. + + .LINK + https://maester.dev/docs/tests/DISA.V-267334 + #> + [MaesterTest( + Id = 'DISA.V-267334', + Title = 'Microsoft Intune service must be configured to transfer Intune logs to another server for storage, analysis, and reporting at least every seven days.', + Product = 'intune', + Feature = 'tenant-administration', + Area = 'logging-and-detection', + ResourceType = 'Tenant', + Severity = 'High', + UserImpact = 'Low', + ImplementationCost = 'Medium', + Mitre = 'T1685.002', + Control = 'disa-stig-intune-desktop:V-267334', + Service = 'Azure', + License = 'INTUNE_A', + Author = 'merill' + )] + [CmdletBinding()] + [OutputType([bool])] + param() + + return Test-MtIntuneDiagnosticSettings +} diff --git a/tests/disa/Test.DISA.V-267341.md b/tests/disa/Test.DISA.V-267341.md new file mode 100644 index 0000000000..f8eac96c4b --- /dev/null +++ b/tests/disa/Test.DISA.V-267341.md @@ -0,0 +1,20 @@ +An enabled Conditional Access policy requires multifactor authentication for all users, including everyone who signs in to Intune. (DISA Microsoft Intune MDM Service Desktop STIG, V-267341, CAT II). + +Intune sign-ins are handled by Microsoft Entra ID, so multifactor authentication for Intune users is a Conditional Access policy for all users. + +This test runs [CIS.M365.5.2.2.2](https://maester.dev/docs/tests/CIS.M365.5.2.2.2), which checks for an enabled Conditional Access policy that requires MFA for all users. + +#### Remediation action + +1. In the [Microsoft Entra admin center](https://entra.microsoft.com), go to **Entra ID** > **Conditional Access** > **[Policies](https://entra.microsoft.com/#view/Microsoft_AAD_ConditionalAccess/ConditionalAccessBlade/~/Policies)**. +2. Create a policy (or use the **Require multifactor authentication for all users** template) that includes **All users** and **All resources** and grants access only with **Require multifactor authentication** or an authentication strength. +3. Exclude only your emergency access accounts, and document each exclusion with your authorizing official. +4. Set **Enable policy** to **On** and select **Save**. + +#### Related links + +* [DISA Microsoft Intune MDM Service Desktop STIG: V-267341](https://cyber.trackr.live/stig/Intune_Service_Desktop/1/1/V-267341) +* [Require multifactor authentication for all users](https://learn.microsoft.com/entra/identity/conditional-access/policy-all-users-mfa-strength) + + +%TestResult% diff --git a/tests/disa/Test.DISA.V-267341.ps1 b/tests/disa/Test.DISA.V-267341.ps1 new file mode 100644 index 0000000000..f838e10385 --- /dev/null +++ b/tests/disa/Test.DISA.V-267341.ps1 @@ -0,0 +1,40 @@ +function Test-MtDisaIntuneDesktopMfa { + <# + .SYNOPSIS + Checks that a Conditional Access policy requires multifactor authentication for all users. + + .DESCRIPTION + DISA Microsoft Intune MDM Service Desktop STIG (V-267341, CAT II): Microsoft Intune service must be configured to use multifactor authentication for network access to privileged and nonprivileged accounts. + + This test runs CIS.M365.5.2.2.2 (Test-MtCisMfaForEveryUser). See the guide for what DISA asks and how the two compare. + + .EXAMPLE + Test-MtDisaIntuneDesktopMfa + + Returns the result of CIS.M365.5.2.2.2 with DISA's values. + + .LINK + https://maester.dev/docs/tests/DISA.V-267341 + #> + [MaesterTest( + Id = 'DISA.V-267341', + Title = 'Microsoft Intune service must be configured to use multifactor authentication for network access to privileged and nonprivileged accounts.', + Product = 'entra', + Feature = 'conditional-access', + Area = 'authentication', + ResourceType = 'Tenant', + Severity = 'High', + UserImpact = 'Medium', + ImplementationCost = 'Medium', + Mitre = ('T1078.004', 'T1110'), + Control = 'disa-stig-intune-desktop:V-267341', + Service = 'Graph', + License = 'AAD_PREMIUM', + Author = 'merill' + )] + [CmdletBinding()] + [OutputType([bool])] + param() + + return Test-MtCisMfaForEveryUser +} diff --git a/tests/disa/Test.DISA.V-267355.md b/tests/disa/Test.DISA.V-267355.md new file mode 100644 index 0000000000..817770d7e0 --- /dev/null +++ b/tests/disa/Test.DISA.V-267355.md @@ -0,0 +1,18 @@ +Passwords expire after 60 days or less on every verified, managed domain. (DISA Microsoft Intune MDM Service Desktop STIG, V-267355, CAT II). + +Intune sign-ins use Microsoft Entra ID passwords, so the password lifetime is set on the tenant's domains. The Intune STIG asks for 60 days, shorter than the 180 days of the newer Entra ID STIG. + +This test runs [DISA.V-270239](https://maester.dev/docs/tests/DISA.V-270239) with a maximum of 60 days (`MaximumPasswordAgeDays`). Like that test, it conflicts with [CIS.M365.1.3.1](https://maester.dev/docs/tests/CIS.M365.1.3.1), which asks that passwords never expire. + +#### Remediation action + +1. In the [Microsoft 365 admin center](https://admin.microsoft.com), go to **Settings** > **Org settings** > **Security & privacy** > **[Password expiration policy](https://admin.microsoft.com/#/Settings/SecurityPrivacy/:/Settings/L1/PasswordPolicy)**. +2. Clear **Set passwords to never expire (recommended)**, set **Days before passwords expire** to **60** or less, and select **Save**. + +#### Related links + +* [DISA Microsoft Intune MDM Service Desktop STIG: V-267355](https://cyber.trackr.live/stig/Intune_Service_Desktop/1/1/V-267355) +* [Set the password expiration policy for your organization](https://learn.microsoft.com/microsoft-365/admin/manage/set-password-expiration-policy) + + +%TestResult% diff --git a/tests/disa/Test.DISA.V-267355.ps1 b/tests/disa/Test.DISA.V-267355.ps1 new file mode 100644 index 0000000000..cdb5468c0e --- /dev/null +++ b/tests/disa/Test.DISA.V-267355.ps1 @@ -0,0 +1,45 @@ +function Test-MtDisaIntuneDesktopPasswordLifetime { + <# + .SYNOPSIS + Checks that passwords expire after 60 days or less on every verified, managed domain. + + .DESCRIPTION + DISA Microsoft Intune MDM Service Desktop STIG (V-267355, CAT II): Microsoft Intune service must enforce a 60-day maximum password lifetime restriction. + + This test runs DISA.V-270239 (Test-MtDisaPasswordLifetime). See the guide for what DISA asks and how the two compare. + + .EXAMPLE + Test-MtDisaIntuneDesktopPasswordLifetime + + Returns the result of DISA.V-270239 with DISA's values. + + .LINK + https://maester.dev/docs/tests/DISA.V-267355 + #> + [MaesterTest( + Id = 'DISA.V-267355', + Title = 'Microsoft Intune service must enforce a 60-day maximum password lifetime restriction.', + Product = 'microsoft-365', + RelatedProduct = 'entra', + Feature = 'organization-settings', + Area = 'authentication', + ResourceType = 'Domain', + Severity = 'Low', + UserImpact = 'Medium', + ImplementationCost = 'Low', + Mitre = 'T1078.004', + Control = 'disa-stig-intune-desktop:V-267355', + Service = 'Graph', + Lifecycle = 'Preview', + Author = 'merill' + )] + [CmdletBinding()] + [OutputType([bool])] + param( + # Longest password lifetime that is allowed, in days. This STIG sets 60. + [ValidateRange(1, 730)] + [int] $MaximumPasswordAgeDays = 60 + ) + + return Test-MtDisaPasswordLifetime -MaximumPasswordAgeDays $MaximumPasswordAgeDays +} diff --git a/tests/disa/Test.DISA.V-270200.md b/tests/disa/Test.DISA.V-270200.md new file mode 100644 index 0000000000..85ad3feb14 --- /dev/null +++ b/tests/disa/Test.DISA.V-270200.md @@ -0,0 +1,20 @@ +Idle sessions are signed out after 15 minutes of inactivity or less. (DISA Microsoft Entra ID STIG, V-270200, CAT II). + +A session left open on an unattended computer can be used by anyone who sits down at it. DISA asks Microsoft Entra ID to lock a session after 15 minutes without activity. + +The STIG's check reads the directory-level idle timeout of the Azure portal (**Settings** > **Signing out + notifications**), which has no documented API. Microsoft 365 applies its idle session timeout to the Azure portal as well, unless the portal sets its own value, so this test runs [DISA.V-273867](https://maester.dev/docs/tests/DISA.V-273867), which reads that timeout, with a maximum of 15 minutes. Check the portal setting by hand if it is configured there. + +#### Remediation action + +1. In the [Microsoft 365 admin center](https://admin.microsoft.com), go to **Settings** > **Org settings** > **Security & privacy** > **[Idle session timeout](https://admin.microsoft.com/#/Settings/SecurityPrivacy/:/Settings/L1/IdleSessionTimeout)**. +2. Turn on **Turn on to set the period of inactivity for users to be signed off of Microsoft 365 web apps**. +3. Choose **Custom**, set the period to **15 minutes** and select **Save**. +4. In the [Azure portal](https://portal.azure.com), select the gear icon > **Signing out + notifications**, select **Enable directory level idle timeout** and set it to **15 minutes**. + +#### Related links + +* [DISA Microsoft Entra ID STIG: V-270200](https://cyber.trackr.live/stig/Entra_ID/1/2/V-270200) +* [Idle session timeout for Microsoft 365](https://learn.microsoft.com/microsoft-365/admin/manage/idle-session-timeout-web-apps) + + +%TestResult% diff --git a/tests/disa/Test.DISA.V-270200.ps1 b/tests/disa/Test.DISA.V-270200.ps1 new file mode 100644 index 0000000000..8ff3905b8c --- /dev/null +++ b/tests/disa/Test.DISA.V-270200.ps1 @@ -0,0 +1,45 @@ +function Test-MtDisaEntraIdleSessionTimeout { + <# + .SYNOPSIS + Checks that idle sessions are signed out after 15 minutes of inactivity or less. + + .DESCRIPTION + DISA Microsoft Entra ID STIG (V-270200, CAT II): Microsoft Entra ID must initiate a session lock after a 15-minute period of inactivity. + + This test runs DISA.V-273867 (Test-MtDisaIdleSessionTimeout). See the guide for what DISA asks and how the two compare. + + .EXAMPLE + Test-MtDisaEntraIdleSessionTimeout + + Returns the result of DISA.V-273867 with DISA's values. + + .LINK + https://maester.dev/docs/tests/DISA.V-270200 + #> + [MaesterTest( + Id = 'DISA.V-270200', + Title = 'Microsoft Entra ID must initiate a session lock after a 15-minute period of inactivity.', + Product = 'microsoft-365', + RelatedProduct = 'entra', + Feature = 'organization-settings', + Area = 'authentication', + ResourceType = 'Tenant', + Severity = 'Medium', + UserImpact = 'Medium', + ImplementationCost = 'Low', + Mitre = 'T1550.004', + Control = 'disa-stig-entra-id:V-270200', + Service = 'Graph', + Lifecycle = 'Preview', + Author = 'merill' + )] + [CmdletBinding()] + [OutputType([bool])] + param( + # Longest idle session timeout that is allowed, in minutes. DISA sets 15. + [ValidateRange(1, 1440)] + [int] $MaximumIdleTimeoutMinutes = 15 + ) + + return Test-MtDisaIdleSessionTimeout -MaximumIdleTimeoutMinutes $MaximumIdleTimeoutMinutes +} diff --git a/tests/disa/Test.DISA.V-270204.md b/tests/disa/Test.DISA.V-270204.md new file mode 100644 index 0000000000..cbeca670bd --- /dev/null +++ b/tests/disa/Test.DISA.V-270204.md @@ -0,0 +1,22 @@ +No enabled user account in Microsoft Entra ID has gone 35 days or more without signing in (DISA Microsoft Entra ID STIG, V-270204, CAT II). + +Accounts that nobody uses are a gift to an attacker: a stolen or guessed password for a dormant account is unlikely to be noticed, because its owner never sees the sign-in prompts, alerts or mailbox changes. DISA asks that accounts are disabled after 35 days of inactivity. + +The check reads every enabled user, members and guests, as the STIG's audit procedure does, and lists those whose last interactive sign-in is older than 35 days (`InactiveDays`), or who never signed in and were created more than 35 days ago. Microsoft Entra ID does not disable inactive accounts by itself, so the fix is a recurring process. [ASD.ISM-1648](https://maester.dev/docs/tests/ASD.ISM-1648) checks the same for privileged users with a 45-day limit. + +Accounts that must stay enabled without signing in, such as emergency access accounts, need the exception documented with your authorizing official; leave them enabled and expect them in this list. + +#### Remediation action + +1. In the [Microsoft Entra admin center](https://entra.microsoft.com), go to **ID Governance** > **[Access reviews](https://entra.microsoft.com/#view/Microsoft_AAD_ERM/DashboardBlade/~/Controls/fromNav/Identity)** and create a review of inactive users (**Inactive users (on tenant level) only**, with **Days inactive** set to **35**). +2. Set the review to recur, and set **If reviewers don't respond** to **Remove access** or use the auto-apply option so that accounts nobody vouches for are disabled. +3. Alternatively, run a scheduled automation that disables the accounts this test lists. + +#### Related links + +* [DISA Microsoft Entra ID STIG: V-270204](https://cyber.trackr.live/stig/Entra_ID/1/2/V-270204) +* [How to manage inactive user accounts](https://learn.microsoft.com/entra/identity/monitoring-health/howto-manage-inactive-user-accounts) +* [Create an access review of groups and applications](https://learn.microsoft.com/entra/id-governance/create-access-review) + + +%TestResult% diff --git a/tests/disa/Test.DISA.V-270204.ps1 b/tests/disa/Test.DISA.V-270204.ps1 new file mode 100644 index 0000000000..0161ab840f --- /dev/null +++ b/tests/disa/Test.DISA.V-270204.ps1 @@ -0,0 +1,81 @@ +function Test-MtDisaInactiveAccount { + <# + .SYNOPSIS + Checks that no enabled user account has been inactive for 35 days or more. + + .DESCRIPTION + The DISA Microsoft Entra ID STIG (V-270204) asks that accounts are disabled automatically after 35 days of + inactivity. Its check lists the enabled users whose last interactive sign-in (signInActivity.lastSignInDateTime) + is older than 35 days, or who never signed in and were created more than 35 days ago, and is a finding when any + such account is still enabled. + + This check does the same: it reads every enabled user, members and guests, and fails when one of them is + inactive for the given number of days (35 by default). Microsoft Entra ID has no setting that disables + accounts by itself, so the fix is a process (an access review of inactive users, or an automation) that + disables them. + + ASD.ISM-1648 reads the same sign-in data for privileged users only, so this is a test of its own. + + .EXAMPLE + Test-MtDisaInactiveAccount + + Returns true when every enabled user signed in within the last 35 days. + + .LINK + https://maester.dev/docs/tests/DISA.V-270204 + #> + [MaesterTest( + Id = 'DISA.V-270204', + Title = 'Microsoft Entra ID must automatically disable accounts after a 35-day period of account inactivity.', + Product = 'entra', + Feature = 'identity-governance', + Area = 'identity-lifecycle', + ResourceType = 'User', + Severity = 'Medium', + UserImpact = 'Low', + ImplementationCost = 'Medium', + Mitre = 'T1078.004', + Control = 'disa-stig-entra-id:V-270204', + Service = 'Graph', + License = 'AAD_PREMIUM', + Lifecycle = 'Preview', + Author = 'merill' + )] + [CmdletBinding()] + [OutputType([bool])] + param( + # Days without a sign-in after which an account must be disabled. + [ValidateRange(1, 365)] + [int] $InactiveDays = 35 + ) + + $cutoff = [datetime]::UtcNow.AddDays(-$InactiveDays) + $users = @(Invoke-MtGraphRequest -RelativeUri 'users' -Filter 'accountEnabled eq true' -Select id, userPrincipalName, displayName, userType, accountEnabled, createdDateTime, signInActivity) + $inactive = foreach ($user in $users) { + if ($user.accountEnabled -ne $true) { continue } + # The STIG's audit reads the interactive sign-in only. + $lastSignIn = Get-MtUserLastSignIn -User $user -InteractiveOnly + $isInactive = if ($lastSignIn) { $lastSignIn -lt $cutoff } else { $user.createdDateTime -and ([datetime]$user.createdDateTime).ToUniversalTime() -lt $cutoff } + if ($isInactive) { + [pscustomobject]@{ + userPrincipalName = $user.userPrincipalName + UserType = $user.userType + LastSignIn = if ($lastSignIn) { $lastSignIn.ToString('yyyy-MM-dd') } else { 'Never' } + } + } + } + $inactive = @($inactive) + $testResult = $inactive.Count -eq 0 + + if ($testResult) { + $testResultMarkdown = "Well done. Every enabled user signed in within the last $InactiveDays days ($($users.Count) users checked)." + } else { + $shown = @($inactive | Sort-Object LastSignIn, userPrincipalName | Select-Object -First 100) + $table = "| User | Type | Last interactive sign-in |`n| --- | --- | --- |`n" + foreach ($user in $shown) { $table += "| $(Get-MtSafeMarkdown $user.userPrincipalName) | $($user.UserType) | $($user.LastSignIn) |`n" } + if ($inactive.Count -gt $shown.Count) { $table += "`nThe first $($shown.Count) of $($inactive.Count) accounts are shown.`n" } + $testResultMarkdown = "$($inactive.Count) enabled account(s) have not signed in for $InactiveDays days or more. Disable them, or document why they must stay enabled.`n`n$table" + } + Add-MtTestResultDetail -Result $testResultMarkdown + return $testResult +} diff --git a/tests/disa/Test.DISA.V-270208.md b/tests/disa/Test.DISA.V-270208.md new file mode 100644 index 0000000000..9380f959d8 --- /dev/null +++ b/tests/disa/Test.DISA.V-270208.md @@ -0,0 +1,19 @@ +Microsoft Entra smart lockout locks an account after three failed sign-ins, for at least 15 minutes. (DISA Microsoft Entra ID STIG, V-270208, CAT II). + +Online password guessing is cheap. A low lockout threshold with a long lockout duration limits how many passwords an attacker can try against each account. + +This test runs the same check as [CIS.M365.5.2.3.8](https://maester.dev/docs/tests/CIS.M365.5.2.3.8) with DISA's values: a lockout threshold of 3 or fewer (`MaximumLockoutThreshold`) and a lockout duration of at least 900 seconds (`MinimumLockoutDurationSeconds`). CIS allows a threshold of 10 and does not check the duration. The Microsoft defaults (10 attempts, 60 seconds) fail. + +#### Remediation action + +1. In the [Microsoft Entra admin center](https://entra.microsoft.com), go to **Entra ID** > **[Authentication methods](https://entra.microsoft.com/#view/Microsoft_AAD_IAM/AuthenticationMethodsMenuBlade/~/PasswordProtection)** > **Password protection**. +2. Set **Lockout threshold** to **3** and **Lockout duration in seconds** to **900** or more. +3. Select **Save**. + +#### Related links + +* [DISA Microsoft Entra ID STIG: V-270208](https://cyber.trackr.live/stig/Entra_ID/1/2/V-270208) +* [Protect user accounts from attacks with Microsoft Entra smart lockout](https://learn.microsoft.com/entra/identity/authentication/howto-password-smart-lockout) + + +%TestResult% diff --git a/tests/disa/Test.DISA.V-270208.ps1 b/tests/disa/Test.DISA.V-270208.ps1 new file mode 100644 index 0000000000..88a5c4bb51 --- /dev/null +++ b/tests/disa/Test.DISA.V-270208.ps1 @@ -0,0 +1,47 @@ +function Test-MtDisaEntraLockout { + <# + .SYNOPSIS + Checks that smart lockout locks an account after three failed sign-ins for at least 15 minutes. + + .DESCRIPTION + DISA Microsoft Entra ID STIG (V-270208, CAT II): Microsoft Entra ID must enforce the limit of three consecutive invalid logon attempts by a user during a 15-minute time period. + + This test runs CIS.M365.5.2.3.8 (Test-MtCisSmartLockoutThreshold). See the guide for what DISA asks and how the two compare. + + .EXAMPLE + Test-MtDisaEntraLockout + + Returns the result of CIS.M365.5.2.3.8 with DISA's values. + + .LINK + https://maester.dev/docs/tests/DISA.V-270208 + #> + [MaesterTest( + Id = 'DISA.V-270208', + Title = 'Microsoft Entra ID must enforce the limit of three consecutive invalid logon attempts by a user during a 15-minute time period.', + Product = 'entra', + Feature = 'password-protection', + Area = 'authentication', + ResourceType = 'Tenant', + Severity = 'Medium', + UserImpact = 'Low', + ImplementationCost = 'Low', + Mitre = ('T1110.001', 'T1110.003'), + Control = 'disa-stig-entra-id:V-270208', + Service = 'Graph', + Author = 'merill' + )] + [CmdletBinding()] + [OutputType([bool])] + param( + # The most failed sign-ins allowed before an account is locked. DISA sets three. + [ValidateRange(1, 50)] + [int] $MaximumLockoutThreshold = 3, + + # Shortest lockout duration, in seconds. DISA sets 900 (15 minutes). + [ValidateRange(0, 86400)] + [int] $MinimumLockoutDurationSeconds = 900 + ) + + return Test-MtCisSmartLockoutThreshold -MaximumLockoutThreshold $MaximumLockoutThreshold -MinimumLockoutDurationSeconds $MinimumLockoutDurationSeconds +} diff --git a/tests/disa/Test.DISA.V-270209.md b/tests/disa/Test.DISA.V-270209.md new file mode 100644 index 0000000000..f209d4ec2d --- /dev/null +++ b/tests/disa/Test.DISA.V-270209.md @@ -0,0 +1,22 @@ +The Microsoft Entra sign-in page shows the Standard Mandatory DoD Notice and Consent Banner (DISA Microsoft Entra ID STIG, V-270209, CAT II). + +DoD information systems must tell every user, before they sign in, that the system is a U.S. Government system, that use is monitored, and that they consent to the terms. In Microsoft Entra ID the banner goes in the **Sign-in page text** of the default company branding, which appears on the sign-in page of every Microsoft cloud app. + +The check reads the sign-in page text and passes when it contains the banner: by default the opening sentence of the full banner, or the short banner ("I've read & consent to terms in IS user agreem't.") that DoD allows where space is limited. The field holds 1,024 characters at most, so the full banner may not fit. To look for a different text, set `RequiredText`. + +The banner is a DoD requirement. Outside DoD this test fails by design; leave it out of your runs. + +#### Remediation action + +1. In the [Microsoft Entra admin center](https://entra.microsoft.com), go to **Entra ID** > **Custom branding** > **[Company branding](https://entra.microsoft.com/#view/Microsoft_AAD_IAM/CompanyBrandingMenuBlade/~/CompanyBranding)**. +2. Edit the **Default sign-in experience** (or select **Customize** if there is none yet). +3. On the **Sign-in form** tab, enter the DoD Notice and Consent Banner in **Sign-in page text**. +4. Select **Review + save**, then **Save**. + +#### Related links + +* [DISA Microsoft Entra ID STIG: V-270209](https://cyber.trackr.live/stig/Entra_ID/1/2/V-270209) +* [Add company branding to your organization's sign-in page](https://learn.microsoft.com/entra/fundamentals/how-to-customize-branding) + + +%TestResult% diff --git a/tests/disa/Test.DISA.V-270209.ps1 b/tests/disa/Test.DISA.V-270209.ps1 new file mode 100644 index 0000000000..26e46ef99f --- /dev/null +++ b/tests/disa/Test.DISA.V-270209.ps1 @@ -0,0 +1,82 @@ +function Test-MtDisaSignInBanner { + <# + .SYNOPSIS + Checks that the Microsoft Entra sign-in page shows the Standard Mandatory DoD Notice and Consent Banner. + + .DESCRIPTION + The DISA Microsoft Entra ID STIG (V-270209) asks that the Standard Mandatory DoD Notice and Consent Banner is + displayed before access is granted. Its check reads the "Sign-in page text" of the default company branding + and is a finding when the banner text is not there. + + This check reads the sign-in page text of the default company branding (organizationalBranding, + signInPageText) and passes when it contains one of the given texts. By default it looks for the opening + sentence of the full banner and for the short banner that DoD allows where space is limited; the field holds + 1,024 characters at most. Comparison ignores case and runs of white space. + + The banner is a DoD requirement, so this test is meant for DoD tenants. + + .EXAMPLE + Test-MtDisaSignInBanner + + Returns true when the sign-in page text contains the DoD banner. + + .LINK + https://maester.dev/docs/tests/DISA.V-270209 + #> + [MaesterTest( + Id = 'DISA.V-270209', + Title = 'Microsoft Entra ID must display the Standard Mandatory DoD Notice and Consent Banner before granting access to the application.', + Product = 'entra', + Feature = 'user-settings', + Area = 'access-control', + ResourceType = 'Tenant', + Severity = 'Low', + UserImpact = 'Low', + ImplementationCost = 'Low', + Mitre = 'None', + Control = 'disa-stig-entra-id:V-270209', + Service = 'Graph', + Lifecycle = 'Preview', + Author = 'merill' + )] + [CmdletBinding()] + [OutputType([bool])] + param( + # Texts of which the sign-in page text must contain one. Empty looks for the full and the short DoD banner. + [string[]] $RequiredText + ) + + if (-not $RequiredText) { + $RequiredText = @( + 'You are accessing a U.S. Government (USG) Information System (IS) that is provided for USG-authorized use only.' + "I've read & consent to terms in IS user agreem't." + ) + } + + $normalize = { param([string] $Text) ($Text -replace '\s+', ' ').Trim() } + $organization = @(Invoke-MtGraphRequest -RelativeUri 'organization')[0] + $branding = $null + try { + $branding = Invoke-MtGraphRequest -RelativeUri "organization/$($organization.id)/branding" + } catch { + # A tenant without company branding answers 404. + if ("$_" -notmatch 'NotFound|404') { throw } + } + $pageText = "$($branding.signInPageText)" + $normalizedPage = & $normalize $pageText + $found = @($RequiredText | Where-Object { $_ -and $normalizedPage.IndexOf((& $normalize $_), [System.StringComparison]::OrdinalIgnoreCase) -ge 0 }) + $testResult = $found.Count -gt 0 + + $link = 'https://entra.microsoft.com/#view/Microsoft_AAD_IAM/CompanyBrandingMenuBlade/~/CompanyBranding' + if ($testResult) { + $testResultMarkdown = "Well done. The sign-in page text of the [company branding]($link) shows the DoD Notice and Consent Banner." + } elseif (-not $branding) { + $testResultMarkdown = "The tenant has no [company branding]($link), so the sign-in page shows no banner. Customize the default branding and put the DoD banner in the sign-in page text." + } elseif (-not $pageText) { + $testResultMarkdown = "The [company branding]($link) has no sign-in page text. Put the DoD Notice and Consent Banner there." + } else { + $testResultMarkdown = "The sign-in page text of the [company branding]($link) does not contain the DoD Notice and Consent Banner. It reads:`n`n> $(Get-MtSafeMarkdown $normalizedPage)" + } + Add-MtTestResultDetail -Result $testResultMarkdown + return $testResult +} diff --git a/tests/disa/Test.DISA.V-270227.md b/tests/disa/Test.DISA.V-270227.md new file mode 100644 index 0000000000..4d7542db22 --- /dev/null +++ b/tests/disa/Test.DISA.V-270227.md @@ -0,0 +1,20 @@ +A Microsoft Entra diagnostic setting sends the sign-in, audit and risk logs to a Log Analytics workspace or another log store. (DISA Microsoft Entra ID STIG, V-270227, CAT II). + +Sign-in and audit logs kept only in Microsoft Entra ID are retained for 30 days at most and are not correlated with other sources. Sending them to a SIEM keeps them and lets the security team alert on them. + +This test runs the same check as [CISA.MS.AAD.4.1](https://maester.dev/docs/tests/CISA.MS.AAD.4.1) with DISA's list of categories (`RequiredLogCategory`): SignInLogs, AuditLogs, ServicePrincipalSignInLogs, ManagedIdentitySignInLogs, UserRiskEvents, RiskyUsers, RiskyServicePrincipals and ServicePrincipalRiskEvents. CISA asks for four more. The STIG also asks you to confirm in Microsoft Sentinel, or your SIEM, that logs arrived within the last hour; check that by hand. + +#### Remediation action + +1. In the [Microsoft Entra admin center](https://entra.microsoft.com), go to **Entra ID** > **Monitoring & health** > **[Diagnostic settings](https://entra.microsoft.com/#view/Microsoft_AAD_IAM/DiagnosticSettingsMenuBlade/~/General)**. +2. Select **Add diagnostic setting**, or **Edit setting** on an existing one. +3. Select the eight log categories listed above and send them to a Log Analytics workspace (or another destination your SIEM reads). +4. Select **Save**. + +#### Related links + +* [DISA Microsoft Entra ID STIG: V-270227](https://cyber.trackr.live/stig/Entra_ID/1/2/V-270227) +* [Configure Microsoft Entra diagnostic settings for activity logs](https://learn.microsoft.com/entra/identity/monitoring-health/howto-configure-diagnostic-settings) + + +%TestResult% diff --git a/tests/disa/Test.DISA.V-270227.ps1 b/tests/disa/Test.DISA.V-270227.ps1 new file mode 100644 index 0000000000..f2939f7c12 --- /dev/null +++ b/tests/disa/Test.DISA.V-270227.ps1 @@ -0,0 +1,43 @@ +function Test-MtDisaEntraLogExport { + <# + .SYNOPSIS + Checks that a Microsoft Entra diagnostic setting sends the log categories DISA names. + + .DESCRIPTION + DISA Microsoft Entra ID STIG (V-270227, CAT II): Microsoft Entra ID must be configured to transfer logs to another server for storage, analysis, and reporting. + + This test runs CISA.MS.AAD.4.1 (Test-MtCisaDiagnosticSettings). See the guide for what DISA asks and how the two compare. + + .EXAMPLE + Test-MtDisaEntraLogExport + + Returns the result of CISA.MS.AAD.4.1 with DISA's values. + + .LINK + https://maester.dev/docs/tests/DISA.V-270227 + #> + [MaesterTest( + Id = 'DISA.V-270227', + Title = 'Microsoft Entra ID must be configured to transfer logs to another server for storage, analysis, and reporting.', + Product = 'entra', + Feature = 'monitoring', + Area = 'logging-and-detection', + ResourceType = 'Tenant', + Severity = 'High', + UserImpact = 'Low', + ImplementationCost = 'Medium', + Mitre = 'T1685.002', + Control = 'disa-stig-entra-id:V-270227', + Service = ('Graph', 'Azure'), + License = 'AAD_PREMIUM', + Author = 'merill' + )] + [CmdletBinding()] + [OutputType([bool])] + param( + # The log categories that a diagnostic setting must send. DISA names eight. + [string[]] $RequiredLogCategory = ('SignInLogs', 'AuditLogs', 'ServicePrincipalSignInLogs', 'ManagedIdentitySignInLogs', 'UserRiskEvents', 'RiskyUsers', 'RiskyServicePrincipals', 'ServicePrincipalRiskEvents') + ) + + return Test-MtCisaDiagnosticSettings -RequiredLogCategory $RequiredLogCategory +} diff --git a/tests/disa/Test.DISA.V-270233.md b/tests/disa/Test.DISA.V-270233.md new file mode 100644 index 0000000000..345570dbd0 --- /dev/null +++ b/tests/disa/Test.DISA.V-270233.md @@ -0,0 +1,20 @@ +An enabled Conditional Access policy requires multifactor authentication for all users. (DISA Microsoft Entra ID STIG, V-270233, CAT I). + +A password alone is stolen by phishing, spray or reuse every day. Multifactor authentication for every user is the main control against those attacks, which is why DISA rates this rule CAT I. + +DISA's check looks for an enabled Conditional Access policy that includes all users and requires MFA, with every exclusion documented with the authorizing official. This test runs [CIS.M365.5.2.2.2](https://maester.dev/docs/tests/CIS.M365.5.2.2.2), which checks that policy. Documenting the exclusions is up to you. + +#### Remediation action + +1. In the [Microsoft Entra admin center](https://entra.microsoft.com), go to **Entra ID** > **Conditional Access** > **[Policies](https://entra.microsoft.com/#view/Microsoft_AAD_ConditionalAccess/ConditionalAccessBlade/~/Policies)**. +2. Create a policy (or use the **Require multifactor authentication for all users** template) that includes **All users** and **All resources** and grants access only with **Require multifactor authentication** or an authentication strength. +3. Exclude only your emergency access accounts, and document each exclusion with your authorizing official. +4. Set **Enable policy** to **On** and select **Save**. + +#### Related links + +* [DISA Microsoft Entra ID STIG: V-270233](https://cyber.trackr.live/stig/Entra_ID/1/2/V-270233) +* [Require multifactor authentication for all users](https://learn.microsoft.com/entra/identity/conditional-access/policy-all-users-mfa-strength) + + +%TestResult% diff --git a/tests/disa/Test.DISA.V-270233.ps1 b/tests/disa/Test.DISA.V-270233.ps1 new file mode 100644 index 0000000000..0c17a92b15 --- /dev/null +++ b/tests/disa/Test.DISA.V-270233.ps1 @@ -0,0 +1,40 @@ +function Test-MtDisaEntraMfa { + <# + .SYNOPSIS + Checks that a Conditional Access policy requires multifactor authentication for all users. + + .DESCRIPTION + DISA Microsoft Entra ID STIG (V-270233, CAT I): Microsoft Entra ID must be configured to use multifactor authentication (MFA). + + This test runs CIS.M365.5.2.2.2 (Test-MtCisMfaForEveryUser). See the guide for what DISA asks and how the two compare. + + .EXAMPLE + Test-MtDisaEntraMfa + + Returns the result of CIS.M365.5.2.2.2 with DISA's values. + + .LINK + https://maester.dev/docs/tests/DISA.V-270233 + #> + [MaesterTest( + Id = 'DISA.V-270233', + Title = 'Microsoft Entra ID must be configured to use multifactor authentication (MFA).', + Product = 'entra', + Feature = 'conditional-access', + Area = 'authentication', + ResourceType = 'Tenant', + Severity = 'High', + UserImpact = 'Medium', + ImplementationCost = 'Medium', + Mitre = ('T1078.004', 'T1110'), + Control = 'disa-stig-entra-id:V-270233', + Service = 'Graph', + License = 'AAD_PREMIUM', + Author = 'merill' + )] + [CmdletBinding()] + [OutputType([bool])] + param() + + return Test-MtCisMfaForEveryUser +} diff --git a/tests/disa/Test.DISA.V-270239.md b/tests/disa/Test.DISA.V-270239.md new file mode 100644 index 0000000000..9e05198233 --- /dev/null +++ b/tests/disa/Test.DISA.V-270239.md @@ -0,0 +1,23 @@ +Passwords expire after 180 days or less on every verified, managed domain (DISA Microsoft Entra ID STIG, V-270239, CAT II). + +DISA requires a maximum password lifetime, so a password that leaked without anyone noticing stops working after a known time. In Microsoft 365 the password expiration policy is set per domain, and it applies to the verified domains that are managed by Microsoft Entra ID (federated domains follow the identity provider's policy). + +The check fails when a verified, managed domain never expires passwords or sets a lifetime longer than 180 days (`MaximumPasswordAgeDays`). A domain that stores no period is reported for review, because the API does not say whether the default of 90 days the STIG mentions applies or, as in newer tenants, passwords never expire. + +**This conflicts with CIS.** [CIS.M365.1.3.1](https://maester.dev/docs/tests/CIS.M365.1.3.1) reads the same setting and asks that passwords never expire, as NIST SP 800-63B recommends. A tenant can pass only one of the two tests; run the one your organization is assessed against. + +#### Remediation action + +1. In the [Microsoft 365 admin center](https://admin.microsoft.com), go to **Settings** > **Org settings** > **Security & privacy** > **[Password expiration policy](https://admin.microsoft.com/#/Settings/SecurityPrivacy/:/Settings/L1/PasswordPolicy)**. +2. Clear **Set passwords to never expire (recommended)**. +3. Set **Days before passwords expire** to **180** or less, and select **Save**. + +The admin center sets the period on every domain. To set one domain, use `Update-MgDomain -DomainId -PasswordValidityPeriodInDays 180`. + +#### Related links + +* [DISA Microsoft Entra ID STIG: V-270239](https://cyber.trackr.live/stig/Entra_ID/1/2/V-270239) +* [Set the password expiration policy for your organization](https://learn.microsoft.com/microsoft-365/admin/manage/set-password-expiration-policy) + + +%TestResult% diff --git a/tests/disa/Test.DISA.V-270239.ps1 b/tests/disa/Test.DISA.V-270239.ps1 new file mode 100644 index 0000000000..fefaef6b63 --- /dev/null +++ b/tests/disa/Test.DISA.V-270239.ps1 @@ -0,0 +1,80 @@ +function Test-MtDisaPasswordLifetime { + <# + .SYNOPSIS + Checks that passwords expire after 180 days or less on every verified, managed domain. + + .DESCRIPTION + The DISA Microsoft Entra ID STIG (V-270239) asks for a maximum password lifetime of 180 days. The password + expiration period is stored per domain (passwordValidityPeriodInDays); the STIG's note points to Get-MgDomain to + read it. + + This check reads every verified domain that is managed (not federated) and fails when one of them never expires + passwords or sets a period longer than the given number of days (180 by default). A domain that stores no + period is reported for review: the STIG states that the Microsoft Entra default is 90 days, but tenants + created more recently do not expire passwords by default, and the API does not say which applies. + + CIS.M365.1.3.1 reads the same setting and asks for the opposite, passwords that never expire, following + NIST SP 800-63B. A tenant passes one of the two tests at most. + + .EXAMPLE + Test-MtDisaPasswordLifetime + + Returns true when every verified, managed domain expires passwords after 180 days or less. + + .LINK + https://maester.dev/docs/tests/DISA.V-270239 + #> + [MaesterTest( + Id = 'DISA.V-270239', + Title = 'Microsoft Entra ID must enforce a 180-day maximum password lifetime restriction.', + Product = 'microsoft-365', + RelatedProduct = 'entra', + Feature = 'organization-settings', + Area = 'authentication', + ResourceType = 'Domain', + Severity = 'Low', + UserImpact = 'Medium', + ImplementationCost = 'Low', + Mitre = 'T1078.004', + Control = 'disa-stig-entra-id:V-270239', + Service = 'Graph', + Lifecycle = 'Preview', + Author = 'merill' + )] + [CmdletBinding()] + [OutputType([bool])] + param( + # Longest password lifetime that is allowed, in days. + [ValidateRange(1, 730)] + [int] $MaximumPasswordAgeDays = 180 + ) + + $domains = @(Get-MtDomainPasswordValidity) + $applicable = @($domains | Where-Object IsApplicable) + if ($applicable.Count -eq 0) { + Add-MtTestResultDetail -SkippedBecause NotApplicable + return $null + } + $failing = @($applicable | Where-Object { $_.IsSet -and ($_.NeverExpires -or $_.ValidityDays -gt $MaximumPasswordAgeDays) }) + $unset = @($applicable | Where-Object { -not $_.IsSet }) + $testResult = $failing.Count -eq 0 + + $table = "| Domain | Password lifetime | Result |`n| --- | --- | --- |`n" + foreach ($domain in $domains) { + $value = if (-not $domain.IsSet) { 'Not set' } elseif ($domain.NeverExpires) { 'Never expires' } else { "$($domain.ValidityDays) days" } + $result = if (-not $domain.IsApplicable) { '⏭️ Skip' } elseif ($domain -in $failing) { '❌ Fail' } elseif ($domain -in $unset) { '❔ Review' } else { '✅ Pass' } + $table += "| $($domain.Id) | $value | $result |`n" + } + + if (-not $testResult) { + $testResultMarkdown = "$($failing.Count) verified, managed domain(s) let passwords live longer than $MaximumPasswordAgeDays days, or never expire them.`n`n$table" + Add-MtTestResultDetail -Result $testResultMarkdown + } elseif ($unset.Count -gt 0) { + $testResultMarkdown = "$($unset.Count) domain(s) store no password expiration period, so the API does not show which lifetime applies. Set the period explicitly to $MaximumPasswordAgeDays days or less.`n`n$table" + Add-MtTestResultDetail -Result $testResultMarkdown -Investigate + } else { + $testResultMarkdown = "Well done. Passwords expire after $MaximumPasswordAgeDays days or less on every verified, managed domain.`n`n$table" + Add-MtTestResultDetail -Result $testResultMarkdown + } + return $testResult +} diff --git a/tests/disa/Test.DISA.V-270255.md b/tests/disa/Test.DISA.V-270255.md new file mode 100644 index 0000000000..7fc7f7f69b --- /dev/null +++ b/tests/disa/Test.DISA.V-270255.md @@ -0,0 +1,20 @@ +Every Microsoft Entra role with an active or eligible assignment sends its Privileged Identity Management activation alert to the system administrators and the information system security officer (DISA Microsoft Entra ID STIG, V-270255, CAT II). + +When an eligible user activates a role, Privileged Identity Management can email an alert. Sending it to the people who watch the system (DISA names the SA and the ISSO) means an unexpected activation, such as one made with stolen credentials, is seen while the elevation is still active. DISA asks for this on every role that has an assignment, not only the most privileged ones. + +The check lists the roles that have an active or eligible assignment and reads the **Additional recipients** of each role's **Role activation alert**. A role fails when that list is empty. Set `RequiredRecipient` to the SA and ISSO addresses to require those exact recipients. [CISA.MS.AAD.7.8](https://maester.dev/docs/tests/CISA.MS.AAD.7.8) and [CISA.MS.AAD.7.9](https://maester.dev/docs/tests/CISA.MS.AAD.7.9) read the same alert for the highly privileged roles only. + +#### Remediation action + +1. In the [Microsoft Entra admin center](https://entra.microsoft.com), go to **ID Governance** > **Privileged Identity Management** > **[Microsoft Entra roles](https://entra.microsoft.com/#view/Microsoft_Azure_PIMCommon/ResourceMenuBlade/~/roles/resourceId//resourceType/tenant/provider/aadroles)** > **Settings**. +2. For each role this test lists, select the role and **Edit**. +3. On the **Notification** tab, under **Send notifications when eligible members activate this role**, add the SA and ISSO addresses as **Additional recipients** of the **Role activation alert**. +4. Select **Update**. + +#### Related links + +* [DISA Microsoft Entra ID STIG: V-270255](https://cyber.trackr.live/stig/Entra_ID/1/2/V-270255) +* [Configure Microsoft Entra role settings in Privileged Identity Management](https://learn.microsoft.com/entra/id-governance/privileged-identity-management/pim-how-to-change-default-settings) + + +%TestResult% diff --git a/tests/disa/Test.DISA.V-270255.ps1 b/tests/disa/Test.DISA.V-270255.ps1 new file mode 100644 index 0000000000..4a85c2206c --- /dev/null +++ b/tests/disa/Test.DISA.V-270255.ps1 @@ -0,0 +1,100 @@ +function Test-MtDisaRoleActivationNotification { + <# + .SYNOPSIS + Checks that every directory role with an active or eligible assignment sends its activation alert to additional recipients. + + .DESCRIPTION + The DISA Microsoft Entra ID STIG (V-270255) asks that system administrators and the information system security + officer (ISSO) are notified when privileges are requested. Its check opens the Privileged Identity Management + settings of each Microsoft Entra role that has an active or eligible assignment and verifies that the SA and + ISSO addresses are listed under "Additional recipients" of the "Role activation alert". + + This check lists the roles with an active or eligible assignment and reads the additional recipients of each + role's activation alert. A role fails when it has none or, when RequiredRecipient is set, when one of those + addresses is missing. + + CISA.MS.AAD.7.8 and CISA.MS.AAD.7.9 read the same alert, but only for the roles that CISA counts as highly + privileged, so this is a test of its own. + + .EXAMPLE + Test-MtDisaRoleActivationNotification + + Returns true when every assigned role sends its activation alert to at least one additional recipient. + + .EXAMPLE + Test-MtDisaRoleActivationNotification -RequiredRecipient 'sa@contoso.mil', 'isso@contoso.mil' + + Returns true when every assigned role sends its activation alert to both addresses. + + .LINK + https://maester.dev/docs/tests/DISA.V-270255 + #> + [MaesterTest( + Id = 'DISA.V-270255', + Title = 'Microsoft Entra ID must notify system administrators (SAs) and the information system security officer (ISSO) when privileges are being requested.', + Product = 'entra', + Feature = 'privileged-identity-management', + Area = 'privileged-access', + ResourceType = 'DirectoryRole', + Severity = 'Medium', + UserImpact = 'Low', + ImplementationCost = 'Low', + Mitre = ('T1098.003', 'T1548.005'), + Control = 'disa-stig-entra-id:V-270255', + Service = 'Graph', + License = ('AAD_PREMIUM_P2', 'Entra_Identity_Governance'), + Lifecycle = 'Preview', + Author = 'merill' + )] + [CmdletBinding()] + [OutputType([bool])] + param( + # Email addresses that every role's activation alert must be sent to, such as the SA and the ISSO. Empty accepts any additional recipient. + [string[]] $RequiredRecipient + ) + + $assignments = @((Get-MtDirectoryRoleAssignment).Assignments | Where-Object { $_ }) + $roleIds = @($assignments.roleDefinitionId | Where-Object { $_ } | Sort-Object -Unique) + if ($roleIds.Count -eq 0) { + Add-MtTestResultDetail -SkippedBecause NotApplicable + return $null + } + $names = @{} + foreach ($definition in @(Invoke-MtGraphRequest -RelativeUri 'roleManagement/directory/roleDefinitions' -Select id, displayName)) { + $names[$definition.id] = $definition.displayName + } + + $rows = foreach ($roleId in $roleIds) { + $recipients = @(Get-MtRoleActivationNotificationRecipient -RoleDefinitionId $roleId) + $missing = if ($RequiredRecipient) { + @($RequiredRecipient | Where-Object { $_ -notin $recipients }) + } elseif ($recipients.Count -eq 0) { + @('an additional recipient') + } else { + @() + } + [pscustomobject]@{ + Role = if ($names.ContainsKey($roleId)) { $names[$roleId] } else { $roleId } + Recipients = $recipients + Missing = $missing + } + } + $rows = @($rows | Sort-Object Role) + $failing = @($rows | Where-Object { $_.Missing.Count -gt 0 }) + $testResult = $failing.Count -eq 0 + + $link = 'https://entra.microsoft.com/#view/Microsoft_Azure_PIMCommon/ResourceMenuBlade/~/roles/resourceId//resourceType/tenant/provider/aadroles' + $table = "| Role | Additional recipients of the activation alert | Result |`n| --- | --- | --- |`n" + foreach ($row in $rows) { + $value = if ($row.Recipients.Count -gt 0) { Get-MtSafeMarkdown ($row.Recipients -join ', ') } else { 'None' } + $result = if ($row.Missing.Count -gt 0) { "❌ Missing $(Get-MtSafeMarkdown ($row.Missing -join ', '))" } else { '✅ Pass' } + $table += "| $(Get-MtSafeMarkdown $row.Role) | $value | $result |`n" + } + if ($testResult) { + $testResultMarkdown = "Well done. Every role with an active or eligible assignment sends its [activation alert]($link) to the required recipients.`n`n$table" + } else { + $testResultMarkdown = "$($failing.Count) of $($rows.Count) role(s) with an active or eligible assignment do not send their [activation alert]($link) to the required recipients.`n`n$table" + } + Add-MtTestResultDetail -Result $testResultMarkdown + return $testResult +} diff --git a/tests/disa/Test.DISA.V-270335.md b/tests/disa/Test.DISA.V-270335.md new file mode 100644 index 0000000000..5bd644e010 --- /dev/null +++ b/tests/disa/Test.DISA.V-270335.md @@ -0,0 +1,19 @@ +No privileged Microsoft Entra role has an active assignment that never ends. (DISA Microsoft Entra ID STIG, V-270335, CAT II). + +A permanent active assignment keeps admin rights on an account around the clock, so a stolen session or password gives them straight away. With Privileged Identity Management, users hold the role only when they activate it, for a limited time. + +DISA's check looks at the active assignments of each privileged role and is a finding when one ends **Permanent**. This test runs [CISA.MS.AAD.7.4](https://maester.dev/docs/tests/CISA.MS.AAD.7.4), which checks the roles that CISA counts as highly privileged. Review the other privileged roles in your tenant by hand. + +#### Remediation action + +1. In the [Microsoft Entra admin center](https://entra.microsoft.com), go to **ID Governance** > **Privileged Identity Management** > **[Microsoft Entra roles](https://entra.microsoft.com/#view/Microsoft_Azure_PIMCommon/ResourceMenuBlade/~/roles/resourceId//resourceType/tenant/provider/aadroles)** > **Assignments**. +2. On the **Active assignments** tab, find the assignments whose end time is **Permanent**. +3. Change each one to an eligible assignment, leaving permanent active assignments only on your emergency access accounts. + +#### Related links + +* [DISA Microsoft Entra ID STIG: V-270335](https://cyber.trackr.live/stig/Entra_ID/1/2/V-270335) +* [Start using Privileged Identity Management](https://learn.microsoft.com/entra/id-governance/privileged-identity-management/pim-getting-started) + + +%TestResult% diff --git a/tests/disa/Test.DISA.V-270335.ps1 b/tests/disa/Test.DISA.V-270335.ps1 new file mode 100644 index 0000000000..4d454e3d60 --- /dev/null +++ b/tests/disa/Test.DISA.V-270335.ps1 @@ -0,0 +1,40 @@ +function Test-MtDisaEntraNoPermanentPrivilegedAssignment { + <# + .SYNOPSIS + Checks that no privileged role has a permanent active assignment. + + .DESCRIPTION + DISA Microsoft Entra ID STIG (V-270335, CAT II): Microsoft Entra ID must use Privileged Identity Management (PIM). + + This test runs CISA.MS.AAD.7.4 (Test-MtCisaPermanentRoleAssignment). See the guide for what DISA asks and how the two compare. + + .EXAMPLE + Test-MtDisaEntraNoPermanentPrivilegedAssignment + + Returns the result of CISA.MS.AAD.7.4 with DISA's values. + + .LINK + https://maester.dev/docs/tests/DISA.V-270335 + #> + [MaesterTest( + Id = 'DISA.V-270335', + Title = 'Microsoft Entra ID must use Privileged Identity Management (PIM).', + Product = 'entra', + Feature = 'privileged-identity-management', + Area = 'privileged-access', + ResourceType = 'DirectoryRole', + Severity = 'High', + UserImpact = 'Low', + ImplementationCost = 'Medium', + Mitre = 'T1098.003', + Control = 'disa-stig-entra-id:V-270335', + Service = 'Graph', + License = ('AAD_PREMIUM_P2', 'Entra_Identity_Governance'), + Author = 'merill' + )] + [CmdletBinding()] + [OutputType([bool])] + param() + + return Test-MtCisaPermanentRoleAssignment +} diff --git a/tests/disa/Test.DISA.V-270475.md b/tests/disa/Test.DISA.V-270475.md new file mode 100644 index 0000000000..5d6c590479 --- /dev/null +++ b/tests/disa/Test.DISA.V-270475.md @@ -0,0 +1,19 @@ +Microsoft Entra password protection enforces a custom banned password list that holds entries. (DISA Microsoft Entra ID STIG, V-270475, CAT II). + +Users pick passwords from what is around them: the organization's name, products and places. A custom banned password list stops those words, on top of the global list Microsoft maintains. + +DISA's check requires **Enforce custom list** set to **Yes** and a list that is not empty. This test runs [CIS.M365.5.2.3.2](https://maester.dev/docs/tests/CIS.M365.5.2.3.2), which checks both. + +#### Remediation action + +1. In the [Microsoft Entra admin center](https://entra.microsoft.com), go to **Entra ID** > **[Authentication methods](https://entra.microsoft.com/#view/Microsoft_AAD_IAM/AuthenticationMethodsMenuBlade/~/PasswordProtection)** > **Password protection**. +2. Set **Enforce custom list** to **Yes** and add terms specific to your organization to **Custom banned password list**. +3. Select **Save**. + +#### Related links + +* [DISA Microsoft Entra ID STIG: V-270475](https://cyber.trackr.live/stig/Entra_ID/1/2/V-270475) +* [Eliminate bad passwords using Microsoft Entra Password Protection](https://learn.microsoft.com/entra/identity/authentication/concept-password-ban-bad) + + +%TestResult% diff --git a/tests/disa/Test.DISA.V-270475.ps1 b/tests/disa/Test.DISA.V-270475.ps1 new file mode 100644 index 0000000000..e1f80e56d0 --- /dev/null +++ b/tests/disa/Test.DISA.V-270475.ps1 @@ -0,0 +1,40 @@ +function Test-MtDisaEntraBannedPasswordList { + <# + .SYNOPSIS + Checks that the custom banned password list is enforced and filled in. + + .DESCRIPTION + DISA Microsoft Entra ID STIG (V-270475, CAT II): Microsoft Entra ID must, for password-based authentication, verify when users create or update passwords that the passwords are not found on the list of commonly used, expected, or compromised passwords. + + This test runs CIS.M365.5.2.3.2 (Test-MtCisCustomBannedPasswordList). See the guide for what DISA asks and how the two compare. + + .EXAMPLE + Test-MtDisaEntraBannedPasswordList + + Returns the result of CIS.M365.5.2.3.2 with DISA's values. + + .LINK + https://maester.dev/docs/tests/DISA.V-270475 + #> + [MaesterTest( + Id = 'DISA.V-270475', + Title = 'Microsoft Entra ID must, for password-based authentication, verify when users create or update passwords that the passwords are not found on the list of commonly used, expected, or compromised passwords.', + Product = 'entra', + Feature = 'password-protection', + Area = 'authentication', + ResourceType = 'Tenant', + Severity = 'Medium', + UserImpact = 'Low', + ImplementationCost = 'Low', + Mitre = 'T1110.003', + Control = 'disa-stig-entra-id:V-270475', + Service = 'Graph', + License = 'AAD_PREMIUM', + Author = 'merill' + )] + [CmdletBinding()] + [OutputType([bool])] + param() + + return Test-MtCisCustomBannedPasswordList +} diff --git a/tests/disa/Test.DISA.V-273867.md b/tests/disa/Test.DISA.V-273867.md new file mode 100644 index 0000000000..888177a3e0 --- /dev/null +++ b/tests/disa/Test.DISA.V-273867.md @@ -0,0 +1,20 @@ +The Microsoft 365 idle session timeout signs users out of Microsoft 365 web apps after 15 minutes of inactivity or less (DISA Microsoft Intune MDM Service Desktop and Mobile STIG, V-273867, CAT II). + +A browser session left open on an unattended computer can be used by anyone who sits down at it. The idle session timeout signs a user out of Outlook on the web, SharePoint, OneDrive and the other Microsoft 365 web apps, including the admin centers, after a period without activity. DISA asks for 15 minutes or less, which is shorter than the CIS benchmark's three hours. + +The setting is stored as the tenant's activity-based timeout policy. Its check (`MaximumIdleTimeoutMinutes`, 15 by default) passes when that policy sets a timeout of no more than the allowed number of minutes. [CIS.M365.1.3.2](https://maester.dev/docs/tests/CIS.M365.1.3.2) reads the same policy with a limit in hours and also requires a Conditional Access policy for unmanaged devices, which this STIG does not ask for. + +#### Remediation action + +1. In the [Microsoft 365 admin center](https://admin.microsoft.com), go to **Settings** > **Org settings** > **Security & privacy** > **[Idle session timeout](https://admin.microsoft.com/#/Settings/SecurityPrivacy/:/Settings/L1/IdleSessionTimeout)**. +2. Turn on **Turn on to set the period of inactivity for users to be signed off of Microsoft 365 web apps**. +3. Choose **Custom** and set the period to **15 minutes**. +4. Select **Save**. + +#### Related links + +* [DISA Microsoft Intune MDM Service Desktop and Mobile STIG: V-273867](https://cyber.trackr.live/stig/Intune_MDM_Service_Desktop_&_Mobile/1/2/V-273867) +* [Idle session timeout for Microsoft 365](https://learn.microsoft.com/microsoft-365/admin/manage/idle-session-timeout-web-apps) + + +%TestResult% diff --git a/tests/disa/Test.DISA.V-273867.ps1 b/tests/disa/Test.DISA.V-273867.ps1 new file mode 100644 index 0000000000..000a28bc08 --- /dev/null +++ b/tests/disa/Test.DISA.V-273867.ps1 @@ -0,0 +1,68 @@ +function Test-MtDisaIdleSessionTimeout { + <# + .SYNOPSIS + Checks that the Microsoft 365 idle session timeout signs users out after 15 minutes of inactivity or less. + + .DESCRIPTION + The DISA Microsoft Intune MDM Service Desktop and Mobile STIG (V-273867) asks that the Intune service initiates a + session lock after a 15-minute period of inactivity. Its check reads the idle session timeout of the Microsoft + 365 admin center (Org settings > Security & privacy > Idle session timeout) and requires 15 minutes or less. + + That setting is stored as the tenant's activity-based timeout policy. The check passes when the policy sets a + web session idle timeout of no more than the given number of minutes (15 by default), and fails when there is no + policy or the timeout is longer. + + CIS.M365.1.3.2 reads the same policy, but in hours, with a minimum of one hour, and it also requires a Conditional + Access policy for unmanaged devices, which the STIG does not ask for. So this is a test of its own. + + .EXAMPLE + Test-MtDisaIdleSessionTimeout + + Returns true when the idle session timeout is 15 minutes or less. + + .LINK + https://maester.dev/docs/tests/DISA.V-273867 + #> + [MaesterTest( + Id = 'DISA.V-273867', + Title = 'Microsoft Intune service must initiate a session lock after a 15-minute period of inactivity.', + Product = 'microsoft-365', + RelatedProduct = 'entra', + Feature = 'organization-settings', + Area = 'authentication', + ResourceType = 'Tenant', + Severity = 'Medium', + UserImpact = 'Medium', + ImplementationCost = 'Low', + Mitre = 'T1550.004', + Control = 'disa-stig-intune-mdm:V-273867', + Service = 'Graph', + Lifecycle = 'Preview', + Author = 'merill' + )] + [CmdletBinding()] + [OutputType([bool])] + param( + # Longest idle session timeout that is allowed, in minutes. + [ValidateRange(1, 1440)] + [int] $MaximumIdleTimeoutMinutes = 15 + ) + + $timeout = Get-MtActivityBasedTimeout + $testResult = $null -ne $timeout.Timeout -and $timeout.Timeout -le [timespan]::FromMinutes($MaximumIdleTimeoutMinutes) + + $value = if ($timeout.Timeout) { "$([math]::Round($timeout.Timeout.TotalMinutes)) minutes" } else { 'Not configured' } + $link = 'https://admin.microsoft.com/#/Settings/SecurityPrivacy/:/Settings/L1/IdleSessionTimeout' + $table = "| Setting | Value | Required | Result |`n| --- | --- | --- | --- |`n" + $table += "| [Idle session timeout]($link) | $value | $MaximumIdleTimeoutMinutes minutes or less | $(if ($testResult) { '✅ Pass' } else { '❌ Fail' }) |`n" + + if ($testResult) { + $testResultMarkdown = "Well done. Users are signed out of Microsoft 365 web apps after $value of inactivity.`n`n$table" + } elseif ($null -eq $timeout.Timeout) { + $testResultMarkdown = "No idle session timeout is set. Set it to $MaximumIdleTimeoutMinutes minutes or less in the Microsoft 365 admin center.`n`n$table" + } else { + $testResultMarkdown = "The idle session timeout is $value. Set it to $MaximumIdleTimeoutMinutes minutes or less.`n`n$table" + } + Add-MtTestResultDetail -Result $testResultMarkdown + return $testResult +} diff --git a/tests/disa/Test.DISA.V-273868.md b/tests/disa/Test.DISA.V-273868.md new file mode 100644 index 0000000000..1575f22118 --- /dev/null +++ b/tests/disa/Test.DISA.V-273868.md @@ -0,0 +1,20 @@ +An Intune diagnostic setting sends the Intune audit logs to a log store outside Intune. (DISA Microsoft Intune MDM Service Desktop and Mobile STIG, V-273868, CAT II). + +Intune keeps its audit logs for a limited time and only in the Intune admin center. Sending them to Azure Monitor or a SIEM keeps them and lets the security team review and alert on changes. + +The STIG accepts a third-party log server or Azure Monitor. This test runs [MT.1100](https://maester.dev/docs/tests/MT.1100), which checks that an Intune diagnostic setting includes the audit logs; logs sent another way must be checked by hand. + +#### Remediation action + +1. In the [Microsoft Intune admin center](https://intune.microsoft.com), go to **Reports** > **[Diagnostic settings](https://intune.microsoft.com/#view/Microsoft_Intune_Enrollment/DiagnosticsSettingsBlade)**. +2. Select **Add diagnostic setting**. +3. Select the **AuditLogs** category (and any other Intune logs you need) and send them to a Log Analytics workspace, a storage account, an event hub or a partner solution. +4. Select **Save**. + +#### Related links + +* [DISA Microsoft Intune MDM Service Desktop and Mobile STIG: V-273868](https://cyber.trackr.live/stig/Intune_MDM_Service_Desktop_&_Mobile/1/2/V-273868) +* [Send Intune log data to storage, event hubs, or Log Analytics](https://learn.microsoft.com/intune/intune-service/fundamentals/review-logs-using-azure-monitor) + + +%TestResult% diff --git a/tests/disa/Test.DISA.V-273868.ps1 b/tests/disa/Test.DISA.V-273868.ps1 new file mode 100644 index 0000000000..a1107094b1 --- /dev/null +++ b/tests/disa/Test.DISA.V-273868.ps1 @@ -0,0 +1,40 @@ +function Test-MtDisaIntuneLogExport { + <# + .SYNOPSIS + Checks that an Intune diagnostic setting sends the audit logs to another store. + + .DESCRIPTION + DISA Microsoft Intune MDM Service Desktop and Mobile STIG (V-273868, CAT II): Microsoft Intune service must be configured to transfer Intune logs to another server for storage, analysis, and reporting at least every seven days. + + This test runs MT.1100 (Test-MtIntuneDiagnosticSettings). See the guide for what DISA asks and how the two compare. + + .EXAMPLE + Test-MtDisaIntuneLogExport + + Returns the result of MT.1100 with DISA's values. + + .LINK + https://maester.dev/docs/tests/DISA.V-273868 + #> + [MaesterTest( + Id = 'DISA.V-273868', + Title = 'Microsoft Intune service must be configured to transfer Intune logs to another server for storage, analysis, and reporting at least every seven days.', + Product = 'intune', + Feature = 'tenant-administration', + Area = 'logging-and-detection', + ResourceType = 'Tenant', + Severity = 'High', + UserImpact = 'Low', + ImplementationCost = 'Medium', + Mitre = 'T1685.002', + Control = 'disa-stig-intune-mdm:V-273868', + Service = 'Azure', + License = 'INTUNE_A', + Author = 'merill' + )] + [CmdletBinding()] + [OutputType([bool])] + param() + + return Test-MtIntuneDiagnosticSettings +} diff --git a/tests/disa/Test.DISA.V-285327.md b/tests/disa/Test.DISA.V-285327.md new file mode 100644 index 0000000000..0e8240c091 --- /dev/null +++ b/tests/disa/Test.DISA.V-285327.md @@ -0,0 +1,20 @@ +An Intune Multi Admin Approval policy requires a second administrator to approve device wipes. (DISA Microsoft Intune MDM Service Desktop and Mobile STIG, V-285327, CAT I). + +One compromised or careless Intune administrator can wipe every managed device in a few clicks. Multi Admin Approval makes a second administrator approve the wipe before it runs, which is why DISA rates this rule CAT I. + +This test runs [MT.1096](https://maester.dev/docs/tests/MT.1096) with `RequiredPolicyType`, so it passes only when an approval policy covers device wipes (a **Device wipe** or **Device actions** policy). The STIG also asks you to confirm that the approver group is the right one and that the policy itself is approved; check that by hand. + +#### Remediation action + +1. Create a Microsoft Entra security group for the administrators who approve device wipes. +2. In the [Microsoft Intune admin center](https://intune.microsoft.com), go to **Tenant administration** > **[Multi Admin Approval](https://intune.microsoft.com/#view/Microsoft_Intune_DeviceSettings/TenantAdminMenu/~/multiAdminApproval)** > **Access policies** and select **Create**. +3. Set **Policy type** to **Device wipe** (or **Device actions**), select the approver group, and save. +4. Have another administrator approve the new policy. + +#### Related links + +* [DISA Microsoft Intune MDM Service Desktop and Mobile STIG: V-285327](https://cyber.trackr.live/stig/Intune_MDM_Service_Desktop_&_Mobile/1/2/V-285327) +* [Use Multi Admin Approval in Intune](https://learn.microsoft.com/intune/intune-service/fundamentals/multi-admin-approval) + + +%TestResult% diff --git a/tests/disa/Test.DISA.V-285327.ps1 b/tests/disa/Test.DISA.V-285327.ps1 new file mode 100644 index 0000000000..06ea389232 --- /dev/null +++ b/tests/disa/Test.DISA.V-285327.ps1 @@ -0,0 +1,43 @@ +function Test-MtDisaIntuneWipeApproval { + <# + .SYNOPSIS + Checks that an Intune Multi Admin Approval policy protects device wipes. + + .DESCRIPTION + DISA Microsoft Intune MDM Service Desktop and Mobile STIG (V-285327, CAT I): The Intune service must be configured to implement Multi-Admin Approval (MAA) for wiping managed devices. + + This test runs MT.1096 (Test-MtOperationApprovalPolicies). See the guide for what DISA asks and how the two compare. + + .EXAMPLE + Test-MtDisaIntuneWipeApproval + + Returns the result of MT.1096 with DISA's values. + + .LINK + https://maester.dev/docs/tests/DISA.V-285327 + #> + [MaesterTest( + Id = 'DISA.V-285327', + Title = 'The Intune service must be configured to implement Multi-Admin Approval (MAA) for wiping managed devices.', + Product = 'intune', + Feature = 'tenant-administration', + Area = 'privileged-access', + ResourceType = 'Tenant', + Severity = 'Medium', + UserImpact = 'Low', + ImplementationCost = 'Low', + Mitre = ('T1072', 'T1078.004'), + Control = 'disa-stig-intune-mdm:V-285327', + Service = 'Graph', + License = 'INTUNE_A', + Author = 'merill' + )] + [CmdletBinding()] + [OutputType([bool])] + param( + # The Multi Admin Approval policy types that protect a device wipe. + [string[]] $RequiredPolicyType = ('deviceWipe', 'deviceAction') + ) + + return Test-MtOperationApprovalPolicies -RequiredPolicyType $RequiredPolicyType +} diff --git a/tests/disa/frameworks/disa-stig-entra-id.json b/tests/disa/frameworks/disa-stig-entra-id.json new file mode 100644 index 0000000000..dbf37f97a1 --- /dev/null +++ b/tests/disa/frameworks/disa-stig-entra-id.json @@ -0,0 +1,103 @@ +{ + "Framework": "disa-stig-entra-id", + "Name": "DISA Microsoft Entra ID STIG", + "Version": "V1R2", + "Url": "https://public.cyber.mil/stigs/downloads/?_dl_facet_stigs=microsoft", + "Published": "2026-09-03", + "Note": "Rule IDs, categories and STIG IDs from the DISA STIG. Related NIST SP 800-53 Rev. 5 controls follow the CCIs each rule lists. DISA STIGs are works of the US Government.", + "Requirements": [ + { + "Id": "V-270200", + "Category": "CAT II", + "RuleId": "SV-270200r1085610_rule", + "StigId": "ENTR-ID-000030", + "Related": [ + "nist-800-53-r5:AC-11", + "nist-800-53-r5:AC-12" + ] + }, + { + "Id": "V-270204", + "Category": "CAT II", + "RuleId": "SV-270204r1271709_rule", + "StigId": "ENTR-ID-000090", + "Related": [ + "nist-800-53-r5:AC-2(3)" + ] + }, + { + "Id": "V-270208", + "Category": "CAT II", + "RuleId": "SV-270208r1085616_rule", + "StigId": "ENTR-ID-000140", + "Related": [ + "nist-800-53-r5:AC-7" + ] + }, + { + "Id": "V-270209", + "Category": "CAT II", + "RuleId": "SV-270209r1271710_rule", + "StigId": "ENTR-ID-000150", + "Related": [ + "nist-800-53-r5:AC-8" + ] + }, + { + "Id": "V-270227", + "Category": "CAT II", + "RuleId": "SV-270227r1085728_rule", + "StigId": "ENTR-ID-000370", + "Related": [ + "nist-800-53-r5:AU-4(1)", + "nist-800-53-r5:AU-9(2)" + ] + }, + { + "Id": "V-270233", + "Category": "CAT I", + "RuleId": "SV-270233r1085634_rule", + "StigId": "ENTR-ID-000440", + "Related": [ + "nist-800-53-r5:IA-2(1)", + "nist-800-53-r5:IA-2(2)" + ] + }, + { + "Id": "V-270239", + "Category": "CAT II", + "RuleId": "SV-270239r1271708_rule", + "StigId": "ENTR-ID-000610", + "Related": [ + "nist-800-53-r5:IA-5(1)" + ] + }, + { + "Id": "V-270255", + "Category": "CAT II", + "RuleId": "SV-270255r1085626_rule", + "StigId": "ENTR-ID-000835", + "Related": [ + "nist-800-53-r5:AC-2(1)" + ] + }, + { + "Id": "V-270335", + "Category": "CAT II", + "RuleId": "SV-270335r1085641_rule", + "StigId": "ENTR-ID-001900", + "Related": [ + "nist-800-53-r5:AC-2(2)" + ] + }, + { + "Id": "V-270475", + "Category": "CAT II", + "RuleId": "SV-270475r1085680_rule", + "StigId": "ENTR-ID-003350", + "Related": [ + "nist-800-53-r5:IA-5(1)" + ] + } + ] +} diff --git a/tests/disa/frameworks/disa-stig-intune-desktop.json b/tests/disa/frameworks/disa-stig-intune-desktop.json new file mode 100644 index 0000000000..3424425951 --- /dev/null +++ b/tests/disa/frameworks/disa-stig-intune-desktop.json @@ -0,0 +1,121 @@ +{ + "Framework": "disa-stig-intune-desktop", + "Name": "DISA Microsoft Intune MDM Service Desktop STIG", + "Version": "V1R1", + "Url": "https://public.cyber.mil/stigs/downloads/?_dl_facet_stigs=microsoft", + "Published": "2024-10-04", + "Note": "Rule IDs, categories and STIG IDs from the DISA STIG. Related NIST SP 800-53 Rev. 5 controls follow the CCIs each rule lists. DISA STIGs are works of the US Government.", + "Requirements": [ + { + "Id": "V-267303", + "Category": "CAT II", + "RuleId": "SV-267303r1026081_rule", + "StigId": "MSIN-24-000030", + "Related": [ + "nist-800-53-r5:AC-11", + "nist-800-53-r5:AC-12" + ] + }, + { + "Id": "V-267309", + "Category": "CAT II", + "RuleId": "SV-267309r1025795_rule", + "StigId": "MSIN-24-000090", + "Related": [ + "nist-800-53-r5:AC-2(3)" + ] + }, + { + "Id": "V-267314", + "Category": "CAT II", + "RuleId": "SV-267314r1026042_rule", + "StigId": "MSIN-24-000140", + "Related": [ + "nist-800-53-r5:AC-7" + ] + }, + { + "Id": "V-267315", + "Category": "CAT II", + "RuleId": "SV-267315r1026051_rule", + "StigId": "MSIN-24-000150", + "Related": [ + "nist-800-53-r5:AC-8" + ] + }, + { + "Id": "V-267334", + "Category": "CAT II", + "RuleId": "SV-267334r1025801_rule", + "StigId": "MSIN-24-000370", + "Related": [ + "nist-800-53-r5:AU-4(1)", + "nist-800-53-r5:AU-9(2)" + ] + }, + { + "Id": "V-267341", + "Category": "CAT II", + "RuleId": "SV-267341r1026082_rule", + "StigId": "MSIN-24-000440", + "Related": [ + "nist-800-53-r5:IA-2(1)", + "nist-800-53-r5:IA-2(2)" + ] + }, + { + "Id": "V-267355", + "Category": "CAT II", + "RuleId": "SV-267355r1025805_rule", + "StigId": "MSIN-24-000610", + "Related": [ + "nist-800-53-r5:IA-5(1)" + ] + }, + { + "Id": "V-267372", + "Category": "CAT II", + "RuleId": "SV-267372r1025806_rule", + "StigId": "MSIN-24-000820", + "Related": [ + "nist-800-53-r5:AC-2(4)" + ] + }, + { + "Id": "V-267373", + "Category": "CAT II", + "RuleId": "SV-267373r1025807_rule", + "StigId": "MSIN-24-000830", + "Related": [ + "nist-800-53-r5:AC-2(4)" + ] + }, + { + "Id": "V-267374", + "Category": "CAT II", + "RuleId": "SV-267374r1026210_rule", + "StigId": "MSIN-24-000840", + "Related": [ + "nist-800-53-r5:AC-2(4)" + ] + }, + { + "Id": "V-267375", + "Category": "CAT II", + "RuleId": "SV-267375r1025809_rule", + "StigId": "MSIN-24-000850", + "Related": [ + "nist-800-53-r5:AC-2(4)" + ] + }, + { + "Id": "V-267379", + "Category": "CAT II", + "RuleId": "SV-267379r1025810_rule", + "StigId": "MSIN-24-000900", + "Related": [ + "nist-800-53-r5:AC-2(1)" + ] + } + ] +} diff --git a/tests/disa/frameworks/disa-stig-intune-mdm.json b/tests/disa/frameworks/disa-stig-intune-mdm.json new file mode 100644 index 0000000000..e41def3c5c --- /dev/null +++ b/tests/disa/frameworks/disa-stig-intune-mdm.json @@ -0,0 +1,39 @@ +{ + "Framework": "disa-stig-intune-mdm", + "Name": "DISA Microsoft Intune MDM Service Desktop and Mobile STIG", + "Version": "V1R2", + "Url": "https://public.cyber.mil/stigs/downloads/?_dl_facet_stigs=microsoft", + "Published": "2026-05-27", + "Note": "Rule IDs, categories and STIG IDs from the DISA STIG. Related NIST SP 800-53 Rev. 5 controls follow the CCIs each rule lists. DISA STIGs are works of the US Government.", + "Requirements": [ + { + "Id": "V-273867", + "Category": "CAT II", + "RuleId": "SV-273867r1207980_rule", + "StigId": "MSIN-25-000030", + "Related": [ + "nist-800-53-r5:AC-11", + "nist-800-53-r5:AC-12" + ] + }, + { + "Id": "V-273868", + "Category": "CAT II", + "RuleId": "SV-273868r1208024_rule", + "StigId": "MSIN-25-000370", + "Related": [ + "nist-800-53-r5:AU-4(1)", + "nist-800-53-r5:AU-9(2)" + ] + }, + { + "Id": "V-285327", + "Category": "CAT I", + "RuleId": "SV-285327r1211999_rule", + "StigId": "MSIN-25-002000", + "Related": [ + "nist-800-53-r5:CM-6" + ] + } + ] +} diff --git a/tests/disa/suite.json b/tests/disa/suite.json new file mode 100644 index 0000000000..0f41700b98 --- /dev/null +++ b/tests/disa/suite.json @@ -0,0 +1,16 @@ +{ + "Id": "DISA", + "Name": "DISA STIGs", + "Source": "DISA", + "IdPattern": "^DISA\\.", + "HelpUrlTemplate": "https://maester.dev/docs/tests/{Id}", + "Upstream": { + "Name": "DISA Security Technical Implementation Guides", + "Url": "https://public.cyber.mil/stigs/" + }, + "Frameworks": [ + { "Key": "disa-stig-entra-id", "Version": "V1R2" }, + { "Key": "disa-stig-intune-mdm", "Version": "V1R2" }, + { "Key": "disa-stig-intune-desktop", "Version": "V1R1" } + ] +} diff --git a/tests/maester/intune/Test.MT.1096.ps1 b/tests/maester/intune/Test.MT.1096.ps1 index dccb2b9f20..c86cd4e1e1 100644 --- a/tests/maester/intune/Test.MT.1096.ps1 +++ b/tests/maester/intune/Test.MT.1096.ps1 @@ -4,13 +4,21 @@ Check for the usage of Intune Multi Admin Approval Policies .DESCRIPTION - At least one Intune Multi Admin Approval Policy should be configured + At least one Intune Multi Admin Approval Policy should be configured. + + With RequiredPolicyType the check passes only when a policy of one of those types exists, for example + deviceWipe or deviceAction for a policy that protects device wipes. .EXAMPLE Test-MtOperationApprovalPolicies Returns true if at least one Intune Multi Admin Approval Policy is configured, false if none is configured. + .EXAMPLE + Test-MtOperationApprovalPolicies -RequiredPolicyType deviceWipe, deviceAction + + Returns true if a Multi Admin Approval policy protects device wipes. + .LINK https://maester.dev/docs/commands/Test-MtOperationApprovalPolicies #> @@ -33,23 +41,40 @@ [CmdletBinding()] [OutputType([bool])] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseSingularNouns', '', Justification = 'This test refers to multiple settings.')] - param() + param( + # Policy types (operationApprovalPolicyType, such as deviceWipe) of which one policy must exist. Empty accepts any policy. + [string[]] $RequiredPolicyType + ) Write-Verbose 'Testing Multi Admin Approval Policy configuration' Write-Verbose 'Retrieving Intune Multi Admin Approval Policies status...' - $approvalPolicies = Invoke-MtGraphRequest -RelativeUri 'deviceManagement/operationApprovalPolicies' -ApiVersion beta - $testResultMarkdown = '' - $hasPolicies = @($approvalPolicies).Count -gt 0 - if ($hasPolicies) { - $testResultMarkdown += "Well done. At least one Intune Multi Admin Approval Policy is configured.`n" + $approvalPolicies = @(Invoke-MtGraphRequest -RelativeUri 'deviceManagement/operationApprovalPolicies' -ApiVersion beta | Where-Object { $_ }) + + if ($RequiredPolicyType) { + $matching = @($approvalPolicies | Where-Object { $_.policyType -in $RequiredPolicyType -or $_.policySet.policyType -in $RequiredPolicyType }) + $testResult = $matching.Count -gt 0 + $typeList = ($RequiredPolicyType | ForEach-Object { "``$_``" }) -join ', ' + $testResultMarkdown = if ($testResult) { + "Well done. An Intune Multi Admin Approval policy of type $typeList is configured.`n" + } else { + "No Intune Multi Admin Approval policy of type $typeList is configured.`n" + } + } else { + $testResult = $approvalPolicies.Count -gt 0 + $testResultMarkdown = if ($testResult) { + "Well done. At least one Intune Multi Admin Approval Policy is configured.`n" + } else { + 'No Intune Multi Admin Approval Policy is configured.' + } + } + + if ($approvalPolicies.Count -gt 0) { $testResultMarkdown += "| Name | Type |`n" $testResultMarkdown += "| --- | --- |`n" foreach ($policy in $approvalPolicies) { $testResultMarkdown += "| $(Get-MtSafeMarkdown $policy.displayName) | $($policy.policyType) |`n" } - } else { - $testResultMarkdown += 'No Intune Multi Admin Approval Policy is configured.' } Add-MtTestResultDetail -Result $testResultMarkdown - return $hasPolicies + return $testResult } diff --git a/website/astro.config.mjs b/website/astro.config.mjs index 1c7194ec05..1b4c44dbc6 100644 --- a/website/astro.config.mjs +++ b/website/astro.config.mjs @@ -134,6 +134,7 @@ export default defineConfig({ { label: 'CIS', link: '/docs/tests/cis' }, { label: 'CISA SCuBA', link: '/docs/tests/cisa' }, { label: 'ASD Essential Eight', link: '/docs/tests/asd' }, + { label: 'DISA STIGs', link: '/docs/tests/disa' }, { label: 'Entra ID SCA (EIDSCA)', link: '/docs/tests/eidsca' }, { label: 'ORCA', link: '/docs/tests/orca' }, { label: 'Active Directory', link: '/docs/tests/ad' }, diff --git a/website/docs/configuration/run-configuration.md b/website/docs/configuration/run-configuration.md index d21f1e223a..69a7741e53 100644 --- a/website/docs/configuration/run-configuration.md +++ b/website/docs/configuration/run-configuration.md @@ -157,7 +157,7 @@ Which tests run. Every key has a command-line equivalent. | `Feature` | array | `[]` | Run only tests about these features (like `-Feature`), for example `conditional-access`. | | `Area` | array | `[]` | Run only tests of these security areas (like `-Area`), for example `authentication`. | | `Severity` | array | `[]` | Run only tests with these severities (like `-Severity`). The severity a `TestSettings` row sets is the one that counts. | -| `Suite` | array | `[]` | Run only tests of these suites (like `-Suite`), for example `Maester`, `CISA`, `CIS`, `ASD`, `EIDSCA`, `ORCA` or `AD`. | +| `Suite` | array | `[]` | Run only tests of these suites (like `-Suite`), for example `Maester`, `CISA`, `CIS`, `ASD`, `DISA`, `EIDSCA`, `ORCA` or `AD`. | | `Pack` | array | `[]` | Run only these [Maester Packs](../packs/index.md#choosing-which-packs-run), by pack ID or code (like `-Pack`). A pack named here runs even if it is off, with its long-running and preview tests. Other packs do not run. | | `Tag` | array | `[]` | Run only tests that any of these tags selects (like `-Tag`). | | `ExcludeTag` | array | `[]` | Do not run tests that any of these tags selects (like `-ExcludeTag`). | diff --git a/website/docs/contributing.md b/website/docs/contributing.md index 5f3039be9e..d849d50f5e 100644 --- a/website/docs/contributing.md +++ b/website/docs/contributing.md @@ -35,12 +35,13 @@ carries the same rules for AI coding and review agents. ```text tests/ The security checks: Test..ps1 + Test..md, plus suite.json, README.md and framework files - /frameworks/.json The catalogue of a benchmark, one entry per requirement (asd/, cis/ and cisa/) + /frameworks/.json The catalogue of a benchmark, one entry per requirement (asd/, cis/, cisa/ and disa/) maester// MT.xxxx checks, one folder per service (plus drift/) maester/xspm/ Exposure management; has its own suite.json (the nearest one applies) cis/ CIS benchmark checks cisa// CISA SCuBA checks asd// ASD Essential Eight and ISM checks; frameworks generated by build/asd + disa/ DISA STIG checks for Entra ID and Intune ad// Active Directory checks eidsca/ orca/ Generated by build/eidsca and build/orca custom/ Reserved for users' own tests; nothing is committed here @@ -231,6 +232,7 @@ Every built-in check is a [native test](./writing-tests/index.mdx): `Test..p - `/cisa` - CISA tests, with a subfolder per service - `/cis` - CIS tests - `/asd` - ASD Essential Eight and ISM tests (`ASD.ISM-xxxx`), with a subfolder per service +- `/disa` - DISA STIG tests (`DISA.V-xxxxxx`, named after the STIG rule), one folder for every product - `/eidsca` - EIDSCA tests (generated, see below) - `/orca` - ORCA tests (generated by `build/orca/Update-OrcaTests.ps1`) - `/ad` - Active Directory tests diff --git a/website/docs/result-schema.md b/website/docs/result-schema.md index aeebb1f169..e17880ba43 100644 --- a/website/docs/result-schema.md +++ b/website/docs/result-schema.md @@ -188,7 +188,7 @@ Added in 2.1: | Field | Type | Content | | --- | --- | --- | -| `Source` | string | Where the test comes from: `Maester`, `CISA`, `CIS`, `ASD`, `EIDSCA`, `ORCA` or `Custom` (or the `Source` of a custom `suite.json`). | +| `Source` | string | Where the test comes from: `Maester`, `CISA`, `CIS`, `ASD`, `DISA`, `EIDSCA`, `ORCA` or `Custom` (or the `Source` of a custom `suite.json`). | | `Suite` | string | The suite ID, for example `Maester`, `CISA`, `AD` or `Custom`. | | `Product` | string | The key of the product where the fix is made, for example `entra` or `exchange`. `Taxonomy.Products` gives the name. A custom test may use a name of its own. | | `RelatedProduct` | array of strings | Keys of other products the test also checks or depends on. | diff --git a/website/docs/writing-tests/attribute-rubric.md b/website/docs/writing-tests/attribute-rubric.md index 6c212452d5..52fec21f9c 100644 --- a/website/docs/writing-tests/attribute-rubric.md +++ b/website/docs/writing-tests/attribute-rubric.md @@ -228,7 +228,7 @@ it: one shipped with Maester or one of your own. - `Control` is the only way a test is mapped to a framework. A CIS test carries `Control = 'cis-m365:5.1.5.1'` and a CISA test carries `Control = 'cisa-scuba:MS.AAD.3.1'` and an ASD test `Control = 'essential-eight:ISM-1504'`. - Every test in `tests/cis`, `tests/cisa` and `tests/asd` must name a requirement of its suite's framework. The unit + Every test in `tests/cis`, `tests/cisa`, `tests/asd` and `tests/disa` must name a requirement of its suite's framework. The unit tests check this. - The first value that names a requirement in a framework file becomes the `Benchmark` of the result. Put the requirement the test is written for first, and any other requirement it supports after it. diff --git a/website/docs/writing-tests/first-custom-test.md b/website/docs/writing-tests/first-custom-test.md index bff50b9eeb..ef73a90bb8 100644 --- a/website/docs/writing-tests/first-custom-test.md +++ b/website/docs/writing-tests/first-custom-test.md @@ -37,7 +37,7 @@ This writes two files into `custom`: | `Test.CT.1001.md` | The text shown in the report: what is checked and how to fix it. | `CT.1001` is the test's ID. Pick a prefix of your own, such as `CT` or your company name, and a number. Do not -use `MT`, `CIS`, `CISA`, `ASD`, `EIDSCA`, `ORCA`, `AD` or `AZDO`: those belong to the tests that ship with Maester. +use `MT`, `CIS`, `CISA`, `ASD`, `DISA`, `EIDSCA`, `ORCA`, `AD` or `AZDO`: those belong to the tests that ship with Maester. :::tip Prefer forms to typing? The [test builder](/test-builder) lets you pick everything from lists. Choose diff --git a/website/docs/writing-tests/index.mdx b/website/docs/writing-tests/index.mdx index 0df06952e5..b4c4867c4c 100644 --- a/website/docs/writing-tests/index.mdx +++ b/website/docs/writing-tests/index.mdx @@ -99,9 +99,10 @@ the rest keeps the benchmark's own punctuation, so a reader can search for the I | `CIS.M365.5.2.2.2` | `CIS.M365.` | Recommendation `5.2.2.2` of the CIS Microsoft 365 Foundations Benchmark | | `CISA.MS.AAD.3.1` | `CISA.` | SCuBA policy `MS.AAD.3.1v1`, without its version suffix | | `ASD.ISM-1504` | `ASD.` | ISM control `ISM-1504`, written with a hyphen by ASD | +| `DISA.V-270233` | `DISA.` | Rule `V-270233` of a DISA STIG (vulnerability IDs are unique across STIGs) | Use a prefix of your own. These prefixes belong to the tests that ship with Maester: `MT.`, `CISA.`, `CIS.`, -`EIDSCA.`, `ORCA.`, `AD-`, `AZDO.`, `ASD.` and `MT1060.`. `MP.` is reserved for Maester Packs, third-party test packs +`EIDSCA.`, `ORCA.`, `AD-`, `AZDO.`, `ASD.`, `DISA.` and `MT1060.`. `MP.` is reserved for Maester Packs, third-party test packs planned for a later release. A custom test with one of these prefixes still runs, with a warning. A custom test that uses the exact ID of a built-in test is not run at all, and the built-in runs instead. To change how a built-in test behaves, set its parameters or severity in the @@ -759,6 +760,9 @@ The frameworks that ship with Maester, with the key to use in `Control`: | `cisa-scuba` | CISA SCuBA Secure Configuration Baselines for Microsoft 365 | [tests/cisa/frameworks/cisa-scuba.json](https://github.com/maester365/maester/blob/main/tests/cisa/frameworks/cisa-scuba.json) | [tests/cisa/suite.json](https://github.com/maester365/maester/blob/main/tests/cisa/suite.json) | | `essential-eight` | ASD Essential Eight maturity model (each requirement is an ISM control; `Level` ML1 to ML3, `Strategy`) | [tests/asd/frameworks/essential-eight.json](https://github.com/maester365/maester/blob/main/tests/asd/frameworks/essential-eight.json) | [tests/asd/suite.json](https://github.com/maester365/maester/blob/main/tests/asd/suite.json) | | `ism` | ASD Information security manual (ISM) (`Guideline`, `Section`, `Applicability`) | [tests/asd/frameworks/ism.json](https://github.com/maester365/maester/blob/main/tests/asd/frameworks/ism.json) | [tests/asd/suite.json](https://github.com/maester365/maester/blob/main/tests/asd/suite.json) | +| `disa-stig-entra-id` | DISA Microsoft Entra ID STIG (`Category` CAT I to CAT III, `RuleId`, `StigId`) | [tests/disa/frameworks/disa-stig-entra-id.json](https://github.com/maester365/maester/blob/main/tests/disa/frameworks/disa-stig-entra-id.json) | [tests/disa/suite.json](https://github.com/maester365/maester/blob/main/tests/disa/suite.json) | +| `disa-stig-intune-mdm` | DISA Microsoft Intune MDM Service Desktop and Mobile STIG | [tests/disa/frameworks/disa-stig-intune-mdm.json](https://github.com/maester365/maester/blob/main/tests/disa/frameworks/disa-stig-intune-mdm.json) | [tests/disa/suite.json](https://github.com/maester365/maester/blob/main/tests/disa/suite.json) | +| `disa-stig-intune-desktop` | DISA Microsoft Intune MDM Service Desktop STIG | [tests/disa/frameworks/disa-stig-intune-desktop.json](https://github.com/maester365/maester/blob/main/tests/disa/frameworks/disa-stig-intune-desktop.json) | [tests/disa/suite.json](https://github.com/maester365/maester/blob/main/tests/disa/suite.json) | Open a file to see the requirement IDs you can reference and the version Maester implements. NIST SP 800-53 has no framework file; its control IDs are in diff --git a/website/scripts/catalog-explorer.mjs b/website/scripts/catalog-explorer.mjs index 4a88e40a8a..c29121e887 100644 --- a/website/scripts/catalog-explorer.mjs +++ b/website/scripts/catalog-explorer.mjs @@ -48,6 +48,9 @@ export const frameworkConfig = { "cisa-scuba": { code: "CISA", label: "CISA SCuBA", suite: "cisa", complete: true, section: (r) => sectionName(CISA_SERVICES, r.Id.split(".").slice(0, 2).join(".")) }, "essential-eight": { code: "E8", label: "Essential Eight", suite: "asd", complete: true, section: (r) => [r.Strategy].flat().filter(Boolean) }, ism: { code: "ISM", label: "ASD ISM", suite: "asd", complete: false, section: (r) => r.Guideline || "Other" }, + "disa-stig-entra-id": { code: "STIG", label: "DISA STIG Entra ID", suite: "disa", complete: true, section: (r) => r.Category || "Other" }, + "disa-stig-intune-mdm": { code: "STIG", label: "DISA STIG Intune MDM", suite: "disa", complete: true, section: (r) => r.Category || "Other" }, + "disa-stig-intune-desktop": { code: "STIG", label: "DISA STIG Intune Desktop", suite: "disa", complete: true, section: (r) => r.Category || "Other" }, }; // A GitHub avatar at the size the nav shows it (github.com/.png serves the full image otherwise). diff --git a/website/scripts/generate-test-docs.mjs b/website/scripts/generate-test-docs.mjs index 37f8a514f7..f3cbbdf6f3 100644 --- a/website/scripts/generate-test-docs.mjs +++ b/website/scripts/generate-test-docs.mjs @@ -62,6 +62,14 @@ const suiteConfig = { overview: "These tests verify Microsoft 365 tenant configuration against the [Essential Eight](https://www.cyber.gov.au/business-government/asds-cyber-security-frameworks/essential-eight) and the [Information security manual (ISM)](https://www.cyber.gov.au/business-government/asds-cyber-security-frameworks/ism), both published by the Australian Signals Directorate (ASD). You may know them as the ACSC Essential Eight and the ACSC ISM: the Australian Cyber Security Centre (ACSC) is part of ASD. The Essential Eight maturity model (November 2023) sets requirements at Maturity Level One to Three, and ASD maps each requirement to an ISM control, so each test is named after the ISM control it checks: ASD.ISM-1504 checks ISM-1504. A few tests check ISM controls outside the Essential Eight, such as ASD.ISM-1403.", }, + disa: { + label: "DISA", + title: "DISA STIG Tests", + sidebarLabel: "🇺🇸 DISA STIGs", + description: "DISA Security Technical Implementation Guide (STIG) rules for Microsoft Entra ID and Intune implemented as Maester tests.", + overview: + "These tests verify Microsoft 365 tenant configuration against the [Security Technical Implementation Guides (STIGs)](https://public.cyber.mil/stigs/) that the US Defense Information Systems Agency (DISA) publishes for Microsoft Entra ID, the Intune MDM service (desktop and mobile) and the Intune service (desktop). Each test is named after the STIG rule it checks: DISA.V-270233 checks rule V-270233. Where another suite already checks the same setting, the DISA test runs that test with DISA's values. Rules that need a person to confirm a process, such as alerting the ISSO when accounts change, have no test. Some rules are DoD-specific, such as the DoD Notice and Consent Banner, and fail outside DoD by design.", + }, cis: { label: "CIS", title: "CIS Benchmark Tests", @@ -555,7 +563,7 @@ ${body.join("\n")}`; function renderSuiteIndex(suite) { const config = suiteConfig[suite]; - const key = new Map([["maester", "Maester"], ["eidsca", "EIDSCA"], ["cisa", "CISA"], ["asd", "ASD"], ["cis", "CIS"], ["orca", "ORCA"], ["ad", "AD"]]).get(suite) ?? suite; + const key = new Map([["maester", "Maester"], ["eidsca", "EIDSCA"], ["cisa", "CISA"], ["asd", "ASD"], ["disa", "DISA"], ["cis", "CIS"], ["orca", "ORCA"], ["ad", "AD"]]).get(suite) ?? suite; return `--- title: ${yamlQuote(config.title)} slug: docs/tests/${suite} diff --git a/website/src/components/catalog/data.ts b/website/src/components/catalog/data.ts index 3dcb629010..93681e36b2 100644 --- a/website/src/components/catalog/data.ts +++ b/website/src/components/catalog/data.ts @@ -26,6 +26,7 @@ export const suiteInfo: Record = { CIS: { name: 'CIS', slug: 'cis' }, CISA: { name: 'CISA SCuBA', slug: 'cisa' }, ASD: { name: 'ASD Essential Eight', slug: 'asd' }, + DISA: { name: 'DISA STIGs', slug: 'disa' }, EIDSCA: { name: 'Entra ID SCA (EIDSCA)', slug: 'eidsca' }, ORCA: { name: 'ORCA', slug: 'orca' }, AD: { name: 'Active Directory', slug: 'ad' }, diff --git a/website/src/components/overrides/PageTitle.astro b/website/src/components/overrides/PageTitle.astro index 9e62f36d57..1068edc3d6 100644 --- a/website/src/components/overrides/PageTitle.astro +++ b/website/src/components/overrides/PageTitle.astro @@ -21,7 +21,7 @@ const name = test?.id ?? commandName; // List pages (the catalog, each suite, the tags, the commands index) are tables, and the test builder is a form // beside its code: give them the full width, from the sidebar's edge. A test page has no contents list, so Starlight // would centre it in the space; it starts at the sidebar's edge too. -const isList = /^docs\/tests(\/(maester|cis|cisa|asd|eidsca|orca|ad|xspm|tags|overview|attack|products\/[^/]+|frameworks\/[^/]+|packs\/[^/]+))?$/.test(id) || id === 'docs/commands' || id === 'test-builder'; +const isList = /^docs\/tests(\/(maester|cis|cisa|asd|disa|eidsca|orca|ad|xspm|tags|overview|attack|products\/[^/]+|frameworks\/[^/]+|packs\/[^/]+))?$/.test(id) || id === 'docs/commands' || id === 'test-builder'; --- { diff --git a/website/src/data/test-builder.json b/website/src/data/test-builder.json index c55a4b4684..0cc2fee8d9 100644 --- a/website/src/data/test-builder.json +++ b/website/src/data/test-builder.json @@ -12,6 +12,7 @@ "AZDO.", "MT1060.", "ASD.", + "DISA.", "MP.", "ZTA." ], @@ -1250,6 +1251,16 @@ "sharepoint" ] }, + { + "id": "DISA", + "name": "DISA STIGs", + "idPattern": "^DISA\\.", + "idPrefixes": [ + "DISA." + ], + "folder": "tests/disa", + "productFolders": [] + }, { "id": "EIDSCA", "name": "Entra ID Security Config Analyzer", @@ -8792,6 +8803,257 @@ ] } ] + }, + { + "key": "disa-stig-entra-id", + "name": "DISA Microsoft Entra ID STIG", + "version": "V1R2", + "url": "https://public.cyber.mil/stigs/downloads/?_dl_facet_stigs=microsoft", + "suite": "DISA", + "file": "tests/disa/frameworks/disa-stig-entra-id.json", + "requirements": [ + { + "id": "V-270200", + "tests": [ + "DISA.V-270200" + ], + "related": [ + "nist-800-53-r5:AC-11", + "nist-800-53-r5:AC-12" + ] + }, + { + "id": "V-270204", + "tests": [ + "DISA.V-270204" + ], + "related": [ + "nist-800-53-r5:AC-2(3)" + ] + }, + { + "id": "V-270208", + "tests": [ + "DISA.V-270208" + ], + "related": [ + "nist-800-53-r5:AC-7" + ] + }, + { + "id": "V-270209", + "tests": [ + "DISA.V-270209" + ], + "related": [ + "nist-800-53-r5:AC-8" + ] + }, + { + "id": "V-270227", + "tests": [ + "DISA.V-270227" + ], + "related": [ + "nist-800-53-r5:AU-4(1)", + "nist-800-53-r5:AU-9(2)" + ] + }, + { + "id": "V-270233", + "tests": [ + "DISA.V-270233" + ], + "related": [ + "nist-800-53-r5:IA-2(1)", + "nist-800-53-r5:IA-2(2)" + ] + }, + { + "id": "V-270239", + "tests": [ + "DISA.V-270239" + ], + "related": [ + "nist-800-53-r5:IA-5(1)" + ] + }, + { + "id": "V-270255", + "tests": [ + "DISA.V-270255" + ], + "related": [ + "nist-800-53-r5:AC-2(1)" + ] + }, + { + "id": "V-270335", + "tests": [ + "DISA.V-270335" + ], + "related": [ + "nist-800-53-r5:AC-2(2)" + ] + }, + { + "id": "V-270475", + "tests": [ + "DISA.V-270475" + ], + "related": [ + "nist-800-53-r5:IA-5(1)" + ] + } + ] + }, + { + "key": "disa-stig-intune-desktop", + "name": "DISA Microsoft Intune MDM Service Desktop STIG", + "version": "V1R1", + "url": "https://public.cyber.mil/stigs/downloads/?_dl_facet_stigs=microsoft", + "suite": "DISA", + "file": "tests/disa/frameworks/disa-stig-intune-desktop.json", + "requirements": [ + { + "id": "V-267303", + "tests": [ + "DISA.V-267303" + ], + "related": [ + "nist-800-53-r5:AC-11", + "nist-800-53-r5:AC-12" + ] + }, + { + "id": "V-267309", + "tests": [ + "DISA.V-267309" + ], + "related": [ + "nist-800-53-r5:AC-2(3)" + ] + }, + { + "id": "V-267314", + "tests": [ + "DISA.V-267314" + ], + "related": [ + "nist-800-53-r5:AC-7" + ] + }, + { + "id": "V-267315", + "tests": [], + "related": [ + "nist-800-53-r5:AC-8" + ] + }, + { + "id": "V-267334", + "tests": [ + "DISA.V-267334" + ], + "related": [ + "nist-800-53-r5:AU-4(1)", + "nist-800-53-r5:AU-9(2)" + ] + }, + { + "id": "V-267341", + "tests": [ + "DISA.V-267341" + ], + "related": [ + "nist-800-53-r5:IA-2(1)", + "nist-800-53-r5:IA-2(2)" + ] + }, + { + "id": "V-267355", + "tests": [ + "DISA.V-267355" + ], + "related": [ + "nist-800-53-r5:IA-5(1)" + ] + }, + { + "id": "V-267372", + "tests": [], + "related": [ + "nist-800-53-r5:AC-2(4)" + ] + }, + { + "id": "V-267373", + "tests": [], + "related": [ + "nist-800-53-r5:AC-2(4)" + ] + }, + { + "id": "V-267374", + "tests": [], + "related": [ + "nist-800-53-r5:AC-2(4)" + ] + }, + { + "id": "V-267375", + "tests": [], + "related": [ + "nist-800-53-r5:AC-2(4)" + ] + }, + { + "id": "V-267379", + "tests": [], + "related": [ + "nist-800-53-r5:AC-2(1)" + ] + } + ] + }, + { + "key": "disa-stig-intune-mdm", + "name": "DISA Microsoft Intune MDM Service Desktop and Mobile STIG", + "version": "V1R2", + "url": "https://public.cyber.mil/stigs/downloads/?_dl_facet_stigs=microsoft", + "suite": "DISA", + "file": "tests/disa/frameworks/disa-stig-intune-mdm.json", + "requirements": [ + { + "id": "V-273867", + "tests": [ + "DISA.V-273867" + ], + "related": [ + "nist-800-53-r5:AC-11", + "nist-800-53-r5:AC-12" + ] + }, + { + "id": "V-273868", + "tests": [ + "DISA.V-273868" + ], + "related": [ + "nist-800-53-r5:AU-4(1)", + "nist-800-53-r5:AU-9(2)" + ] + }, + { + "id": "V-285327", + "tests": [ + "DISA.V-285327" + ], + "related": [ + "nist-800-53-r5:CM-6" + ] + } + ] } ], "nist": { @@ -17989,7 +18251,7 @@ "UserImpact": "How much the recommended fix disrupts end users. Administrators and the owners of applications are not end\nusers here. Developers are the end users of Azure DevOps and GitHub.\n\n| Value | Applying the fix |\n| --- | --- |\n| `Low` | End users notice nothing, or only administrators are affected. |\n| `Medium` | Some users change how they work or meet a new prompt: a group loses a capability, users register a method once, a legacy client stops working for a subset. |\n| `High` | Most users change a daily habit, or a mistake locks people out or stops mail or an app for many. Needs communication and a staged rollout. |\n\nOmit `UserImpact` when `Severity` is `Info`.", "ImplementationCost": "How much administrator work the recommended fix takes.\n\n| Value | The fix is |\n| --- | --- |\n| `Low` | One setting or one policy in one portal. Under an hour, with no dependency on another team, a licence purchase or a rollout. |\n| `Medium` | Several steps: a policy that needs exclusions and a pilot, clean-up of a handful of objects, coordination with one other team. Hours to a few days. |\n| `High` | A project: new licences, infrastructure or process, a migration of users or apps, or clean-up across many objects. Weeks or more. |\n\nClean-up that one administrator can finish alone in a sitting is `Low`. Clean-up that needs the owner of each\nobject is `Medium`. Turning on a plan that is billed by use is `Medium`: the click is easy, the budget approval is\nnot. Count the work of the fix, including exclusions and rollout, but not the time to decide.\n\nOmit `ImplementationCost` when `Severity` is `Info`.", "Mitre": "The MITRE ATT&CK techniques that the checked control prevents or detects. A list of technique IDs, or `None`.\n\n- IDs only, in the form `T1110` or `T1110.003`. Tactic names are looked up from the pinned ATT&CK release\n (`powershell/assets/MaesterAttackTechniques.json`) and are never typed.\n- Use a sub-technique when the control addresses only that sub-technique. When three or more sub-techniques of\n one technique apply, list the technique instead. Do not list a technique together with one of its own\n sub-techniques.\n- List a technique only if the test's description explains, or plainly implies, how the control stops or reveals\n it. At most five.\n- A test that implements a benchmark which publishes a mapping, such as CISA SCuBA, starts from that mapping and\n then applies these rules. An ID the pinned release has retired is replaced by its successor in that release,\n found by name.\n- The description means the comment-based help and the Markdown file together.\n- Use `None` for a test with no attacker behaviour behind it, such as replication health or an inventory count.\n An inventory test lists a technique only when the fact it reports is itself the precondition of that technique,\n such as accounts that do not require Kerberos pre-authentication.\n- A retired or unknown ID fails the unit tests.", - "Control": "Requirements of frameworks the test implements or supports, written `:`, for\nexample `cis-m365:5.1.5.1`, `cisa-scuba:MS.AAD.3.1` or `nist-800-53-r5:IA-2(1)`. Optional list. Any test can use\nit: one shipped with Maester or one of your own.\n\n- `Control` is the only way a test is mapped to a framework. A CIS test carries `Control = 'cis-m365:5.1.5.1'` and\n a CISA test carries `Control = 'cisa-scuba:MS.AAD.3.1'` and an ASD test `Control = 'essential-eight:ISM-1504'`.\n Every test in `tests/cis`, `tests/cisa` and `tests/asd` must name a requirement of its suite's framework. The unit\n tests check this.\n- The first value that names a requirement in a framework file becomes the `Benchmark` of the result. Put the\n requirement the test is written for first, and any other requirement it supports after it.\n- Use the same attribute for a test that exists for its own reasons and also supports a requirement: a Maester\n test that checks the setting a CISA policy asks for, or a CIS test that also supports a NIST control.\n- When the key is a framework shipped with Maester (`cis-m365`, `cis-github`, `cisa-scuba`, `essential-eight`, `ism`), the requirement must\n exist in that framework's file. If it is new, add it to the file with its facts. The module build and the unit\n tests fail otherwise.\n- Do not repeat the `Related` controls of a requirement. The framework file lists them and Maester adds them to\n the result.\n- List a requirement only when a passing result is evidence for it. A test that checks one part of a requirement\n may list it; a test that is merely on the same topic may not.\n\nA reference says the test supports the requirement. It never says the organization complies with it.\n\n### NIST SP 800-53\n\nA test may list the NIST SP 800-53 Rev. 5 controls its setting implements, as `nist-800-53-r5:`.\n\n- Use an ID from the pinned list, [`powershell/assets/MaesterNistControls.json`](https://github.com/maester365/maester/blob/main/powershell/assets/MaesterNistControls.json):\n a base control (`AC-2`) or an enhancement (`IA-2(1)`). The unit tests reject anything else.\n- List a control only when a passing result is direct evidence that it is implemented for what the test checks.\n- Prefer the enhancement when the test checks exactly what it says: MFA for privileged accounts is `IA-2(1)`.\n Do not list a base control together with one of its own enhancements.\n- At most three, best fit first. Never the policy-and-procedures controls (`AC-1`, `IA-1` and so on).\n- A test that only reports a count, or checks health, licensing or tidiness, lists none, unless the count is\n itself what a control asks to be tracked: dormant accounts for `AC-2(3)`.\n- A test that implements a CISA SCuBA policy does not list NIST controls. CISA publishes that mapping, the\n framework file carries it as `Related`, and the result gets it from there.", + "Control": "Requirements of frameworks the test implements or supports, written `:`, for\nexample `cis-m365:5.1.5.1`, `cisa-scuba:MS.AAD.3.1` or `nist-800-53-r5:IA-2(1)`. Optional list. Any test can use\nit: one shipped with Maester or one of your own.\n\n- `Control` is the only way a test is mapped to a framework. A CIS test carries `Control = 'cis-m365:5.1.5.1'` and\n a CISA test carries `Control = 'cisa-scuba:MS.AAD.3.1'` and an ASD test `Control = 'essential-eight:ISM-1504'`.\n Every test in `tests/cis`, `tests/cisa`, `tests/asd` and `tests/disa` must name a requirement of its suite's framework. The unit\n tests check this.\n- The first value that names a requirement in a framework file becomes the `Benchmark` of the result. Put the\n requirement the test is written for first, and any other requirement it supports after it.\n- Use the same attribute for a test that exists for its own reasons and also supports a requirement: a Maester\n test that checks the setting a CISA policy asks for, or a CIS test that also supports a NIST control.\n- When the key is a framework shipped with Maester (`cis-m365`, `cis-github`, `cisa-scuba`, `essential-eight`, `ism`), the requirement must\n exist in that framework's file. If it is new, add it to the file with its facts. The module build and the unit\n tests fail otherwise.\n- Do not repeat the `Related` controls of a requirement. The framework file lists them and Maester adds them to\n the result.\n- List a requirement only when a passing result is evidence for it. A test that checks one part of a requirement\n may list it; a test that is merely on the same topic may not.\n\nA reference says the test supports the requirement. It never says the organization complies with it.\n\n### NIST SP 800-53\n\nA test may list the NIST SP 800-53 Rev. 5 controls its setting implements, as `nist-800-53-r5:`.\n\n- Use an ID from the pinned list, [`powershell/assets/MaesterNistControls.json`](https://github.com/maester365/maester/blob/main/powershell/assets/MaesterNistControls.json):\n a base control (`AC-2`) or an enhancement (`IA-2(1)`). The unit tests reject anything else.\n- List a control only when a passing result is direct evidence that it is implemented for what the test checks.\n- Prefer the enhancement when the test checks exactly what it says: MFA for privileged accounts is `IA-2(1)`.\n Do not list a base control together with one of its own enhancements.\n- At most three, best fit first. Never the policy-and-procedures controls (`AC-1`, `IA-1` and so on).\n- A test that only reports a count, or checks health, licensing or tidiness, lists none, unless the count is\n itself what a control asks to be tracked: dormant accounts for `AC-2(3)`.\n- A test that implements a CISA SCuBA policy does not list NIST controls. CISA publishes that mapping, the\n framework file carries it as `Related`, and the result gets it from there.", "Lifecycle and ReplacedBy": "- `Preview`: new and still changing. Not run unless previews are included.\n- `Stable`: the default.\n- `Deprecated`: kept so history stays readable. Give `ReplacedBy` when another test took its place.", "Tag": "`Tag` holds labels the owner of a test folder finds useful. It is not part of Maester's taxonomy.\n\n- Built-in tests do not carry tags for product, feature, area, suite, benchmark, licence, severity or their own ID.\n Each of those has an attribute or is derived.\n- A custom test may tag freely.", "How the rubric is enforced": "1. **Unit tests** (`powershell/tests/general/NativeTestAttributes.Tests.ps1`) fail when a built-in test misses a\n required attribute, uses a key that is not in the taxonomy, pairs a feature with the wrong product, lists a\n retired ATT&CK technique, carries a taxonomy tag, names a requirement that a shipped framework file does not\n have, or is a CIS or CISA test without a `Control` for its own framework.\n2. **Attribute review** runs on every pull request that adds a test or changes one of these attributes. A\n reviewer model reads the test, its Markdown file and this page, and fails the check when a value does not fit\n the rubric, with the value it expected and the reason. It also sees the attributes of the other tests with the\n same product and feature. It fails a test whose area, resource type or severity differs from the same check in\n another suite, and whose user impact or implementation cost differs when both plainly recommend the same fix.\n MITRE techniques and related products are not compared. A maintainer can overrule it.\n3. **Reviewers**, human or agent, apply the same page. See `AGENTS.md`." diff --git a/website/src/pages/index.astro b/website/src/pages/index.astro index b0ea72e09b..16019a45b7 100644 --- a/website/src/pages/index.astro +++ b/website/src/pages/index.astro @@ -28,6 +28,7 @@ const suites = [ { code: 'MT', name: 'Maester checks', desc: 'Checks written by the community for what the frameworks miss: Conditional Access, apps, Intune and more.', count: bySuite('Maester') + bySuite('XSPM'), href: '/docs/tests/maester' }, { code: 'AD', name: 'Active Directory', desc: 'Read-only checks for your on-premises domains: GPOs, DACLs, Kerberos, trusts and more.', count: bySuite('AD'), href: '/docs/tests/ad' }, { code: 'ASD', name: 'ASD Essential Eight', desc: "The Australian Signals Directorate's Essential Eight and ISM controls.", count: bySuite('ASD'), href: '/docs/tests/asd' }, + { code: 'DISA', name: 'DISA STIGs', desc: 'The US Defense Information Systems Agency STIGs for Entra ID and Intune.', count: bySuite('DISA'), href: '/docs/tests/disa' }, { code: 'PACKS', name: 'Community packs', desc: 'Checks from community packs on packs.maester.cloud, among them the CIS Intune benchmarks for Windows, macOS, iOS and Edge.', count: community, href: 'https://packs.maester.cloud' }, ]; From 34e16ef4c0ceab2ed35d53f769536c9efa7e869f Mon Sep 17 00:00:00 2001 From: Julien Ly Date: Mon, 9 Nov 2026 21:44:31 +0100 Subject: [PATCH 02/19] fix(intune): name the Trellix connector in MT.1098 (#2753) The ID table had 4873197-ffec-4dfc-9816-db65f34c7cb9, with seven hex characters in its first block, so a Trellix connector was shown by its raw ID. A Trellix Mobile Security connector created in the Intune admin center gets 74873197-ffec-4dfc-9816-db65f34c7cb9. --- .../Test-MtMobileThreatDefenseConnectors.Tests.ps1 | 8 ++++++++ tests/maester/intune/Test.MT.1098.ps1 | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/powershell/tests/functions/Test-MtMobileThreatDefenseConnectors.Tests.ps1 b/powershell/tests/functions/Test-MtMobileThreatDefenseConnectors.Tests.ps1 index 78d7329bc1..3a2a14fc1a 100644 --- a/powershell/tests/functions/Test-MtMobileThreatDefenseConnectors.Tests.ps1 +++ b/powershell/tests/functions/Test-MtMobileThreatDefenseConnectors.Tests.ps1 @@ -94,6 +94,14 @@ Describe 'Test-MtMobileThreatDefenseConnectors' { $script:Result | Should -BeLike '*Microsoft Defender for Endpoint*' } + It 'Names the Trellix connector by the ID Intune assigns to it' { + $script:Connector.id = '74873197-ffec-4dfc-9816-db65f34c7cb9' + + Test-MtMobileThreatDefenseConnectors | Should -BeTrue + $script:Result | Should -BeLike '*| Trellix Mobile Security |*' + $script:Result | Should -Not -BeLike '*74873197*' + } + It 'Escapes unknown connector IDs and states in the report table' { $script:Connector.id = '[link](https://example.test) | extra' $script:Connector.partnerState = '**unknown** | extra' diff --git a/tests/maester/intune/Test.MT.1098.ps1 b/tests/maester/intune/Test.MT.1098.ps1 index bb8c2b8115..a49ba3d649 100644 --- a/tests/maester/intune/Test.MT.1098.ps1 +++ b/tests/maester/intune/Test.MT.1098.ps1 @@ -46,7 +46,7 @@ '860d3ab4-8fd1-45f5-89cd-ecf51e4f92e5' = 'BETTER Mobile Security' '870b252b-0ef0-4707-8847-50fc571472b3' = 'Sophos' '1f58d6d2-02cc-4c80-b008-1bfe7396a10a' = 'Jamf Trust' - '4873197-ffec-4dfc-9816-db65f34c7cb9' = 'Trellix Mobile Security' + '74873197-ffec-4dfc-9816-db65f34c7cb9' = 'Trellix Mobile Security' 'a447eca6-a986-4d3f-9838-5862bf50776c' = 'CylancePROTECT Mobile' '4928f0f6-2660-4f69-b4c5-5170ec921f7b' = 'Trend Micro' 'bb13fe25-ce1f-45aa-b278-cabbc6b9072e' = 'SentinelOne' From 68848811ea8a4922e413aa562ca2b34ed0452acd Mon Sep 17 00:00:00 2001 From: Merill Fernando Date: Tue, 10 Nov 2026 18:00:06 +1100 Subject: [PATCH 03/19] fix(website): move the organisation sponsor block to the bottom of the sponsor page (#2776) The maintainers' sponsor cards now come first. The organisations block drops the sentence about the review rubric and replaces the Discord invoicing link with an email link to sponsor@maester.cloud. Entire-Checkpoint: 01M72426V0Y487ESE0RTG59B7R Co-authored-by: Claude Opus 5.5 --- website/src/pages/sponsor.astro | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/website/src/pages/sponsor.astro b/website/src/pages/sponsor.astro index c3c50081a2..12bbd395f1 100644 --- a/website/src/pages/sponsor.astro +++ b/website/src/pages/sponsor.astro @@ -1,6 +1,6 @@ --- -// Sponsor: organisations first, then the people who build Maester (their GitHub Sponsors listings, refreshed -// on each deploy by scripts/sponsors.mjs into src/data/sponsors.json). +// Sponsor: the people who build Maester first (their GitHub Sponsors listings, refreshed on each deploy by +// scripts/sponsors.mjs into src/data/sponsors.json), then organisations. import SiteLayout from '../layouts/SiteLayout.astro'; import SponsorPage from '../react/SponsorPage.jsx'; --- @@ -10,6 +10,7 @@ import SponsorPage from '../react/SponsorPage.jsx'; description="Maester is free and open source. Sponsor the project as an organisation, or sponsor the people who build it." wide > +

For organisations

@@ -17,15 +18,16 @@ import SponsorPage from '../react/SponsorPage.jsx';

Sponsorship pays for maintainer time, the test tenants every check is proven against, and the Microsoft licences those tenants need. Organisation sponsors are thanked with their logo on this page, on the home page and in the - README. Sponsorship never changes what a check reports: every check is reviewed against the same public rubric. + README.

- From 38bd4f9a3e35a8744d54d4b4a2322b039c8e885a Mon Sep 17 00:00:00 2001 From: Sven Frank <82213858+FiraSenax@users.noreply.github.com> Date: Tue, 17 Nov 2026 20:30:18 +0100 Subject: [PATCH 17/19] fix(ad): preserve typed OU modification dates --- .../tests/functions/ADSiteOuBatch.Tests.ps1 | 16 ++++++++++++++++ tests/ad/ou/Test.AD-OU-03.ps1 | 8 ++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/powershell/tests/functions/ADSiteOuBatch.Tests.ps1 b/powershell/tests/functions/ADSiteOuBatch.Tests.ps1 index ee55590e68..8f3d8c9de5 100644 --- a/powershell/tests/functions/ADSiteOuBatch.Tests.ps1 +++ b/powershell/tests/functions/ADSiteOuBatch.Tests.ps1 @@ -126,6 +126,22 @@ Describe 'AD site, subnet, OU and printer checks with state' -F $script:detail.Text | Should -Match '1 OU\(s\)' } + It 'keeps typed OU modification dates independent of parsing' -ForEach @( + @{ Culture = 'de-DE' } + @{ Culture = 'en-US' } + ) { + $previousCulture = [Globalization.CultureInfo]::CurrentCulture + try { + [Globalization.CultureInfo]::CurrentCulture = [Globalization.CultureInfo]::new($Culture) + $script:state.OrganizationalUnits[0].Modified = [datetime]::new(2010, 11, 17) + Test-MtAdOuStaleCount -MaximumAgeYears 5 | Should -BeTrue + $script:detail.Text | Should -Match '\| 2010-11-17 \|' + $script:detail.Text | Should -Match '1 OU\(s\)' + } finally { + [Globalization.CultureInfo]::CurrentCulture = $previousCulture + } + } + It 'reports printer name, server, location and description for review' { Test-MtAdPrinterTotalCount | Should -BeTrue $script:detail.Investigate | Should -BeTrue diff --git a/tests/ad/ou/Test.AD-OU-03.ps1 b/tests/ad/ou/Test.AD-OU-03.ps1 index 1de74d8c89..0dfdf1e86c 100644 --- a/tests/ad/ou/Test.AD-OU-03.ps1 +++ b/tests/ad/ou/Test.AD-OU-03.ps1 @@ -38,8 +38,12 @@ foreach ($ou in $ous) { $value = if ($null -ne $ou.Modified) { $ou.Modified } elseif ($null -ne $ou.whenChanged) { $ou.whenChanged } elseif ($null -ne $ou.modifyTimeStamp) { $ou.modifyTimeStamp } else { $null } if ($null -eq $value -or [string]::IsNullOrWhiteSpace([string]$value)) { throw "OU '$($ou.DistinguishedName)' has no modification date." } - $date = [datetime]::MinValue - if (-not [datetime]::TryParse([string]$value, [ref]$date)) { throw "OU '$($ou.DistinguishedName)' has an invalid modification date." } + if ($value -is [datetime]) { + $date = $value + } else { + $date = [datetime]::MinValue + if (-not [datetime]::TryParse([string]$value, [ref]$date)) { throw "OU '$($ou.DistinguishedName)' has an invalid modification date." } + } if ($date -lt $cutoff) { $old++ $rows += '| {0} | {1} | {2} |' -f (Format-MtAdSiteInventoryValue $ou.Name), $date.ToString('yyyy-MM-dd'), (Format-MtAdSiteInventoryValue $ou.DistinguishedName) From 92405fcab7bb72a752ea5938e9f6c65a40abc7e5 Mon Sep 17 00:00:00 2001 From: Sven Frank <82213858+FiraSenax@users.noreply.github.com> Date: Tue, 17 Nov 2026 20:30:18 +0100 Subject: [PATCH 18/19] build: refresh authoring data after AD consolidation --- website/src/data/test-builder.json | 123 ++++++++++++++++++++++++++++- 1 file changed, 119 insertions(+), 4 deletions(-) diff --git a/website/src/data/test-builder.json b/website/src/data/test-builder.json index 2b025d35ea..09fbe1cb60 100644 --- a/website/src/data/test-builder.json +++ b/website/src/data/test-builder.json @@ -18359,6 +18359,11 @@ "type": "string[]", "tests": 1 }, + { + "name": "AccountIds", + "type": "string[]", + "tests": 1 + }, { "name": "AllDevices", "type": "switch", @@ -18379,11 +18384,41 @@ "type": "string[]", "tests": 1 }, + { + "name": "AllowedPrimaryGroupIds", + "type": "string[]", + "tests": 1 + }, + { + "name": "AllowedSitesWithoutDcs", + "type": "string[]", + "tests": 1 + }, + { + "name": "ApprovedAccountIds", + "type": "string[]", + "tests": 1 + }, + { + "name": "ApprovedPathPrefixes", + "type": "string[]", + "tests": 1 + }, + { + "name": "AssessmentMode", + "type": "string", + "tests": 1 + }, { "name": "ComplianceLogic", "type": "string", "tests": 24 }, + { + "name": "ConfigurationProfile", + "type": "string", + "tests": 3 + }, { "name": "EmergencyAccessAccounts", "type": "object[]", @@ -18394,11 +18429,26 @@ "type": "int", "tests": 1 }, + { + "name": "ExcludedUsers", + "type": "string[]", + "tests": 1 + }, { "name": "ExpiringWithinDays", "type": "int", "tests": 1 }, + { + "name": "GraceDays", + "type": "int", + "tests": 1 + }, + { + "name": "KeyInventoryReadAccessConfirmed", + "type": "bool", + "tests": 1 + }, { "name": "MailboxServicePlanIds", "type": "string[]", @@ -18409,6 +18459,16 @@ "type": "int", "tests": 1 }, + { + "name": "MaximumAgeDays", + "type": "int", + "tests": 4 + }, + { + "name": "MaximumAgeYears", + "type": "int", + "tests": 2 + }, { "name": "MaximumDevicesPerUser", "type": "int", @@ -18432,7 +18492,7 @@ { "name": "MaximumInactiveDays", "type": "int", - "tests": 7 + "tests": 6 }, { "name": "MaximumInactivityMinutes", @@ -18462,12 +18522,17 @@ { "name": "MaximumLockoutThreshold", "type": "int", - "tests": 4 + "tests": 6 + }, + { + "name": "MaximumLogonTimestampLagDays", + "type": "int", + "tests": 1 }, { "name": "MaximumPasswordAgeDays", "type": "int", - "tests": 3 + "tests": 4 }, { "name": "MaximumPatchLevelAgeDays", @@ -18492,23 +18557,43 @@ { "name": "MaximumValidationAgeDays", "type": "int", - "tests": 2 + "tests": 1 }, { "name": "MaximumValidityDays", "type": "int", "tests": 2 }, + { + "name": "MinimumHistory", + "type": "int", + "tests": 2 + }, + { + "name": "MinimumIdleDays", + "type": "int", + "tests": 1 + }, { "name": "MinimumIPv4PrefixLength", "type": "int", "tests": 1 }, + { + "name": "MinimumLength", + "type": "int", + "tests": 2 + }, { "name": "MinimumLockoutDurationSeconds", "type": "int", "tests": 4 }, + { + "name": "MinimumLockoutMinutes", + "type": "int", + "tests": 2 + }, { "name": "MinimumOsVersion", "type": "string", @@ -18524,6 +18609,16 @@ "type": "int", "tests": 1 }, + { + "name": "MinimumResetMinutes", + "type": "int", + "tests": 2 + }, + { + "name": "MinimumSupportedRelease", + "type": "int", + "tests": 1 + }, { "name": "ParkedDomains", "type": "string[]", @@ -18534,11 +18629,26 @@ "type": "string", "tests": 24 }, + { + "name": "PolicyInventoryReadAccessConfirmed", + "type": "bool", + "tests": 2 + }, { "name": "RecentModificationDays", "type": "int", "tests": 1 }, + { + "name": "RecommendedMinimumDays", + "type": "int", + "tests": 1 + }, + { + "name": "RegexPatterns", + "type": "string[]", + "tests": 1 + }, { "name": "RequiredLogCategories", "type": "string[]", @@ -18554,6 +18664,11 @@ "type": "string[]", "tests": 1 }, + { + "name": "RetentionDays", + "type": "int", + "tests": 1 + }, { "name": "Selector", "type": "string", From 809eda8be7da66bdd4ddf0cefe5f962dc31591c3 Mon Sep 17 00:00:00 2001 From: Sven Frank <82213858+FiraSenax@users.noreply.github.com> Date: Tue, 17 Nov 2026 20:40:51 +0100 Subject: [PATCH 19/19] fix(ad): normalize LDAP certificate byte projections --- .../ad/ad/Get-MtAdCertificateInventory.ps1 | 8 +++- .../ADCertificateInventoryBatch.Tests.ps1 | 48 +++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/powershell/internal/checks/ad/ad/Get-MtAdCertificateInventory.ps1 b/powershell/internal/checks/ad/ad/Get-MtAdCertificateInventory.ps1 index c0b95aa787..d557f10a55 100644 --- a/powershell/internal/checks/ad/ad/Get-MtAdCertificateInventory.ps1 +++ b/powershell/internal/checks/ad/ad/Get-MtAdCertificateInventory.ps1 @@ -19,12 +19,18 @@ $values = [System.Collections.Generic.List[object]]::new() if ($raw -is [byte[]] -or $raw -is [string]) { $values.Add($raw) + } elseif ($raw -is [array] -and $raw.Count -gt 0 -and @($raw | Where-Object { $_ -isnot [byte] }).Count -eq 0) { + # A single LDAP binary attribute can be projected as an object array of bytes. + $values.Add([byte[]]$raw) } elseif ($null -ne $raw) { foreach ($value in $raw) { $values.Add($value) } } foreach ($value in $values) { if ($null -eq $value) { continue } - $bytes = if ($value -is [byte[]]) { $value } elseif ($value -is [string]) { + $bytes = if ($value -is [byte[]]) { $value } elseif ($value -is [array] -and $value.Count -gt 0 -and @($value | Where-Object { $_ -isnot [byte] }).Count -eq 0) { + # Each value of a multi-valued LDAP binary attribute can also be projected as an object array of bytes. + [byte[]]$value + } elseif ($value -is [string]) { try { [Convert]::FromBase64String($value) } catch { throw "Invalid certificate encoding for $($role.Name) $($entry.Name)." } } else { throw "Unsupported certificate value for $($role.Name) $($entry.Name)." } try { diff --git a/powershell/tests/functions/ADCertificateInventoryBatch.Tests.ps1 b/powershell/tests/functions/ADCertificateInventoryBatch.Tests.ps1 index 4093fc2b03..62c6b3da85 100644 --- a/powershell/tests/functions/ADCertificateInventoryBatch.Tests.ps1 +++ b/powershell/tests/functions/ADCertificateInventoryBatch.Tests.ps1 @@ -26,6 +26,54 @@ Describe 'AD configuration inventory batch' { { Get-MtAdCertificateInventory -Configuration $config } | Should -Throw '*Unable to parse public certificate*' } + Context 'LDAP binary projection in the inventory' -ForEach @( + @{ Property = 'EnterpriseCAs'; Role = 'Enterprise CA' } + @{ Property = 'TrustedRootCAs'; Role = 'Trusted root' } + @{ Property = 'IntermediateCAs'; Role = 'Intermediate' } + @{ Property = 'NtAuthCertificates'; Role = 'NTAuth' } + ) { + BeforeEach { + $script:projectionConfiguration = [pscustomobject]@{ + EnterpriseCAs = @(); TrustedRootCAs = @(); IntermediateCAs = @(); NtAuthCertificates = @() + } + } + + It 'accepts a single DER value projected as an object array of bytes' { + $script:projectionConfiguration.$Property = @([pscustomobject]@{ Name = 'Projected CA'; cACertificate = [object[]]$script:certBytes }) + $rows = @(Get-MtAdCertificateInventory -Configuration $script:projectionConfiguration) + $rows.Count | Should -Be 1 + $rows[0].Role | Should -Be $Role + $rows[0].Thumbprint | Should -Not -BeNullOrEmpty + $rows[0].PSObject.Properties.Name | Should -Not -Contain RawData + } + + It 'retains multiple projected DER values on one directory object' { + $values = [Collections.Generic.List[object]]::new() + $values.Add([object[]]$script:certBytes) + $values.Add([object[]]$script:certBytes) + $script:projectionConfiguration.$Property = @([pscustomobject]@{ Name = 'Two certificates'; cACertificate = $values.ToArray() }) + $rows = @(Get-MtAdCertificateInventory -Configuration $script:projectionConfiguration) + $rows.Count | Should -Be 2 + @($rows | Where-Object Role -EQ $Role).Count | Should -Be 2 + } + + It 'rejects non-byte content alongside a valid projected certificate' { + $values = [Collections.Generic.List[object]]::new() + $values.Add([object[]]$script:certBytes) + $values.Add(@([byte]1, 'unexpected value')) + $script:projectionConfiguration.$Property = @([pscustomobject]@{ Name = 'Mixed input'; cACertificate = $values.ToArray() }) + { Get-MtAdCertificateInventory -Configuration $script:projectionConfiguration } | Should -Throw '*Unsupported certificate value*' + } + + It 'rejects malformed DER alongside a valid projected certificate' { + $values = [Collections.Generic.List[object]]::new() + $values.Add([object[]]$script:certBytes) + $values.Add([object[]][byte[]](1, 2, 3)) + $script:projectionConfiguration.$Property = @([pscustomobject]@{ Name = 'Malformed input'; cACertificate = $values.ToArray() }) + { Get-MtAdCertificateInventory -Configuration $script:projectionConfiguration } | Should -Throw '*Unable to parse public certificate*' + } + } + It 'distinguishes missing data from a retrieved empty collection' { $state = [pscustomobject]@{ Configuration = [pscustomobject]@{ SiteLinks = @() } } @(Get-MtAdConfigurationInventory -State $state -Required SiteLinks).Count | Should -Be 1