Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
ae75e27
Add CIS parked-domain audit handling
JeremyFinney-lgtm Nov 3, 2026
ff17c23
Merge remote-tracking branch 'upstream/main' into fix/cis-parked-doma…
JeremyFinney-lgtm Nov 3, 2026
43c141c
Fix review findings and DMARC tests
JeremyFinney-lgtm Nov 3, 2026
eeb9ff2
Align SPF and parked DKIM audit criteria
JeremyFinney-lgtm Nov 4, 2026
27aee8c
Investigate incomplete parked DKIM lookups
JeremyFinney-lgtm Nov 4, 2026
c16b54a
Fail parked domains with known DKIM selectors
JeremyFinney-lgtm Nov 4, 2026
68f3d33
Investigate incomplete receiving DNS evidence
JeremyFinney-lgtm Nov 4, 2026
6b56b5a
Fix CIS DNS evidence and share lookup caching
JeremyFinney-lgtm Nov 5, 2026
6ac6cf2
Preserve mixed CIS SPF and DMARC investigation results
JeremyFinney-lgtm Nov 5, 2026
b070ea6
Avoid compliance banners for CIS investigation results
JeremyFinney-lgtm Nov 5, 2026
d33e0a5
Fix DKIM investigation banners and verify negative DNS caching
JeremyFinney-lgtm Nov 6, 2026
aa0c3e7
Merge upstream/main into fix/cis-parked-domain-detection
JeremyFinney-lgtm Nov 8, 2026
26a6220
Isolate TXT resolver tests from the shared DNS cache
JeremyFinney-lgtm Nov 8, 2026
4a3c028
Use only ParkedDomains to mark parked domains in CIS 2.1.8-2.1.10
merill Nov 9, 2026
c3bc710
fix(cis): reject earlier SPF all mechanism
JeremyFinney-lgtm Nov 11, 2026
62d2576
docs(cis): explain SPF all evaluation order
JeremyFinney-lgtm Nov 11, 2026
8ac3c92
fix(cis): fail parked redirects without target lookup
JeremyFinney-lgtm Nov 11, 2026
9725d1d
fix(cis): investigate unavailable parked DKIM checks
JeremyFinney-lgtm Nov 11, 2026
1a14e39
Support shared parked domains setting
JeremyFinney-lgtm Nov 11, 2026
8a658d6
Reject repeated SPF exp modifiers
JeremyFinney-lgtm Nov 11, 2026
a6ff0db
fix(cis): validate parked SPF explanation domain syntax
JeremyFinney-lgtm Nov 11, 2026
cdc79f6
chore: credit reviewers for parked-domain findings
JeremyFinney-lgtm Nov 12, 2026
ddf6d63
fix(cis): sync parked-domain checks with shared settings
JeremyFinney-lgtm Nov 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions powershell/Maester.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ $__MtSession = @{
Connections = @()
ConnectionConfig = $null # Reference to config discovered by a connector, not an explicit run config.
DnsCache = @()
DnsRecordCache = @{}
ExoCache = @{}
OrcaCache = @{}
AIAgentInfo = $null # Get-MtAIAgentInfo cache: @{ Agents; Error }, Error is why no agent data is available
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
function Test-MtCisParkedDomain {
<#
.SYNOPSIS
Returns true when a domain is in the list of parked domains an admin gave a CIS email-authentication check.

.DESCRIPTION
CIS Microsoft 365 Foundations Benchmark v7.0.0 (2.1.8 to 2.1.10) sets different requirements for domains that
are not used to send email, but leaves it to the auditor to say which domains those are. Maester does not
guess from DNS: a domain is parked only when it is listed in the check's ParkedDomains parameter. The
comparison ignores case and a trailing dot.

.PARAMETER DomainName
The accepted domain to look up.

.PARAMETER ParkedDomains
The domains the admin listed as parked.
#>
[CmdletBinding()]
[OutputType([bool])]
param(
[Parameter(Mandatory)]
[string]$DomainName,

[string[]]$ParkedDomains = @()
)

$name = $DomainName.TrimEnd('.')
return @($ParkedDomains | Where-Object {
$_ -and [string]::Equals($_.Trim().TrimEnd('.'), $name, [System.StringComparison]::OrdinalIgnoreCase)
}).Count -gt 0
}
153 changes: 153 additions & 0 deletions powershell/internal/services/exchange/Resolve-MtDnsRecord.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
function Resolve-MtDnsRecord {
<#
.SYNOPSIS
Resolves DNS records with consistent results across supported platforms.

.DESCRIPTION
Uses Resolve-DnsName on Windows and Resolve-Dns from DnsClient-PS on other platforms.
A successful query with no answers has Status Success and an empty Answers array.
All lookup outcomes are cached until Clear-MtDnsCache resets the session snapshot.
Queries use absolute DNS names so suffix search policies cannot change the cached identity.
Cached results are shared read-only objects and retain the first caller's Name spelling.

.PARAMETER Name
The DNS name to query.

.PARAMETER Type
The DNS record type to query.
#>
[CmdletBinding()]
[OutputType([pscustomobject])]
param(
[Parameter(Mandatory)]
[string]$Name,

[Parameter(Mandatory)]
[ValidateSet('A', 'AAAA', 'CNAME', 'MX', 'TXT')]
[string]$Type
)

if ($null -eq $__MtSession.DnsRecordCache) {
$__MtSession.DnsRecordCache = @{}
}

$queryName = "$($Name.TrimEnd('.'))."
$cacheKey = "$($Type.ToUpperInvariant())|$($queryName.ToLowerInvariant())"
if ($__MtSession.DnsRecordCache.ContainsKey($cacheKey)) {
Write-Verbose "DNS record exists in cache for $Type $Name - Use Clear-MtDnsCache to reset"
return $__MtSession.DnsRecordCache[$cacheKey]
}

$result = [pscustomobject]@{
Name = $Name
Type = $Type
Status = 'Success'
Answers = [object[]]@()
Error = $null
}
$answers = @()

if ($IsWindows) {
try {
$response = Resolve-DnsName -Name $queryName -Type $Type -ErrorAction Stop
$answers = @($response | Where-Object { $_.Section -eq 'Answer' -and $_.Type -eq $Type })
} catch [System.Management.Automation.CommandNotFoundException] {
$result.Status = 'NotAvailable'
$result.Error = 'Unsupported platform, Resolve-DnsName not available'
$__MtSession.DnsRecordCache[$cacheKey] = $result
return $result
} catch {
if ($_.FullyQualifiedErrorId -like 'DNS_ERROR_RCODE_NAME_ERROR*') {
$result.Status = 'NXDomain'
} elseif ($_.FullyQualifiedErrorId -notlike 'DNS_INFO_NO_RECORDS*') {
$result.Status = 'Error'
$result.Error = "$_"
}
$__MtSession.DnsRecordCache[$cacheKey] = $result
return $result
}
} else {
if (-not (Get-Command -Name 'Resolve-Dns' -ErrorAction SilentlyContinue)) {
$result.Status = 'NotAvailable'
$result.Error = 'Missing dependency, Resolve-Dns not available'
$__MtSession.DnsRecordCache[$cacheKey] = $result
return $result
}

try {
$response = Resolve-Dns -Query $queryName -QueryType $Type -ErrorAction Stop
if ($response.HasError) {
if ("$($response.Header.ResponseCode)" -eq 'NotExistentDomain') {
$result.Status = 'NXDomain'
} else {
$result.Status = 'Error'
$result.Error = $response.ErrorMessage
}
$__MtSession.DnsRecordCache[$cacheKey] = $result
return $result
}
$answers = @($response.Answers | Where-Object { "$($_.RecordType)" -eq $Type })
} catch {
$result.Status = 'Error'
$result.Error = "$_"
$__MtSession.DnsRecordCache[$cacheKey] = $result
return $result
}
}

foreach ($answer in $answers) {
$value = $null
$preference = $null
switch ($Type) {
'TXT' {
if ($answer.PSObject.Properties['Strings']) {
$value = @($answer.Strings) -join ''
} elseif ($answer.PSObject.Properties['Text']) {
$value = @($answer.Text) -join ''
}
}
'MX' {
if ($answer.PSObject.Properties['NameExchange']) {
$value = $answer.NameExchange
} elseif ($answer.PSObject.Properties['Exchange']) {
$value = $answer.Exchange
}
if ($answer.PSObject.Properties['Preference']) {
$preference = $answer.Preference
}
}
'CNAME' {
foreach ($propertyName in 'NameHost', 'CanonicalName', 'CName', 'HostName') {
if ($answer.PSObject.Properties[$propertyName]) {
$value = $answer.PSObject.Properties[$propertyName].Value
break
}
}
}
{ $_ -in 'A', 'AAAA' } {
foreach ($propertyName in 'IPAddress', 'IPv4Address', 'IPv6Address', 'Address') {
if ($answer.PSObject.Properties[$propertyName]) {
$value = $answer.PSObject.Properties[$propertyName].Value
break
}
}
}
}

if ($null -eq $value -or ($Type -ne 'TXT' -and [string]::IsNullOrWhiteSpace([string]$value))) {
$result.Status = 'Error'
$result.Error = "The DNS resolver returned an unusable $Type answer for $Name."
$result.Answers = [object[]]@()
$__MtSession.DnsRecordCache[$cacheKey] = $result
return $result
}

$result.Answers += [pscustomobject]@{
Value = [string]$value
Preference = $preference
}
}

$__MtSession.DnsRecordCache[$cacheKey] = $result
return $result
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,55 +29,11 @@
[string]$Name
)

$result = [pscustomobject]@{
Name = $Name
Status = 'Success'
Answers = [string[]]@()
Error = $null
$dnsResult = Resolve-MtDnsRecord -Name $Name -Type TXT
return [pscustomobject]@{
Name = $dnsResult.Name
Status = $dnsResult.Status
Answers = [string[]]@($dnsResult.Answers | ForEach-Object { $_.Value })
Error = $dnsResult.Error
}

if ($IsWindows) {
try {
$response = Resolve-DnsName -Name $Name -Type TXT -ErrorAction Stop
$result.Answers = [string[]]@($response | Where-Object { $_.Section -eq 'Answer' -and $_.Type -eq 'TXT' } | ForEach-Object { $_.Strings -join '' })
} catch [System.Management.Automation.CommandNotFoundException] {
$result.Status = 'NotAvailable'
$result.Error = 'Unsupported platform, Resolve-DnsName not available'
} catch {
Write-Verbose "TXT lookup for $($Name) failed: $_"
if ($_.FullyQualifiedErrorId -like 'DNS_ERROR_RCODE_NAME_ERROR*') {
$result.Status = 'NXDomain'
} elseif ($_.FullyQualifiedErrorId -notlike 'DNS_INFO_NO_RECORDS*') {
$result.Status = 'Error'
$result.Error = "$_"
}
}
return $result
}

if (-not (Get-Command -Name 'Resolve-Dns' -ErrorAction SilentlyContinue)) {
Write-Verbose 'For non-Windows platforms, please install the DnsClient-PS module: Install-Module DnsClient-PS -Scope CurrentUser'
$result.Status = 'NotAvailable'
$result.Error = 'Missing dependency, Resolve-Dns not available'
return $result
}

try {
$response = Resolve-Dns -Query $Name -QueryType TXT -ErrorAction Stop
if ($response.HasError) {
if ("$($response.Header.ResponseCode)" -eq 'NotExistentDomain') {
$result.Status = 'NXDomain'
} else {
$result.Status = 'Error'
$result.Error = $response.ErrorMessage
}
} else {
$result.Answers = [string[]]@($response.Answers | Where-Object { "$($_.RecordType)" -eq 'TXT' } | ForEach-Object { $_.Text -join '' })
}
} catch {
Write-Verbose "TXT lookup for $($Name) failed: $_"
$result.Status = 'Error'
$result.Error = "$_"
}
return $result
}
1 change: 1 addition & 0 deletions powershell/public/connect/Clear-MtDnsCache.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@
Write-Verbose -Message "Clearing the results cached from DNS lookups in this session"

$__MtSession.DnsCache = @()
$__MtSession.DnsRecordCache = @{}
}
Loading
Loading