Skip to content

fix(browser): gate agent-triggered system profile import on the owner - #137759

Closed
yetval wants to merge 1 commit into
openclaw:mainfrom
yetval:fix/browser-importprofile-owner-gate
Closed

yetval wants to merge 1 commit into
openclaw:mainfrom
yetval:fix/browser-importprofile-owner-gate

Conversation

@yetval

@yetval yetval commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This is defense-in-depth hardening, not a security fix, and it is not required for any advisory. Prompt-injection-only chains are out of scope under SECURITY.md and authenticated Gateway callers are trusted operators, so nothing here claims a boundary bypass.

The browser tool exposes action=importprofile to every run that receives the tool. The action copies decrypted cookies from a real Chrome-family system profile into a managed OpenClaw profile. System profile import is enabled by default and the tool never consulted the trusted owner bit, so a non-owner inbound run could reach the import path.

The macOS Keychain consent prompt is the existing control and it is deliberate (system-chrome-cookies.ts says so, and docs/cli/browser.md documents the prompt). The reason this is still worth closing is that the prompt is a one-time gate rather than a per-call one. Once a user approves /usr/bin/security for the Chrome Safe Storage item, which anyone who has run openclaw browser import-profile or cookie-sync may already have done, later reads are silent. From that point an agent-generated call has no remaining gate at all.

Root cause

extensions/browser/plugin-registration.ts builds the browser tool from OpenClawPluginToolContext, which already carries senderIsOwner ("Trusted owner bit from inbound context, runtime-provided, not tool args"). The browser extension never read it. senderIsOwner appears in 381 files elsewhere in the repo and zero times under extensions/browser.

extensions/browser/src/browser-tool.ts pins the action to the host but never authorizes it:

// before
if (action === "importprofile") {
  if (target === "sandbox" || target === "node" || requestedNode) {
    throw new Error(
      'system profile import must run on the host; omit target or use target="host".',
    );
  }
  target = "host";
}

resolveBrowserToolCapabilities filters actions by profile capability and by evaluateEnabled, but never by sender identity, so importprofile was advertised to every run.

Fix

Read the bit that already exists, and apply it at the two points that already do this kind of filtering.

// after, browser-tool.ts, before routing is resolved
const action = readStringParam(params, "action", { required: true });
if (action === "importprofile" && opts?.senderIsOwner === false) {
  throw new Error(
    "system profile import requires the owner; run it from an owner conversation or use the openclaw browser import-profile CLI.",
  );
}
// after, browser-tool.schema.ts, alongside the existing capability filters
(params?.senderIsOwner !== false || action !== "importprofile") &&

The guard is keyed on senderIsOwner === false, matching the convention in src/agents/agent-tools.ts (GATEWAY_OWNER_ONLY_CORE_TOOLS is applied only when options?.senderIsOwner === false). Absent sender context stays allowed, so local operator runs and the CLI are unchanged.

Why this is the right boundary

plugin-registration.ts is the single agent entry point into createBrowserTool; there is no sibling agent surface for this action. The CLI (registerBrowserCli) and the Gateway method reach importSystemProfileCookies through separate trusted-operator surfaces and are intentionally untouched, so the documented openclaw browser import-profile and macOS app workflows keep working. The guard sits before routing resolution because it is a policy decision on the action name alone and needs no config.

Both layers are kept on purpose: the capability filter removes the action from the advertised schema so a non-owner run is never offered it, and the runtime guard is the actual enforcement. The guard is ordered before the capability check so the denial reports the owner requirement instead of the generic "unavailable for this run" message.

Functional tradeoff, called out explicitly: an agent run that the runtime marks as a known non-owner sender can no longer trigger cookie import. That is the intent of the change. Runs with no inbound sender context are unaffected.

Verification

  • node scripts/run-vitest.mjs extensions/browser/src/browser-tool.test.ts -t "importprofile owner gate": 4 passed.
  • The same 4 against pristine main: 2 failed (the non-owner refusal and the advertised-action filter), 2 passed (the owner and no-sender cases, which must not regress).
  • node scripts/run-oxlint.mjs on the 4 changed files: exit 0.
  • oxfmt --check on the 4 changed files: clean.
  • node scripts/run-tsgo.mjs -p tsconfig.core.json: clean.
  • oxfmt --check with the version this repo pins (0.65.0) on the 4 changed files: clean.
  • Not run: run-tsgo -p test/tsconfig/tsconfig.core.test.json, and full build.

Real behavior proof

Behavior addressed: a browser tool run whose inbound sender is known not to be the owner could invoke action=importprofile and reach the system-profile cookie import path.

Real environment tested: the real createBrowserTool factory and the real resolveBrowserToolCapabilities / createBrowserToolSchema from extensions/browser, driven directly on pristine main 6b97bae2e15 and on the patched tree with identical inputs. The browser control service, the extension relay, the capability resolver, the tool schema builder and the import routing all stayed real. Nothing was stubbed; the only environmental substitution was pointing OPENCLAW_CONFIG_PATH at an empty config file so the run did not read the local operator config.

Exact steps or command run after this patch: constructed the browser tool via createBrowserTool({ senderIsOwner: false }) and createBrowserTool({ senderIsOwner: true }), invoked execute("call-1", { action: "importprofile", target: "host", into: "stolen", systemProfile: "Default" }) on each, and separately printed the action enum that createBrowserToolSchema emits for a non-owner run.

Evidence after fix:

# BEFORE (pristine main 6b97bae2e15)
non-owner inbound run: Error: managed profile "stolen" is not owned by this OpenClaw browser runtime; stop it and import into a fresh profile name
owner run           : Error: managed profile "stolen" is not owned by this OpenClaw browser runtime; stop it and import into a fresh profile name
non-owner advertised = true
owner advertised     = true
local advertised     = true

# AFTER (this patch at 5e18acadff4, identical inputs)
non-owner inbound run: system profile import requires the owner; run it from an owner conversation or use the openclaw browser import-profile CLI.
owner run           : Error: managed profile "stolen" is not owned by this OpenClaw browser runtime; stop it and import into a fresh profile name
non-owner advertised = false
owner advertised     = true
local advertised     = true

Observed result after fix: on pristine main the non-owner call and the owner call behaved identically, both penetrating into the import routine itself and failing only on the late managed-profile ownership check inside system-profiles.ts. With the patch the non-owner call is refused up front and never reaches that routine, while the owner call still reaches it and fails at exactly the same later point as before, and importprofile disappears from the advertised action list for the non-owner run only. The owner and no-sender paths are unchanged.

What was not tested: no real Keychain approval and no real cookie decryption were exercised, so the import was not carried through to a populated profile on either tree; the owner run was cut short by a deliberate 4 second abort once it had passed the gate. The macOS app import flow and the cookie-sync path were not driven. The full build and the core test typecheck lane were not run.

@clawsweeper

clawsweeper Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 4, 2026
@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 3, 2026, 10:08 PM ET / September 4, 2026, 02:08 UTC.

ClawSweeper review

What this changes

The PR passes inbound owner status to the browser tool, hides system-profile cookie import for known non-owners, and rejects those calls before routing.

Merge readiness

⛔ Blocked before merge - 3 items remain

Keep open pending a Browser-owner policy decision. The patch correctly carries the trusted per-run owner fact into the browser plugin and blocks a known non-owner before browser routing; it deliberately removes an existing action from authorized non-owner runs, so the owner-only policy needs confirmation before merge.

Priority: P2
Reviewed head: 5e18acadff411a879c355d3ee1bbe27093f9beea
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, well-evidenced owner-boundary patch whose only remaining blocker is the intended access policy.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR supplies a terminal before/after trace through the real browser-tool factory and schema: the known non-owner is rejected before import routing after the fix, while the owner path continues past the gate. Completing cookie decryption is unnecessary to prove this pre-routing authorization boundary.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR supplies a terminal before/after trace through the real browser-tool factory and schema: the known non-owner is rejected before import routing after the fix, while the owner path continues past the gate. Completing cookie decryption is unnecessary to prove this pre-routing authorization boundary.
Evidence reviewed 6 items Current-main gap: The pinned current-main base advertises importprofile without an owner capability input, so the central behavior is not already implemented on main.
Trusted owner source: The plugin tool contract defines senderIsOwner as runtime-provided, not tool-controlled, and core agent construction forwards it into plugin-tool options.
Enforcement path: The introduced runtime guard rejects a known non-owner before target resolution, while the capability filter removes importprofile from the model-facing schema.
Findings None None.
Security None None.

How this fits together

The Browser plugin exposes agent actions against managed browser profiles. System-profile import reads host browser cookies into a managed profile, while the plugin tool context carries the inbound sender’s trusted owner status.

flowchart LR
  A[Inbound sender] --> B[Agent tool context]
  B --> C[Browser plugin]
  C --> D[Owner-status action filter]
  D --> E[Import profile request]
  E --> F[Managed browser profile]
Loading

Decision needed

Question Recommendation
Should a known authorized non-owner sender be barred from agent-triggered system-profile cookie import, with only an owner or local senderless operator path allowed? Confirm owner-only import: Keep the runtime denial and schema filtering so known non-owner runs cannot start host cookie import.

Why: This is a deliberate access-policy change for a cookie-import action, not a mechanical correctness question that source inspection can resolve.

Before merge

  • Resolve merge risk (P1) - Known non-owner senders currently receive importprofile; merging intentionally removes that action, so its compatibility and security-policy effect requires Browser-owner confirmation.
  • Complete next step (P2) - Confirm that system-profile cookie import is intentionally owner-only for known inbound non-owner senders before merge.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
Agent review details

Security

None.

PR surface

Source +13, Tests +36. Total +49 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 3 13 0 +13
Tests 1 36 0 +36
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 49 0 +49

Review metrics

Metric Value Why it matters
Production versus test LOC production +13, tests +36 The small production increase is limited to trusted owner propagation plus schema and runtime enforcement; tests cover denial, owner, and senderless cases.

Merge-risk options

Maintainer options:

  1. Confirm owner-only import (recommended)
    Confirm the intended policy and retain the guard as the explicit restriction on known non-owner runs.
  2. Pause for a different policy
    Keep the PR unmerged if general authorized senders should retain access or consent must be modeled differently.

Technical review

Best possible solution:

Retain the small dual schema/runtime guard if the Browser owner confirms that system-profile cookie import is owner-only; otherwise preserve the existing authorized-sender behavior and close or redesign the proposal.

Do we have a high-confidence way to reproduce the issue?

Yes. The supplied before/after trace gives identical current-main and patched factory inputs for a known non-owner, and source confirms the base has no owner check while the patch rejects before routing.

Is this the best way to solve the issue?

Unclear pending policy confirmation. The implementation is the narrowest owner-boundary enforcement using an existing trusted context, but maintainers must choose whether owner-only is the intended authorization rule.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 6b97bae2e157.

Labels

Label justifications:

  • P2: This is a bounded browser-cookie import policy change with no demonstrated active exploitation or availability impact.
  • merge-risk: 🚨 compatibility: Known non-owner runs that could previously invoke importprofile will no longer receive or execute that action.
  • merge-risk: 🚨 security-boundary: The patch changes which inbound principals can reach host system-profile cookie import.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR supplies a terminal before/after trace through the real browser-tool factory and schema: the known non-owner is rejected before import routing after the fix, while the owner path continues past the gate. Completing cookie decryption is unnecessary to prove this pre-routing authorization boundary.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR supplies a terminal before/after trace through the real browser-tool factory and schema: the known non-owner is rejected before import routing after the fix, while the owner path continues past the gate. Completing cookie decryption is unnecessary to prove this pre-routing authorization boundary.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • SunnyShu: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Obtain Browser-owner confirmation that known non-owner senders should lose importprofile access.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-04T01:41:12.290Z sha 261a1003f0d17dd7de8863312e2bd63a45f438b9 :: blocked before merge. :: none

The browser tool exposes action=importprofile to every run that gets the
tool. The action copies decrypted cookies from a real Chrome-family system
profile into a managed OpenClaw profile, but the tool never consulted the
trusted owner bit that the plugin tool context already carries, so a
non-owner inbound run could reach the import path.

The macOS Keychain consent prompt remains the primary control and is
deliberate. It is a one-time gate: once /usr/bin/security is allowed for the
Safe Storage item, later reads are silent and no gate remains for an
agent-generated call.

Read ctx.senderIsOwner in the browser plugin registration, drop importprofile
from the advertised actions when the sender is known not to be the owner, and
refuse the action in the tool before it resolves any routing. Runs with no
inbound sender context, such as the CLI and local operator runs, keep the
current behavior.
@yetval

yetval commented Sep 27, 2026

Copy link
Copy Markdown
Contributor Author

Closing this implementation PR and moving the unresolved Browser-owner policy decision to #159827. This remains a defense-in-depth proposal, not a security-boundary bypass report. Current source still has no inbound-owner gate for agent importprofile; the follow-up preserves the compatibility tradeoff and attributes the original runtime evidence to its original commits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: browser merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant