Skip to content

fix(openclaw-id): delegated owner devices can escape revocation or regain removed capabilities - #193990

Merged
jalehman merged 4 commits into
mainfrom
openclaw/brisk-shell
Nov 6, 2026
Merged

jalehman merged 4 commits into
mainfrom
openclaw/brisk-shell

Conversation

@jalehman

@jalehman jalehman commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Related: #191469 (security review of the protocol package)

What Problem This Solves

Fixes: a delegated owner device can survive revoking the device that approved it, or get back capabilities that were taken away. To do this it re-adds itself (or another device) with a new certificate.

User Impact

User impact: revoking an owner device now reliably removes every device it approved, and lowering a device's capabilities stays in effect until the recovery kit raises them again. Nothing has shipped yet; this tightens the v1-draft protocol before Gateways store membership state.

Why This Change Was Made

addOwnerDevice had two gaps found in the #191469 security review:

  1. It took approved_by from whoever signed the replacement certificate. A device with approve_device could re-certify itself (or a sibling) and move out of its approver's removal cascade.
  2. The capability-raise exemption checked whether the embedded certificate was R-signed. A device could therefore carry its old R-signed certificate inside a new change that it signed itself, and restore capabilities that had been lowered. The same route could re-list a removed kit-enrolled device.

Protocol changes (all in add_owner_device):

  • Same signer: the certificate must be signed by the key that signs the enclosing MembershipChange (wrong_signer otherwise). The authority behind a grant is the current authority of the change. Every caller I found already signs both with the same key.
  • Subtree rule: an owner device may re-add only itself or a device it approved, directly or transitively (target_mismatch otherwise). An earlier version of this fix only preserved lineage. Independent review showed that then let a device attach its own peer key to an unrelated root-approved device and survive revocation. This rule closes that.
  • A re-add by an owner device keeps the existing approved_by and still cannot raise capabilities. R can still re-add any device, raise capabilities, and re-anchor a device under root.

Docs:

  • statements.md and enrollment.md now describe these rules.
  • README.md states that the guarantees assume the loader and Service Worker delivery path is trusted (review item 3).
  • The old K_srv+K_gw residual risk is now an accepted v1 limitation. The text corrects the claim that a K_gw-signed nonce answer would close it, and notes that an old K_gw can also trigger owner_reset (review item 4).

Out of scope: separate from this PR, the client freshness marker can lower its stored binding_seq. That is a pre-existing bug, tracked as a separate issue.

Test-line allocation: config/test-lines-allocations/openclaw-id-owner-device-lineage.txt grants 197 lines, exactly this PR's net test growth. These are security regressions for the review findings and the peer-graft bypass, and no existing test covered them.

Evidence

Live Gateway trace through the #192345 tunnel ingress (before and after)

#192345 (tunnel transport and relayed-device Gateway auth) is not on main yet, so I built it together with this PR and ran one scripted scenario against a real Gateway. I ran it on two builds:

The script is a throwaway and is not committed.

What the scenario uses:

  • Real:
    • a Gateway server (createGatewaySuiteHarness, token auth, gateway.openclawId.enabled)
    • the OpenClaw ID service and authority over the SQLite claw store
    • the private ingress listener: a Unix socket with a per-boot proxy token
    • the tunnel API (POST /_openclaw-id/v1/statements)
    • Gateway WebSocket auth for relayed devices
    • the removal effects wired at Gateway startup
    • device-token issuance, binding and revocation
    • root changes submitted as a local operator: loopback openclawId.authority submit with the Gateway token
  • Replaced: only the QUIC tunnel child. Requests enter the ingress socket the way the child forwards them: proxy token plus authenticated peer-key header. Membership updates sent to the child are recorded.

Scenario:

  1. R links the claw with D1.
  2. D1 approves D2 through the tunnel API.
  3. R enrolls C.
  4. D2 opens a Control UI WebSocket over the tunnel and gets a tunnel-bound device token.
  5. D2 tries the attacks. E replays its old certificate after a capability reduction.
  6. R revokes D1.
  7. D2 reconnects, with and without its old token.
  8. R re-enrolls D2.
Step Unfixed (#192345 alone) This PR (#192345 + #193990)
Ingress request without the proxy token 403 403
D1 approves D2 via tunnel API (legitimate) 200 200
R enrolls C as local operator (legitimate) accepted accepted
D2 Control UI WebSocket over the tunnel admitted as owner, device token issued admitted as owner, device token issued
D2 re-certifies itself via tunnel API 200, approved_by moves off D1 200, approved_by stays D1
D2 adds its peer key to C via tunnel API 200 403 target_mismatch
E replays its old R-signed certificate 200, caps restored to all four 403 wrong_signer, caps stay ["approve_device"]
R revokes D1: removal summary devices: 1, connectionsClosed: 0 devices: 2, connectionsClosed: 1
D2's open WebSocket stays open closed by the Gateway, code 1008
D2 peer key in membership pushed to the tunnel child still admitted removed
D2 reconnects over the tunnel admitted refused: "this device no longer has access to this claw"
D2 reconnects with its old device token admitted refused (same message); token store reports token-revoked
D2 reads /_openclaw-id/v1/membership 200 403 not_owner_device
C connects (independent root device) admitted admitted
R re-enrolls D2 under root (recovery) accepted accepted; D2 is admitted again with a fresh Gateway device identity

After recovery, D2's old Gateway device identity is asked to re-pair ("pairing required: device is asking for a higher role than currently approved"). Removal revoked that identity's paired tokens, and this pairing behavior comes from #192345, not from this PR.

Not exercised:

  • the QUIC child and relay network
  • a browser or Service Worker
  • run cancellation for active runs (no runs were started, so runsCancelled is 0 in both builds)

An earlier version of this section had a service-level trace on the in-memory store with recorded effect hooks. The live trace above supersedes it.

Protocol tests

  • New approval-lineage.test.ts (9 tests through submitStatement) covers:
    • self re-certification, then R revokes the approver
    • reciprocal re-certification
    • attaching a peer key to an unrelated device
    • an ancestor updating a descendant
    • R re-anchoring a device
    • grant → reduce → replay old R-signed certificate (refused; a fresh R-signed change can still raise capabilities)
    • replaying an old certificate to re-list a removed device
    • mismatched certificate and change signers, in both directions
  • On unfixed main, 7 of these 9 tests fail (the R re-anchor and ancestor-update cases are guards that pass both ways).
  • pnpm vitest run packages/openclaw-id-protocol: 25 files, 178 tests pass. The new file takes 3.0s wall time with --maxWorkers=1.
  • oxlint on the changed files and a package-scoped tsgo typecheck are clean; run-format --check and git diff --check pass.
  • CI is green on 40441d9933f9.
  • Two independent review passes. The first found the peer-graft bypass, which this version fixes. The second found no P0–P2 issues. It also probed ancestor edits, orphans whose approver was dropped for inactivity, cycles, and shared peer keys.

…gain removed capabilities

OpenClaw-Publication: d77653aa-2243-49dd-8290-544278dfad32
@clawsweeper

clawsweeper Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

OpenClaw-Publication: d13c5bfb-757b-4950-81db-9a7632a90997
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 6, 2026
@clawsweeper

clawsweeper Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR preserves delegated-device approval lineage and requires device grants to use the enclosing membership change’s current authority.

Example: D1 approves D2, D2 re-certifies itself, and the recovery-kit root revokes D1.

  • Before: D2 can change its recorded approver and retain access after D1 is revoked.
  • After: D2 remains under D1 and loses its connection, tokens, and admission when D1 is revoked.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with distinct regressions and sufficient Gateway enforcement evidence; proof uses a real server harness with the tunnel child replaced.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The updated before/after trace exercises the exact protocol head through a real Gateway’s Unix-socket ingress, HTTP membership API, WebSocket authentication, SQLite authority, and production removal effects. It covers allowed enrollment, forbidden peer graft and certificate replay, closure of an existing revoked connection, rejected reconnects with the old token, denied membership reads, and root recovery. This resolves the earlier recorded-hook limitation. The QUIC child is replaced; relay networking, browser delivery, and active-run cancellation are expressly outside the demonstrated scenario.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A delegated device can evade cascading removal or restore capabilities that an owner removed.
Reason: The repair restores the protocol owner’s established revocation and capability contracts within the approved direction.

Merge readiness

✅ Ready for maintainer review

This PR fixes authority bypasses still present on current main; no actionable introduced defect was found.

Priority: P2
Reviewed head: 40441d9933f966d67efa3ff73adc14ce401d1da9

Before merge

None.

Findings

None.

Agent review details

How this fits together

The protocol authority validates signed membership changes and returns updated membership plus removal events; the Gateway persists that state and enforces connection and token removal.

flowchart TD
  A[Signed membership change] --> B[Gateway authority queue]
  B --> C[Protocol grant validation]
  C --> D[SQLite membership state]
  D --> E[Admission and snapshots]
  C --> F[Removal events]
  F --> G[Connections and device tokens]
Loading

Technical review

Best possible solution:

Keep grant validation in addOwnerDevice, preserve approval lineage, and retain recovery-kit authority to restore access.

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

Current-main source exposes both bypasses, and the supplied Gateway comparison records the failing and repaired behavior; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The patch repairs the producer of invalid grants, reuses the existing descendant calculation, and preserves legitimate enrollment and root recovery.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against e5253a3b0563.

Provenance checked

  • Owner-device grant authority and approval lineage keeps the original intent (ed57ed7: The original protocol used a bounded current allowlist, cascading removal, and stored capability limits instead of certificate chains or growing revocation history.)
  • Listing sequence and revocation replay protection keeps the original intent (0809cf3: Captured revocations must not remove devices approved again after the revocation’s observed sequence.)
  • Documented browser trust and replaced-key limitation changes intended behavior with a stated reason (ed57ed7: The draft documented hostile Discovery and relay behavior plus a residual risk involving replaced server and Gateway keys.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Josh Lehman: Raw commit ed57ed7 adds packages/openclaw-id-protocol/src/authority/apply.ts:347 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: ed57ed752e35; files: packages/openclaw-id-protocol/src/authority/apply.ts)

PR surface

Source +62, Tests +197, Docs +25, Other +3. Total +287 across 7 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 1 69 7 +62
Tests 2 199 2 +197
Docs 3 38 13 +25
Config 0 0 0 0
Generated 0 0 0 0
Other 1 3 0 +3
Total 7 309 22 +287

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production versus test growth Production net +62 lines; tests net +197 lines Growth implements three grant invariants within the existing authority and adds distinct security regressions without new persisted state or another enforcement owner.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove merge-risk: 🚨 security-boundary: Current PR review selected no merge-risk labels.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This repairs concrete authorization defects in an unshipped draft capability, with no evidence of an affected stable release.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-11-06T06:30:56.623Z sha 40441d9 :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-06T06:44:00.425Z sha 40441d9 :: needs real behavior proof before merge. :: none

Reviewed November 6, 2026, 8:45 AM ET / 13:45 UTC (Revision 3).

@jalehman

jalehman commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 6, 2026
@jalehman

jalehman commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added the clawsweeper:intake:bug Preliminary submission classification; full source review pending. label Nov 6, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. 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. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 6, 2026
@jalehman
jalehman merged commit c6480f7 into main Nov 6, 2026
159 checks passed
@jalehman
jalehman deleted the openclaw/brisk-shell branch November 6, 2026 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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: M 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