fix(gateway): support custom URL schemes in origin allowlist matching#98912
fix(gateway): support custom URL schemes in origin allowlist matching#98912wendy-chsy wants to merge 1 commit into
Conversation
The parseOrigin function used the standard URL constructor which assigns
an opaque origin ("null") to custom schemes like tauri:// and electron://.
This prevented those origins from being matched against the configured
allowedOrigins allowlist, forcing Tauri/Electron Control UI clients to use
the wildcard "*" workaround.
Add a parseCustomSchemeOrigin fallback that manually extracts scheme, host,
and hostname from custom scheme origins. The fallback is triggered both
when URL ctor throws and when it returns an opaque "null" origin.
Closes openclaw#46520
|
Codex review: needs real behavior proof before merge. Reviewed July 2, 2026, 12:56 AM ET / 04:56 UTC. Summary PR surface: Source +62, Tests +45. Total +107 across 2 files. Reproducibility: yes. Current source passes the browser Origin through Review metrics: 1 noteworthy metric.
Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Mantis proof suggestion Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Keep the custom-scheme fix local to successful hosted opaque origins, preserve rejection for standard URL parse failures, add invalid-origin coverage, and require redacted Gateway allow/reject proof before merge. Do we have a high-confidence way to reproduce the issue? Yes. Current source passes the browser Origin through Is this the best way to solve the issue? No as currently patched. The parser layer is the right place, but the best fix should reconstruct hosted opaque origins without parsing standard-scheme strings that Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against b2c507c5f04c. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +62, Tests +45. Total +107 across 2 files. View PR surface stats
Security concerns:
Acceptance criteria:
What I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
|
What Problem This Solves
tauri://andelectron://cannot be matched ingateway.controlUi.allowedOriginsbecause the standardURLconstructor assigns an opaque origin ("null") to non-standard schemes"*"workaround, which is a security regressionWhy This Change Was Made
The
parseOriginfunction insrc/gateway/origin-check.tsusesnew URL()which works for standard schemes (http, https) but returnsnullas the origin for custom schemes. This means even when a user explicitly allowstauri://localhostinallowedOrigins, the allowlist check fails because the parsed origin is"null"instead of"tauri://localhost".User Impact
"*"Evidence
Behavior or issue addressed
allowedOriginsReal environment tested
Exact steps or command run after this patch
pnpm test src/gateway/origin-check.test.tsEvidence after fix
All 84 tests pass (78 existing + 6 new) covering:
tauri://localhost)electron://localhost:5173)Observed result after fix
Tests and validation
Risk checklist
Additional notes
AI-assisted fix. The change adds a
parseCustomSchemeOriginfallback for custom URL schemes while preserving the existing standard URL parsing path unchanged.