Skip to content

fix(connection): reject invalid SSH forward ports before connecting - #1729

Merged
shanselman merged 2 commits into
mainfrom
shanselman-reject-invalid-ssh-forward-ports
Oct 15, 2026
Merged

shanselman merged 2 commits into
mainfrom
shanselman-reject-invalid-ssh-forward-ports

Conversation

@shanselman

@shanselman shanselman commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #1684

What Problem This Solves

Fixes: Connection Status enters the connection workflow when SSH forward ports are blank, malformed, or outside 1 through 65535.

User Impact

User impact: invalid remote/local ports show a field-specific error without replacing the active connection or substituting defaults.

Why This Change Was Made

Preserves @SebTardif's implementation and authorship: original fe0c60aa5771a571dd1144abc206bd0e293da88c, cherry-picked with -x as 72ebc36f. Follow-up 4bd28825 adds boundary/invalid tests, isolated real-app proof, and documentation. UI validation stays in the UI and transaction ownership stays with GatewayDirectConnectService. ConnectionPage behavior and downstream SSH enforcement remain unchanged. Port 70000 did not previously launch ssh.exe; it entered the connection workflow before downstream rejection.

Evidence

Base-failing/head-passing source regression; 25 focused tests; six real-app invalid-input cases with fresh visible errors and unchanged registry/original operator connection. Rubber-duck found no production defects; its stale-error test concern was fixed and the UI proof rerun.

Additional autoreview skipped at Scott's explicit direction on October 14, 2026: "you can also just skip it because I said so". The attempted CLI-based review path could not start because its executable was unavailable. Codex CLI is not a required repository prerequisite. No autoreview pass is claimed. Existing rubber-duck review, local validation and visible proof remain valid; CI is still required.

Change Type

  • Bug fix
  • Feature
  • Refactor
  • Docs or instructions
  • Tests or validation
  • Security hardening
  • Chore or infrastructure

Scope

  • Tray or WinUI UX
  • Windows node capability
  • Local MCP or winnode
  • Gateway, connection, or pairing
  • Setup or onboarding
  • Permissions, privacy, or security
  • Tests, CI, or docs

Required proof pools

  • windows-winui-interactive: Connection Status inline validation, passed in the isolated native ARM64 app.

Validation

With OPENCLAW_REPO_ROOT set to the worktree:

  • .\build.ps1: PASS, all five projects and docs.
  • dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore --verbosity quiet: PASS, 4311 passed / 36 skipped / 4347 total.
  • dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore --verbosity quiet: PASS, 4033 passed, zero skips.
  • dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --filter FullyQualifiedName~SshForwardPortsTests --verbosity quiet: PASS, 25 tests including null, whitespace, nonnumeric, negative, zero, 65536, 70000, overflow, and valid 1/65535/default controls.
  • dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-build --no-restore --filter FullyQualifiedName~StatusWindowDirectConnect_RejectsForwardPortsBeforeConnect --verbosity quiet: expected FAIL (one failed) against a scratch source fixture containing the unchanged 72ebc36f^ status-window source selected with OPENCLAW_REPO_ROOT. PASS against head in the focused/full suite. This is source-contract proof, not a base-app launch.
  • dotnet test .\tests\OpenClaw.Tray.UITests\OpenClaw.Tray.UITests.csproj -r win-arm64 -p:Platform=ARM64 -p:DevBuild=false --no-restore --filter FullyQualifiedName~ConnectionStatus_RejectsInvalidForwardPortsWithoutChangingGateway --logger 'console;verbosity=detailed': PASS, one test covering six cases, zero skips.
  • python "$HOME\.agents\skills\autoreview\scripts\autoreview" --mode branch --base origin/main --engine codex --max-priority P3: attempted CLI path did not run a reviewer (executable not found: codex); additional autoreview subsequently SKIPPED at Scott's explicit direction. Branch preparation succeeded (493909 prompt bytes); earlier local preparation exceeded context capacity, resolved by committed branch mode. This is not a passing review verdict or a requirement to install Codex CLI.

