fix(gateway): support non-standard protocol origins in allowedOrigins check#35396
Closed
Sid-Qin wants to merge 1 commit into
Closed
fix(gateway): support non-standard protocol origins in allowedOrigins check#35396Sid-Qin wants to merge 1 commit into
Sid-Qin wants to merge 1 commit into
Conversation
… check URL.origin returns "null" for non-standard protocols like app:// and tauri:// used by desktop apps (Electron, Tauri). This caused checkBrowserOrigin to always reject these origins even when explicitly listed in gateway.controlUi.allowedOrigins. Reconstruct origin from protocol + host when URL.origin is "null" so that allowlist matching works correctly for ClawControl and other desktop-app clients. Closes openclaw#35035
Contributor
Greptile SummaryThis PR fixes a bug where non-standard protocol origins (e.g. Key observations:
Confidence Score: 5/5
Last reviewed commit: 80da54c |
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.
Summary
app://localhostfor Electron/ClawControl,tauri://localhostfor Tauri) are rejected by the gateway origin check even when explicitly listed ingateway.controlUi.allowedOrigins.allowedOrigins: ["*"]workaround.parseOrigin()insrc/gateway/origin-check.tsnow reconstructs the origin string fromprotocol + "//" + hostwhenURL.originreturns"null"(which Node.js/browsers do for non-standard protocols). Added 4 test cases covering non-standard protocol matching.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
app://localhost,tauri://localhost, and other non-standard protocol origins now work correctly ingateway.controlUi.allowedOriginsconfiguration.Security Impact (required)
NoNoNoNoNoRepro + Verification
Environment
Steps
gateway.controlUi.allowedOriginsto["app://localhost"]Expected
Actual
origin not allowed—URL.originreturns"null"forapp://scheme, so the allowlist lookup compares"null"against"app://localhost"and never matches.protocol + "//" + host→"app://localhost", which matches the allowlist entry.Evidence
All 15 tests pass including 4 new ones:
Human Verification (required)
app://localhost,tauri://localhost, wildcard with non-standard origins, rejection when non-standard origin is not in allowlistCompatibility / Migration
YesNoNoFailure Recovery (if this breaks)
parseOrigin()'s origin construction for non-standard protocols.src/gateway/origin-check.tsRisks and Mitigations
protocol + "//" + hostpattern thatURL.hrefuses for these schemes, and the allowlist comparison is a direct string match against user-configured values — users control both sides.