Skip to content

Fix: detect CA availability via RPC (TCP 135) instead of ICMP ping#290

Open
1junh wants to merge 1 commit into
jakehildreth:mainfrom
1junh:fix/detect-ca-availability
Open

Fix: detect CA availability via RPC (TCP 135) instead of ICMP ping#290
1junh wants to merge 1 commit into
jakehildreth:mainfrom
1junh:fix/detect-ca-availability

Conversation

@1junh

@1junh 1junh commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Problem
Set-AdditionalCAProperty gates all live-CA reads (certutil -getreg) behind
an ICMP echo test:

Test-Connection -ComputerName $CAHostFQDN -Count 1 -Quiet

Windows Firewall does not allow inbound ICMPv4 Echo by default (the
"File and Printer Sharing (Echo Request - ICMPv4-In)" rule is disabled out of
the box). On such hosts the CA is fully reachable over RPC/DCOM, yet this ping
fails, so the CA is reported as "CA Unavailable". This yields false positives
and runtime errors: .Translate() throws IdentityNotMappedException on the
"CA Unavailable" placeholder, and $Issue.IdentityReferenceSID.ToString() is
then called on the resulting null SID (InvokeMethodOnNull).

Fix
Test TCP reachability on 135 (RPC Endpoint Mapper), matching the actual
transport. Unreachable-CA cases remain handled by the existing per-certutil
try/catch.

Test-NetConnection -ComputerName $CAHostFQDN -Port 135 -InformationLevel Quiet -WarningAction SilentlyContinue

Compatibility
Test-NetConnection is part of the inbox NetTCPIP module, documented for
Windows Server 2016 and later (with -Port and -InformationLevel Quiet):
https://learn.microsoft.com/powershell/module/nettcpip/test-netconnection?view=windowsserver2016-ps

Testing
In an environment where inbound ICMP echo is blocked (the Windows Firewall
default) but the CA is reachable over RPC, the current code logs runtime errors
during the CA scan and reports the DETECT/ESC6/ESC7/ESC11/ESC16 checks as
"CA Unavailable". With this change the scan completes cleanly with no errors,
and those checks are evaluated against the real CA configuration — identical to
a run where ICMP is allowed, but without changing the firewall.

Scope notes

  • The same ICMP pattern also exists in Tests/Invoke-TSS.ps1 (line 408), but I
    wasn't sure whether it should be fixed too, so I've left it unchanged.

References

Set-AdditionalCAProperty gates live-CA reads with an ICMP echo (Test-Connection -Quiet). When inbound ICMPv4 Echo is blocked (the Windows Firewall default), a reachable CA is wrongly marked 'CA Unavailable', triggering runtime errors and false ESC findings during the CA scan. Probe TCP 135 (the RPC endpoint mapper AD CS actually uses) so reachable CAs are read instead of being falsely skipped.
@SamErde
SamErde requested a review from Copilot July 17, 2026 11:38
@SamErde SamErde added bug Something isn't working enhancement New feature or request labels Jul 17, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request updates CA “availability” detection in Set-AdditionalCAProperty to better reflect how AD CS is actually contacted, avoiding false “CA Unavailable” results when ICMP is blocked but RPC is reachable.

Changes:

  • Replaces ICMP echo reachability checks (Test-Connection) with an RPC Endpoint Mapper TCP check (Test-NetConnection to port 135).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +132 to 133
$ping = if ($CAHostFQDN) { Test-NetConnection -ComputerName $CAHostFQDN -Port 135 -InformationLevel Quiet -WarningAction SilentlyContinue } else { Write-Warning "Unable to resolve $($_.Name) Fully Qualified Domain Name (FQDN)" }
if ($ping) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants