fix(manage-server): scope TLS validation bypass to the health-check loop #5
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
primatekuntech/triton-install!5
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/scope-tls-bypass-health-check"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $true }globally disabled certificate validation for allServicePointManager-based HTTPS calls for the rest of the PowerShell session — not scoped to the specific self-signed loopback health-check connection it's meant for, and never reset afterward. Any laterhttps://Invoke-WebRequestcall in the same session would silently inherit the same blanket bypass.Traced both files' full remaining flow after this point:
install.ps1's background setup-completion watcher runs as a completely separateStart-Processchild (ServicePointManagerstate is per-process, so it never inherits the parent's override regardless), andupgrade.ps1has no further HTTP calls at all after its health-check loop. So neither file currently has a live "later https call silently succeeds against an MITM" exploit path — but the anti-pattern is real: a future maintainer adding anyhttps://call later in either script would silently inherit the bypass with no warning.Fix
A full CA-pinned
SslStreamrewrite (matching the agent installer's approach for its remote connection) wasn't applied here: this check is purely a loopback probe against a container the script itself just started — there's no untrusted network path to defend against (an attacker capable of hosts-file tampering to hijacklocalhostalready needs the same admin privilege both scripts already require), so the added complexity buys little. Instead, resets the callback to$nullimmediately after the health-check loop in bothinstall.ps1andupgrade.ps1, scoping the bypass window to exactly the calls that need it.Verification
$nullis .NET's actual default (full restoration, not a weaker no-op) and the reset is reached on every code path out of the loop, confirmed the loopback/no-untrusted-path reasoning holds given both scripts already require admin elevation — no findingsFixes amiryahaya/triton#339
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $true } globally disabled certificate validation for all ServicePointManager-based HTTPS calls for the rest of the PowerShell session — not scoped to the specific self-signed loopback health-check connection it's meant for, and never reset afterward. Any later https:// Invoke-WebRequest call in the same session would silently inherit the same blanket bypass. Traced both files' full remaining flow after this point: install.ps1's background setup-completion watcher runs as a completely separate Start-Process child (ServicePointManager state is per-process, so it never inherits the parent's override regardless), and upgrade.ps1 has no further HTTP calls at all after its health-check loop. So neither file currently has a live "later https call silently succeeds against an MITM" exploit path — but the anti-pattern is real: a future maintainer adding any https:// call later in either script would silently inherit the bypass with no warning. A full CA-pinned SslStream rewrite (matching the agent installer's approach for its remote connection) wasn't applied here: this check is purely a loopback probe against a container the script itself just started — there's no untrusted network path to defend against, so the added complexity buys little. Instead, reset the callback to $null immediately after the health-check loop in both install.ps1 and upgrade.ps1, so the bypass window is scoped to exactly the calls that need it. Verified via PowerShell Core's own parser (no live Windows box in this environment): no syntax errors in either file. Fixes amiryahaya/triton#339