Skip to content

test: prevent testhost firewall consent prompts - #1125

Merged
shanselman merged 1 commit into
mainfrom
shanselman-fix-testhost-firewall
Aug 8, 2026
Merged

shanselman merged 1 commit into
mainfrom
shanselman-fix-testhost-firewall

Conversation

@shanselman

Copy link
Copy Markdown
Collaborator

Summary

  • keep every repository test-owned TCP listener on IPv4/IPv6 loopback instead of wildcard interfaces
  • preserve mirrored-WSL port collision checks and SSH forward pair reservation across both loopback families
  • test production LAN-bind conflict handling by occupying loopback, so the production wildcard bind fails without exposing testhost.exe
  • document the loopback-only rule for test listeners

Root cause

Windows Defender Firewall event 2099 recorded per-worktree inbound rules for:

  • tests\OpenClaw.E2ETests\bin\Debug\net10.0-windows\testhost.exe
  • tests\OpenClaw.E2ETests\bin\Debug\net10.0-windows\win-x64\testhost.exe
  • tests\OpenClaw.SetupEngine.Tests\bin\Debug\net10.0\testhost.exe

The triggering paths were MirroredWslPortLease.CanBindExclusively, the SSH forward port-pair allocator, and PreflightPort_Lan_FailsWhenAnyBindPortInUse. Those tests successfully listened on IPAddress.Any or IPAddress.IPv6Any, which made the per-worktree .NET testhost.exe network reachable and caused Windows to request an interactive firewall decision.

Validation

  • ./build.ps1: passed
  • dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore: 3,623 passed, 32 skipped
  • dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore: 2,241 passed
  • dotnet test ./tests/OpenClaw.E2ETests/OpenClaw.E2ETests.csproj -c Debug -r win-x64 --no-restore --filter "FullyQualifiedName~MirroredWslPortLeaseTests": 11 passed
  • dotnet test ./tests/OpenClaw.SetupEngine.Tests/OpenClaw.SetupEngine.Tests.csproj -c Debug -r win-x64 --no-restore --filter "FullyQualifiedName~PreflightPort_Lan_FailsWhenLoopbackPortInUse": 1 passed
  • git diff --check: passed

Real behavior proof

Before the fix, Windows Firewall event 2099 created or modified inbound testhost rules for E2E and SetupEngine worktree paths. After the fix, the focused tests and the full required closeout ran while monitoring Microsoft-Windows-Windows Firewall With Advanced Security/Firewall; both completed with FIREWALL_EVENT_DELTA=0 for this worktree. No firewall dialog interaction, elevated mutation, firewall rule change, or global firewall weakening was used.

Autoreview initially found loss of IPv6 loopback collision coverage in the SSH allocator. The allocator was corrected to reserve both 127.0.0.1 and ::1, with a focused IPv6 collision regression. The final autoreview reported no actionable findings. Rubber-duck review found the missing behavioral regression and was addressed.

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal priority bug or improvement with limited blast radius. labels Aug 8, 2026
@clawsweeper

clawsweeper Bot commented Aug 8, 2026

Copy link
Copy Markdown

Codex review: needs maintainer review before merge. Reviewed August 7, 2026, 9:43 PM ET / August 8, 2026, 01:43 UTC.

ClawSweeper review

What this changes

The PR changes test-owned TCP listeners to use IPv4 and IPv6 loopback only, preventing Windows Firewall consent prompts during validation.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep this collaborator PR open for normal merge review. Current main still uses wildcard test probes, while this focused branch removes them and retains explicit IPv4/IPv6 loopback collision coverage.

Priority: P2
Reviewed head: 99fd114872ba87edcfb65de666531564d8e976e5

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, test-only reliability patch with concrete after-fix firewall-event evidence and targeted dual-family regression coverage.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (logs): The PR body provides current-head after-fix Firewall event monitoring and focused test results showing no new testhost firewall events.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (logs): The PR body provides current-head after-fix Firewall event monitoring and focused test results showing no new testhost firewall events.
Evidence reviewed 5 items Current-main behavior: Current main probes wildcard IPv4 and IPv6 addresses when reserving a mirrored-WSL test port; the PR replaces that with loopback-only probes.
Focused regression coverage: The branch checks that all probe addresses are loopback, that ports are released, and that an IPv6 loopback collision is rejected.
Production LAN-bind behavior remains exercised: The setup preflight checks wildcard IPv4 and IPv6 for LAN mode; the updated test occupies loopback so that production wildcard bind fails without making testhost network-reachable.
Findings None None.
Security None None.

How this fits together

E2E setup reserves temporary ports before starting a WSL gateway, and SSH adversarial tests reserve local forwarding ports. These test-only listeners exercise port-conflict behavior before the real gateway or tunnel starts.

flowchart LR
A[Host port state] --> B[Test port reservation]
B --> C[IPv4 and IPv6 loopback probes]
C --> D[WSL gateway setup]
C --> E[SSH forwarding setup]
D --> F[E2E connection checks]
E --> F
Loading

Before merge

  • Complete next step (P2) - No discrete repair is identified; this collaborator PR is ready for ordinary CI completion and maintainer review.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production versus test delta production +0, tests +100/-30, docs +6 The implementation is confined to test infrastructure and its developer validation guidance.

Technical review

Best possible solution:

Land the loopback-only test-listener rule with its dual-family regression tests and retain the existing production LAN-bind preflight coverage.

Do we have a high-confidence way to reproduce the issue?

Yes. On a Windows host, the prior wildcard test listener can be exercised while monitoring Firewall event 2099; the branch supplies a focused after-fix path and reports zero new events.

Is this the best way to solve the issue?

Yes. Loopback-only temporary listeners eliminate the triggering network exposure while the production LAN-bind test still verifies wildcard-bind conflict handling.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 603886a81d34.

Labels

Label changes:

  • add P2: This is a bounded test-infrastructure reliability fix that avoids disruptive Windows Firewall prompts during validation.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides current-head after-fix Firewall event monitoring and focused test results showing no new testhost firewall events.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (logs): The PR body provides current-head after-fix Firewall event monitoring and focused test results showing no new testhost firewall events.

Label justifications:

  • P2: This is a bounded test-infrastructure reliability fix that avoids disruptive Windows Firewall prompts during validation.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (logs): The PR body provides current-head after-fix Firewall event monitoring and focused test results showing no new testhost firewall events.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides current-head after-fix Firewall event monitoring and focused test results showing no new testhost firewall events.

Evidence

What I checked:

Likely related people:

  • shanselman: Current-main history shows Scott Hanselman recently changed the mirrored-WSL port-lease area, and this collaborator PR continues that focused work. (role: recent area contributor; confidence: high; commits: 01faa6419b42, 99fd114872ba; files: tests/OpenClaw.E2ETests/Setup/MirroredWslPortLease.cs, tests/OpenClaw.E2ETests/Setup/MirroredWslPortLeaseTests.cs)
  • Barbara Kudiess: The current main tip recently updated the affected setup-test path alongside gateway recovery work. (role: recent setup-test contributor; confidence: medium; commits: 603886a81d34; files: tests/OpenClaw.SetupEngine.Tests/SetupStepsTests.cs)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@shanselman
shanselman merged commit 650247d into main Aug 8, 2026
34 of 35 checks passed
@shanselman
shanselman deleted the shanselman-fix-testhost-firewall branch August 8, 2026 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant