Skip to content

gateway.controlUi.allowedOrigins: support scheme-level wildcards (e.g. chrome-extension://*) #39739

Description

@changx

Problem

gateway.controlUi.allowedOrigins only supports exact origin matching or a global "*" wildcard. Chrome extensions get a unique chrome-extension://<id> origin that changes when:

  • Reinstalling the extension
  • Switching Chrome profiles
  • Loading unpacked from a different path

This forces users to update allowedOrigins every time the extension ID changes.

Proposed Solution

Support scheme-level wildcard patterns like chrome-extension://* in allowedOrigins.

The change in checkBrowserOrigin (src/gateway/origin-check.ts) would be minimal — after the exact match check, add a prefix/pattern match for entries ending with *:

// Current: exact match only
if (allowlist.has("*") || allowlist.has(parsedOrigin.origin)) return { ok: true, matchedBy: "allowlist" };

// Proposed: add wildcard prefix matching
for (const pattern of allowlist) {
  if (pattern.endsWith("*") && parsedOrigin.origin.startsWith(pattern.slice(0, -1))) {
    return { ok: true, matchedBy: "allowlist" };
  }
}

Use Case

Chrome extensions that connect to the OpenClaw gateway via WebSocket (e.g. side panel chat UIs, browser relay extensions). These extensions need stable access regardless of installation context.

Security Consideration

This is opt-in — users explicitly configure the pattern. chrome-extension://* is far more scoped than "*" (which is already supported), as it only allows Chrome extension origins, not arbitrary web pages.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:needs-security-reviewClawSweeper marked this issue as needing security-sensitive review.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:securitySecurity boundary, credential, authz, sandbox, or sensitive-data risk.impact:ux-frictionUser-facing flow adds avoidable confusion or support burden without fully blocking progress.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.maturity:stableIssue affects a taxonomy feature currently scored M4/M5.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions