fix(gateway): use loopback for self-connections regardless of bind mode#22056
Open
usedhonda wants to merge 2 commits intoopenclaw:mainfrom
Open
fix(gateway): use loopback for self-connections regardless of bind mode#22056usedhonda wants to merge 2 commits intoopenclaw:mainfrom
usedhonda wants to merge 2 commits intoopenclaw:mainfrom
Conversation
When bind=lan or bind=tailnet, buildGatewayConnectionDetails() was generating localUrl with the LAN/tailnet IP (e.g. ws://192.168.x.x). The security check added in openclaw#20803 then rejected these as plaintext ws:// to non-loopback addresses. Root cause: bind mode controls which interface the *server* listens on, but was incorrectly also driving the *client* connection URL for agents running on the same host. Fix: localUrl now always uses ws://127.0.0.1 (loopback). LAN and tailnet IPs remain available in lanIPv4/tailnetIPv4 for display purposes (QR codes, onboarding hints, urlSource labels) but are no longer used as the actual connection target. Fixes openclaw#22047
Contributor
|
Related: #20289 (comment) |
Contributor
|
The real fix would be to fix the anti-ws code to properly check if the address is that of a local interface, not do simple pattern matching for 3 known things, of which one isn't even nailed down to be local. See my comment on #20803. |
|
This pull request has been automatically marked as stale due to inactivity. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Closes #22047
bind: "lan"causes the browser tool (and any Gateway self-connection) to fail with aSECURITY ERRORafter the plaintext ws:// block introduced in #20803.Two commits are in conflict:
localUrlnow uses the LAN IP whenbind=lanws://to non-loopback addresses is rejectedResult: agents running on the same host as the Gateway hit
SECURITY ERROR: Gateway URL "ws://192.168.x.x" uses plaintext ws:// to a non-loopback address.Fix
localUrlinbuildGatewayConnectionDetails()always usesws(s)://127.0.0.1:<port>regardless of bind mode.bindcontrols which interface the server listens on — it should not affect the connection URL for agents on the same host. LAN/tailnet IPs are still available inlanIPv4/tailnetIPv4for display purposes (QR codes,urlSourcelabels, onboarding hints).Changes
src/gateway/call.ts:localUrlsimplified tows(s)://127.0.0.1:${localPort}src/gateway/call.test.ts: updated test names and assertions to reflect new behaviorTests
All 29 tests passing.
Greptile Summary
Fixes a regression where
bind: "lan"caused browser tools and Gateway self-connections to fail withSECURITY ERRORdue to a conflict between two previous commits. The fix ensures agents on the same host always connect via127.0.0.1regardless of bind mode, sincebindcontrols which interface the server listens on, not the connection URL for local agents. LAN/tailnet IPs remain available for display purposes (QR codes, onboarding hints).buildGatewayConnectionDetails()insrc/gateway/call.tsto always usews(s)://127.0.0.1forlocalUrl, removing the conditional logic that previously used LAN/tailnet IPs based on bind modesrc/gateway/call.test.tsto reflect the new behavior, converting tests that expectedSECURITY ERRORexceptions into tests that verify loopback connections succeedConfidence Score: 5/5
Last reviewed commit: e97ebcf
(2/5) Greptile learns from your feedback when you react with thumbs up/down!