openclaw-windows-node icon indicating copy to clipboard operation
openclaw-windows-node copied to clipboard

[deep-review] C9: Plain ws:// gateway URLs are accepted with no TLS warning

Open codemonkeychris opened this issue 6 months ago • 2 comments

Summary

The setup-code path, onboarding wizard, and direct --url flags all accept ws:// (non-TLS) gateway URLs without surfacing a warning. The corresponding WebView2 chat surface then trusts http:// content from that host, including any inline scripts the gateway returns. A LAN-positioned attacker (typical case: a coffee shop, conference, or any shared WiFi) can intercept the gateway WebSocket and inject arbitrary content into the chat surface.

Where

  • URL parsing: src/OpenClaw.Shared/GatewayUrlHelper.cs
  • Setup-code decoder: src/OpenClaw.Tray.WinUI/Services/LocalGatewaySetup/SetupCodeDecoder.cs
  • WebView2 chat: src/OpenClaw.Tray.WinUI/Windows/ChatWindow.xaml.cs and GatewayChatUrlBuilder.cs

Why it matters

Comparable products:

  • Slack: refuses http:// workspace URLs. Only https://.
  • Discord: same.
  • Most VS Code remote-development extensions: https:// only.
  • VS Live Share: TLS-only by default.

Plain ws:// is a development affordance that's been hauled into the production product. It's not strictly wrong (the device-token Ed25519 signature still authenticates the client), but the chat surface trusts the same plain-HTTP origin and that surface is where users see and respond to agent output.

Proposed fix

Three tiers:

  1. Warn: when a user pastes a ws:// URL into the onboarding wizard, surface a yellow banner explaining the LAN-MITM risk. Allow proceed-anyway.
  2. Block by default for remote: refuse ws:// URLs to anything outside loopback/192.168.*/10.*/172.16-31.*/fc00::/7 unless an OPENCLAW_ALLOW_INSECURE_GATEWAY=1 escape hatch is set.
  3. Loopback / local-WSL exception: continue to allow ws://localhost:* and ws://127.0.0.1:* without warning — this is the legitimate developer path.

Apply the same logic to the WebView2 chat URL — never load HTTP content from a non-loopback host.

Severity

High — LAN MITM with chat-injection.

codemonkeychris avatar May 13 '26 23:05 codemonkeychris

🤖 This is an automated response from Repo Assist.

I've opened a draft PR implementing Tier 1 of this proposal: surfacing a ⚠️ warning in the onboarding Connection page when the user types a plain ws:// URL pointing to a non-local host.

What the PR does:

  • Adds GatewayUrlHelper.IsInsecureRemoteGatewayUrl() with loopback + RFC 1918 + ULA exemptions
  • Shows the warning inline in OnUrlChanged so users see it immediately as they type
  • Warning is non-blocking — users can still connect
  • 17 new test cases covering remote, loopback, private-range, and edge cases

Tier 2 (block-by-default for remote with escape hatch) and any WebView2 chat surface enforcement remain for a follow-up PR.

Generated by 🌈 Repo Assist, see workflow run. Learn more.

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@97143ac59cb3a13ef2a77581f929f06719c7402a

github-actions[bot] avatar May 16 '26 01:05 github-actions[bot]

Closing this one-off deep-review issue as consolidated, not necessarily fixed. The useful signal is preserved in #372: non-TLS gateway warning/policy still needs a fresh focused pass. We will take these one at a time from #372 after verifying against current master instead of keeping the issue list flooded.

shanselman avatar May 18 '26 00:05 shanselman