From 96f4b6ac5a3b1a18159d98801c86b0fdf2842799 Mon Sep 17 00:00:00 2001 From: Snozz-Al Date: Sat, 21 Nov 2026 12:55:51 +0000 Subject: [PATCH] feat(ad): add LDAP connection security report --- tests/ad/security/Test.AD-LDAP-01.md | 52 ++++++ tests/ad/security/Test.AD-LDAP-01.ps1 | 167 ++++++++++++++++++ .../domain-controller-configuration-state.md | 30 ++++ 3 files changed, 249 insertions(+) create mode 100644 tests/ad/security/Test.AD-LDAP-01.md create mode 100644 tests/ad/security/Test.AD-LDAP-01.ps1 create mode 100644 website/docs/advanced/domain-controller-configuration-state.md diff --git a/tests/ad/security/Test.AD-LDAP-01.md b/tests/ad/security/Test.AD-LDAP-01.md new file mode 100644 index 0000000000..0e0e69680f --- /dev/null +++ b/tests/ad/security/Test.AD-LDAP-01.md @@ -0,0 +1,52 @@ +Reports the available evidence for LDAP encryption, signing, and Kerberos authentication from Maester's cached Active Directory domain state. + +This informational check always requests investigation. It reports the **domain-state collection connection**, which can be a separate connection from the initial `Connect-Maester` bind, and the SASL mechanisms advertised by that connection's domain controller. It does not probe alternative protocols, read DC enforcement policies, or assess every domain controller. Existing SASL inventories **AD-ROOTDSE-01** and **AD-ROOTDSE-02** enumerate mechanisms; this check adds connection-state context and explicitly identifies gaps in security evidence. + +The report has two sections: + +1. **Connection actually used:** one connection assessment and three components that apply **together (AND)**: transport, certificate validation, and authentication. An Undesirable component takes precedence; otherwise missing evidence makes the assessment Unknown, an authentication choice needing attention makes it Review, and positive evidence for all three makes it Good. This assessment describes recorded configuration, not an independent audit of platform trust settings or domain-wide compliance. +2. **Alternative connection options:** separate tables for **transport choices (OR)** and **authentication choices (OR)**. Choose one of each: **(LDAPS OR StartTLS) AND (an authentication method)**. A transport or authentication capability alone does not prove every combination will work with your credentials, certificates, DNS/SPNs, and policies. Alternatives without recorded results remain unknown. Auto mode may have attempted and failed LDAPS before selecting StartTLS; attempt history is not included in the cached evidence. + +Each row includes an indicator: + +| Indicator | Interpretation | +| --- | --- | +| Good | Positive evidence for that particular property or a secure connection option. It does not certify the whole connection or domain. | +| Review | A limitation or authentication choice warrants investigation, such as Negotiate fallback or Basic authentication even when protected by TLS. | +| Undesirable | Avoid this production configuration: no TLS, certificate-validation bypass, or legacy NTLM authentication. | +| Unknown | Evidence is missing, not collected, or the alternative's result was not recorded. | + +The check remains informational and always returns **Investigate**. Indicators help interpret observations; they do not add a scored compliance assertion. In particular, a Good transport row does not cancel an Undesirable certificate-validation row; their combined assessment is Undesirable. + +Interpret the evidence separately: + +- **Encryption:** recorded `Ldaps` or `StartTls` demonstrates TLS use for the collection connection and observed support for that mode. The other TLS mode remains unknown. `None` means no TLS, not necessarily no encryption: SASL sealing is not collected. The TLS version, cipher suite, and DC encryption-enforcement policy are not collected. +- **LDAPS versus StartTLS:** LDAPS establishes TLS before LDAP traffic; StartTLS upgrades the LDAP connection to TLS before authentication in Maester. Both receive a Good encryption indicator when recorded as used. StartTLS is not inherently weaker once TLS is established; this check does not infer handshake quality or insecure fallback from the transport name alone. +- **Certificate validation:** a recorded certificate-check bypass means TLS use does not establish trusted server identity or exclude an active interceptor. The transport row explicitly qualifies this limitation. Without a requested bypass, platform default validation applies; this report does not independently audit certificates or the host's validation configuration. +- **Signing:** TLS provides transport integrity. Separate SASL signing/sealing state, support, and DC LDAP signing-enforcement policies are not collected. A TLS bind neither proves nor disproves DC signing enforcement. +- **Kerberos:** an explicit `Kerberos` bind mode is reported as such, and the capability table prefers a successfully recorded explicit bind mode over an advertisement. `Negotiate` can select Kerberos or NTLM, so actual Kerberos use remains unknown. Without an explicit Kerberos bind, a `GSSAPI` advertisement indicates capability only, not successful Kerberos authentication or Kerberos-only enforcement. A missing advertisement is not proof that Kerberos is unsupported. + +**Unknown / not collected** means the current data source cannot answer the question. It does not mean disabled, unsupported, compliant, or noncompliant. This inventory has no framework mapping because reading the evidence is not proof that a security control is implemented. + +SASL signing/sealing state and effective DC enforcement settings are listed as a single configuration-evidence limitation, not as alternative connection options. Maester can collect configuration through a narrowly scoped, cached read-only management helper, as existing DC SMB checks do. No LDAP-policy collector currently supplies this check. Reading GPO links or advertised SASL mechanisms alone would not prove a DC's effective configuration. Such a collector could target just the contacted DC without testing every protocol against every DC; a domain-wide conclusion would require explicit coverage of the relevant DCs' configuration. + +#### Remediation action + +There is no automatic pass/fail remediation for this informational check. + +1. Review **Connection actually used** and its combined assessment first. Address Undesirable components and investigate Review components. Then review the separate transport and authentication tables under **Alternative connection options**. Do not extrapolate one connection's evidence to all clients or domain controllers. +2. Where TLS is absent or validation is bypassed, review the DC's [LDAPS certificate configuration](https://learn.microsoft.com/windows-server/identity/ad-ds/configure-ldap-signing-certificates) and the trust configuration on the Maester host. Use LDAPS or StartTLS with certificate validation for production collection. +3. To investigate signing enforcement, inspect the effective **Domain controller: LDAP server signing requirements** policies and Directory Service events using Microsoft's [LDAP signing guidance](https://learn.microsoft.com/windows-server/identity/ad-ds/ldap-signing). Evaluate client compatibility before changing policies. This check does not perform an unsigned bind or transmit credentials without TLS. +4. To verify Kerberos rather than Negotiate fallback, review the host's Kerberos prerequisites, DNS/SPNs, and authentication telemetry. An explicit `-ActiveDirectoryAuthMode Kerberos` connection can provide bind-mode evidence on a later run; it does not establish a DC-wide Kerberos-only policy. +5. After any authorized configuration change, start a new Maester session and run the check again so the report uses a new snapshot rather than bypassing the session cache. + +#### Related links + +- [LDAP signing overview for Active Directory](https://learn.microsoft.com/windows-server/identity/ad-ds/ldap-signing) +- [Configure certificates for LDAP over SSL](https://learn.microsoft.com/windows-server/identity/ad-ds/configure-ldap-signing-certificates) +- [Microsoft Negotiate and Kerberos/NTLM selection](https://learn.microsoft.com/windows/win32/secauthn/microsoft-negotiate) +- [Active Directory SASL authentication](https://learn.microsoft.com/openspecs/windows_protocols/ms-adts/989e0748-0953-455d-9d37-d08dfbf3998b) +- [Planned domain-controller configuration-state checks](https://maester.dev/docs/advanced/domain-controller-configuration-state) + + +%TestResult% diff --git a/tests/ad/security/Test.AD-LDAP-01.ps1 b/tests/ad/security/Test.AD-LDAP-01.ps1 new file mode 100644 index 0000000000..fb4e8c7a70 --- /dev/null +++ b/tests/ad/security/Test.AD-LDAP-01.ps1 @@ -0,0 +1,167 @@ +function Test-MtAdLdapConnectionSecurity { + <# + .SYNOPSIS + Reports LDAP encryption, signing, and Kerberos evidence for review. + + .DESCRIPTION + Uses cached Active Directory domain state to report the collection connection's + TLS and authentication modes separately from the contacted domain controller's + observed or advertised capabilities. The connection's transport, certificate + validation, and authentication apply together (AND). Alternative transports + and alternative authentication methods are separate choices (OR). + Signing, sealing, and domain-controller enforcement are not collected. + This inventory does not assess domain-wide compliance or probe other modes. + #> + [MaesterTest( + Id = 'AD-LDAP-01', + Title = 'LDAP encryption, signing, and Kerberos evidence should be investigated', + Product = 'ad', + Feature = 'directory-configuration', + Area = 'authentication', + ResourceType = 'Tenant', + Severity = 'Info', + Mitre = 'None', + Service = 'ActiveDirectory', + Permission = 'ActiveDirectory:Ldap:domainDNS:ReadProperty', + Author = 'soulemike' + )] + [CmdletBinding()] + [OutputType([bool])] + param() + + $adState = Get-MtADDomainState -Categories Domain + if ($null -eq $adState) { + throw 'Active Directory domain state could not be retrieved for the LDAP security report.' + } + + $evidence = $adState.ProtocolEvidence + $tlsMode = [string]$evidence.TlsMode + $authenticationMode = [string]$evidence.AuthenticationMode + $mechanisms = @($adState.RootDSE.SupportedSaslMechanisms | Where-Object { -not [string]::IsNullOrWhiteSpace($_) }) + + $tlsEncryption = switch ($tlsMode) { + 'Ldaps' { 'Enabled (LDAPS; TLS established before LDAP traffic)' } + 'StartTls' { 'Enabled (StartTLS; LDAP connection upgraded to TLS before authentication)' } + 'None' { 'Disabled (no TLS); SASL sealing is unknown' } + default { 'Unknown / not collected' } + } + $certificateValidation = if ($tlsMode -notin 'Ldaps', 'StartTls') { + 'Not applicable or unknown (no recorded TLS connection)' + } elseif ($null -eq $evidence.SkipCertificateCheck) { + 'Unknown / not collected' + } elseif ($evidence.SkipCertificateCheck) { + 'Bypassed; TLS use does not establish trusted server identity' + } else { + 'Bypass not requested; platform default validation applies' + } + if ($tlsMode -in 'Ldaps', 'StartTls' -and $evidence.SkipCertificateCheck) { + $tlsEncryption += '; server identity unverified, so an active interceptor is not excluded' + } + $kerberosAuthentication = switch ($authenticationMode) { + 'Kerberos' { 'Explicit Kerberos bind mode recorded; no negotiated-mechanism telemetry' } + 'Negotiate' { 'Unknown; Negotiate can select Kerberos or NTLM' } + 'Ntlm' { 'Kerberos not selected (NTLM bind mode recorded)' } + 'Basic' { 'Kerberos not selected (Basic bind mode recorded)' } + default { 'Unknown / not collected' } + } + $kerberosSupport = if ($authenticationMode -eq 'Kerberos') { + 'Observed: successful explicit Kerberos bind mode; no negotiated-mechanism telemetry' + } elseif ($mechanisms -contains 'GSSAPI') { + 'Advertised (GSSAPI); does not prove Kerberos use or enforcement' + } else { + 'Unknown; GSSAPI advertisement not available, not proof of unsupported Kerberos' + } + $tlsIndicator = switch ($tlsMode) { + { $_ -in 'Ldaps', 'StartTls' } { 'Good' } + 'None' { 'Undesirable' } + default { 'Unknown' } + } + $certificateIndicator = if ($tlsMode -notin 'Ldaps', 'StartTls' -or $null -eq $evidence.SkipCertificateCheck) { + 'Unknown' + } elseif ($evidence.SkipCertificateCheck) { 'Undesirable' } else { 'Good' } + $authenticationIndicator = switch ($authenticationMode) { + 'Kerberos' { 'Good' } + 'Negotiate' { 'Review' } + 'Ntlm' { 'Undesirable' } + 'Basic' { 'Review' } + default { 'Unknown' } + } + $ldapsSupport = if ($tlsMode -eq 'Ldaps') { 'Observed: successful LDAPS collection connection' } else { 'Unknown / not recorded; a prior attempt may have failed during Auto selection' } + $startTlsSupport = if ($tlsMode -eq 'StartTls') { 'Observed: successful StartTLS collection connection' } else { 'Unknown / not recorded; alternative-mode attempt history is unavailable' } + $negotiateSupport = if ($authenticationMode -eq 'Negotiate') { + 'Observed: successful Negotiate bind; underlying Kerberos or NTLM selection is unverified' + } elseif ($mechanisms -contains 'GSS-SPNEGO' -or $mechanisms -contains 'GSS_SPNEGO') { + 'Advertised (SPNEGO); Kerberos or NTLM selection depends on client and server configuration' + } else { 'Unknown; SPNEGO advertisement not available' } + + $connectionIndicator = if ('Undesirable' -in $tlsIndicator, $certificateIndicator, $authenticationIndicator) { + 'Undesirable' + } elseif ('Unknown' -in $tlsIndicator, $certificateIndicator, $authenticationIndicator) { + 'Unknown' + } elseif ($authenticationIndicator -eq 'Review') { 'Review' } else { 'Good' } + $connectionSummary = switch ($connectionIndicator) { + 'Undesirable' { 'Avoid the recorded configuration for production; review the component marked Undesirable.' } + 'Unknown' { 'There is insufficient evidence to assess the complete connection combination.' } + 'Review' { 'TLS is recorded and certificate-validation bypass was not requested; the authentication choice needs review.' } + 'Good' { 'TLS is recorded, certificate-validation bypass was not requested, and an explicit Kerberos bind mode was selected.' } + } + if ($tlsMode -eq 'None') { + $connectionSummary += ' No TLS does not itself prove absent SASL encryption.' + } + $connectionRows = @( + @{ Property = 'Transport used'; Indicator = $tlsIndicator; Evidence = $tlsEncryption } + @{ Property = 'Certificate validation'; Indicator = $certificateIndicator; Evidence = $certificateValidation } + @{ Property = 'Authentication used'; Indicator = $authenticationIndicator; Evidence = $kerberosAuthentication } + ) + $transportRows = @( + @{ Property = 'LDAPS support'; Indicator = $(if ($tlsMode -eq 'Ldaps') { 'Good' } else { 'Unknown' }); Evidence = $ldapsSupport } + @{ Property = 'StartTLS support'; Indicator = $(if ($tlsMode -eq 'StartTls') { 'Good' } else { 'Unknown' }); Evidence = $startTlsSupport } + ) + $authenticationRows = @( + @{ Property = 'Kerberos support'; Indicator = $(if ($kerberosSupport -match '^(Observed|Advertised):?') { 'Good' } else { 'Unknown' }); Evidence = $kerberosSupport } + @{ Property = 'Negotiate support'; Indicator = $(if ($negotiateSupport -match '^(Observed|Advertised):?') { 'Review' } else { 'Unknown' }); Evidence = $negotiateSupport } + ) + $context = [ordered]@{ + Server = $evidence.ResolvedServer + Domain = $evidence.ResolvedDomain + 'Evidence collected' = $evidence.VerifiedAt + } + $contextText = foreach ($item in $context.GetEnumerator()) { + $value = [string]$item.Value + if ([string]::IsNullOrWhiteSpace($value)) { $value = 'Unknown / not collected' } + $value = [System.Security.SecurityElement]::Escape($value).Replace('|', '|') -replace '[\r\n]+', ' ' + $value = $value -replace '([\\`*_\[\]()])', '\$1' + "$($item.Key): $value" + } + $sections = @( + @{ Heading = '#### Connection actually used'; Intro = "**Connection assessment: $connectionIndicator.** $connectionSummary`n`nThese three components apply **together (AND)**; they are not alternative ways to secure the connection."; Column = 'Component (AND)'; Rows = $connectionRows } + @{ Heading = '#### Alternative connection options'; Intro = 'Choose **one transport (OR)** and **one authentication method (OR)**; the resulting transport and authentication apply **together (AND)**. Evidence for either component alone does not prove every combination will work.'; Subheading = '##### Transport options: choose one (OR)'; Column = 'Transport option (OR)'; Rows = $transportRows } + @{ Subheading = '##### Authentication options: choose one (OR)'; Column = 'Authentication option (OR)'; Rows = $authenticationRows } + ) + $result = ($contextText -join '; ') + "`n`n" + $result += "Evidence describes the cached collection connection and the contacted DC, not every DC in the domain. Good = positive recorded evidence; Review = investigate the authentication choice; Undesirable = avoid this configuration for production; Unknown = insufficient evidence. The check remains informational (Investigate), not a compliance assertion or an independent certificate-validation audit.`n`n" + foreach ($section in $sections) { + if ($section.Heading) { $result += "$($section.Heading)`n`n" } + if ($section.Intro) { $result += "$($section.Intro)`n`n" } + if ($section.Subheading) { $result += "$($section.Subheading)`n`n" } + $result += "| $($section.Column) | Indicator | Evidence |`n| --- | --- | --- |`n" + $rows = foreach ($row in $section.Rows) { + $value = [string]$row.Evidence + $indicator = $row.Indicator + if ([string]::IsNullOrWhiteSpace($value)) { + $value = 'Unknown / not collected' + $indicator = 'Unknown' + } + # Preserve table structure and render directory-provided text as text. + $value = [System.Security.SecurityElement]::Escape($value).Replace('|', '|') -replace '[\r\n]+', ' ' + $value = $value -replace '([\\`*_\[\]()])', '\$1' + "| $($row.Property) | $indicator | $value |" + } + $result += ($rows -join "`n") + "`n`n" + } + $result += 'LDAPS starts with TLS; StartTLS upgrades LDAP to TLS before the bind in Maester. Both encrypt traffic and provide transport integrity, but trusted server identity is needed to exclude active interception. NTLM is legacy authentication; Basic warrants review even over TLS. Advertisements show possible options, not proof of successful authentication or enforcement. Unknown transport support means there is no recorded result, not that the mode is unsupported.' + $result += "`n`n**Configuration evidence not collected:** SASL signing/sealing state and effective DC LDAP signing, encryption, or Kerberos-only policies. TLS provides transport integrity but does not establish those policies. Validating them requires an authorized, cached DC-configuration collector; this check neither reads those settings nor probes every DC." + + Add-MtTestResultDetail -Result $result -Investigate + return $true +} diff --git a/website/docs/advanced/domain-controller-configuration-state.md b/website/docs/advanced/domain-controller-configuration-state.md new file mode 100644 index 0000000000..02a5095ec6 --- /dev/null +++ b/website/docs/advanced/domain-controller-configuration-state.md @@ -0,0 +1,30 @@ +--- +title: Domain Controller Configuration State (Planned) +description: Planned scope and validation requirements for future domain-controller configuration checks. +--- + +# Domain Controller Configuration State + +**Status: Planned; not implemented.** This work adds no dedicated LDAP-configuration collector, configuration-state check, or command. This document does not reserve test IDs or define an executable interface. + +## Scope + +Future native security checks may assess domain-controller configuration related to LDAP security. This work would be separate from `AD-LDAP-01`, which reports connection evidence; configuration values alone cannot establish how a particular connection was negotiated or enforced. + +The planned collection would read, where feasible, effective local settings for LDAP signing and channel binding, relevant Schannel/TLS policy and certificate configuration, and relevant authentication or NTLM restrictions. Collection should use a cached, read-only, narrowly allowlisted service helper under `internal/services/ad`, following the existing AD SMB management pattern in `Get-MtADDomainState` (`SmbConfigurations`) and `Invoke-MtADManagementCommand`. No collector or checks are implemented by this plan. + +By default, evidence should cover the contacted domain controller. Each result should identify the responding controller and collection timestamp so configuration from one controller is not attributed to another connection. An operator may explicitly select an inventory of controllers for a broader assessment. A domain-wide conclusion is appropriate only when configuration coverage is complete for all relevant controllers. Preserve denied, unavailable, and other per-controller states; partial or empty data must not be treated as a pass. + +Interpretation must account for operating-system defaults and policy precedence, including Server 2025 behavior. Distinguish an absent registry value (which may mean a platform default applies) from a failed read. Do not reduce the assessment to a universal encryption or Kerberos-only switch: the relevant settings and their meaning depend on the policy and platform. + +## Boundaries and access + +Configuration evidence supports an assessment of configured posture, not proof that every protocol combination is safe or that runtime enforcement behaved as configured. GPO links or definitions do not establish the effective policy on a domain controller. The scope excludes mass protocol probing and any transmission of insecure credentials. + +Reading these settings may require explicitly delegated management or registry-read access, or an appropriately constrained JEA endpoint. LDAP read access alone is not sufficient. Documentation should describe the required technical permissions without assuming or automatically granting broad administrative roles. Collection must remain read-only; this work does not include mutations or remediation. See the [Active Directory permission model](./active-directory.md). + +## Future implementation and acceptance + +If implemented, reusable collection would live under `powershell/internal/services/ad/`; native checks and their guides would live under `tests/ad/domain-controller/`. No implementation files, tests, or collector are created by this plan. + +Acceptance should include unit validation of platform defaults and precedence, denied and missing values, partial results, cache use, and service gates. A scoped Windows-runner validation should use approved delegated credentials. The results must not claim full-domain certification without complete relevant-controller coverage.