Real Behavior Proof

  • Environment tested: native Windows ARM64, worktree Debug app, disposable fixture profile and fixture Gateway; no installed user profiles changed.
  • PR head or commit tested: 4bd28825 source, committed unchanged after proof; app implementation 72ebc36f.
  • Exact steps or command run: UI test above with OPENCLAW_RUN_GATEWAY_FIXTURE_UI=1, OPENCLAW_GATEWAY_FIXTURE_APP set to this worktree's src\OpenClaw.Tray.WinUI\bin\Debug\net10.0-windows10.0.22621.0\win-arm64\OpenClaw.Tray.WinUI.exe, and OPENCLAW_GATEWAY_FIXTURE_SCREENSHOTS=1. Open Diagnostics > event timeline, enable SSH, set valid URL/user/host, and invoke direct Connect for blank, 70000, and abc in each port field.
  • Evidence after fix: fixture run 61585a34fa55482786369d239ae6d677; owned-window screenshots captured and inspected locally; copied live output below.
  • Observed result: fresh visible field-specific errors, byte-identical registry, original operator Connected; source guard verifies rejection before ConnectAsync.
  • Screenshot or artifact links verified? (Yes/No/N/A): No. GitHub accepted the screenshot upload but its returned attachment URL did not resolve (404); no broken image embedded. Copied live output is preserved here.
  • Not verified or blocked: hosted CI pending; additional autoreview skipped at Scott's direction. This is fixture Gateway proof, not production Gateway pairing or successful SSH interoperability.
blank-remote: SSH remote port must be 1–65535; registry unchanged; original operator Connected.
blank-local: SSH local port must be 1–65535; registry unchanged; original operator Connected.
large-remote: SSH remote port must be 1–65535; registry unchanged; original operator Connected.
large-local: SSH local port must be 1–65535; registry unchanged; original operator Connected.
text-remote: SSH remote port must be 1–65535; registry unchanged; original operator Connected.
text-local: SSH local port must be 1–65535; registry unchanged; original operator Connected.

Security Impact

  • New permissions or capabilities? (Yes/No) No
  • Secrets or tokens handling changed? (Yes/No) No
  • New or changed network calls? (Yes/No) No
  • Command or tool execution surface changed? (Yes/No) No
  • Data access scope changed? (Yes/No) No
  • If any answer is Yes, explain the risk and mitigation: N/A

Compatibility and Migration

  • Backward compatible? (Yes/No) Yes for valid inputs; invalid status-window inputs intentionally fail inline.
  • Config or environment changes? (Yes/No) No
  • Migration needed? (Yes/No) No
  • If yes, list the exact upgrade steps: N/A

Review Conversations

  • I replied to or resolved every bot review conversation addressed by this PR.
  • I left unresolved only conversations that still need maintainer judgment.

ClawSweeper acknowledged stop and added clawsweeper:human-review; no duplicate implementation found. Nearby PRs #1556 (fix(connection): copied browser SSH forward uses the local port on both sides), #1658 (fix(ssh): a GatewayPorts yes setting publishes the tunnel on every interface), and #1514 (fix(connection): Open Dashboard can send the token before the SSH forward owns the port) were checked and left outside this scope.

SebTardif and others added 2 commits October 14, 2026 18:56
Connection Status treated a blank forward port as 18789 or 18790 and kept a value such as 70000. Both the status window and the connection page now use one parser. A port that does not parse, or that is outside 1 through 65535, stops the connect before a tunnel is built.

./build.ps1 passed. Shared 4263 passed / 34 skipped / 4297. Tray 4004 passed.

Signed-off-by: Sebastien Tardif <[email protected]>
(cherry picked from commit fe0c60a)
Expand invalid and valid boundary coverage and exercise Connection Status in an isolated real app. Preserve the contributor's original implementation commit.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 36aba55c-8528-40c0-8d40-8c010048f37d
@shanselman shanselman added the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Oct 15, 2026
@shanselman

Copy link
Copy Markdown
Collaborator Author

Final CI update for head 4bd2882: CI Gate passed. Core/CLI, tray/setup/integration, UI/functional/accessibility, setup/connect E2E, network recovery E2E, revocation recovery E2E, x64 publish smoke, both MSIX architectures, and the multi-architecture bundle all passed. No submitted review findings or inline review comments remain. This supersedes the earlier CI-pending notes in the description. Additional autoreview remains skipped at Scott's explicit direction, not reported as passed. Existing local validation, rubber-duck review, and isolated UI proof are retained.

@shanselman
shanselman marked this pull request as ready for review October 15, 2026 02:37
@clawsweeper

clawsweeper Bot commented Oct 15, 2026

Copy link
Copy Markdown

ClawSweeper reviews are opt-in for maintainers. If a review is required, finish the work and validation first, then comment @clawsweeper review. Please avoid repeated requests while a review is queued or running; agents should not request reviews automatically.

@shanselman
shanselman merged commit ad78068 into main Oct 15, 2026
30 checks passed
@shanselman
shanselman deleted the shanselman-reject-invalid-ssh-forward-ports branch October 15, 2026 02:54
@shanselman shanselman removed the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(connection): reject bad SSH forward ports before connect

2 participants