Skip to content

Commit 59f373a

Browse files
ranjeshjCopilot
andcommitted
Guard gateway cleanup against reparse points
Refuse recursive gateway directory deletion when the target is a junction or symlink, matching the SetupEngine safety guard and preventing cleanup from crossing outside the app-owned WSL directory. Co-authored-by: Copilot <[email protected]>
1 parent 9a85e96 commit 59f373a

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

‎scripts/Uninstall-LocalGateway.ps1‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,11 @@ function Remove-GatewayDirectory {
545545
return
546546
}
547547

548+
$gatewayItem = Get-Item -LiteralPath $gatewayDirectory -Force -ErrorAction Stop
549+
if (($gatewayItem.Attributes -band [System.IO.FileAttributes]::ReparsePoint) -ne 0) {
550+
throw "Refusing to recursively delete reparse point '$gatewayDirectory'."
551+
}
552+
548553
$lastError = $null
549554
for ($attempt = 1; $attempt -le 6; $attempt++) {
550555
try {

‎tests/OpenClaw.Tray.Tests/InstallerIssAssertionTests.cs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ public void UninstallLocalGatewayScript_DirectlyUnregistersWslDistro()
117117
Assert.Contains("wsl-keepalive", script);
118118
Assert.Contains("Test-DistroListed", script);
119119
Assert.Contains("Test-DistroNotFound", script);
120+
Assert.Contains("FileAttributes]::ReparsePoint", script);
121+
Assert.Contains("Refusing to recursively delete reparse point", script);
120122
Assert.Contains("for ($attempt = 1; $attempt -le 6; $attempt++)", script);
121123
Assert.Contains("exit $unregisterResult.ExitCode", script);
122124
Assert.DoesNotContain("OpenClaw.Tray.WinUI.exe", script);

0 commit comments

Comments
 (0)