Skip to content

fix(gateway): stop fabricating scope-upgrade requests on trusted-proxy reconnects - #129563

Merged
steipete merged 2 commits into
mainfrom
steipete/trusted-proxy-scope-narrowing
Aug 26, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/trusted-proxy-scope-narrowing

Conversation

@steipete

@steipete steipete commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

On trusted-proxy gateways with deviceAutoApprove enabled (e.g. team.openclaw.ai), every Control UI reconnect — page load, laptop wake, network flap — fabricated a device scope-upgrade round-trip: a security audit: device access upgrade requested reason=scope-upgrade warn, a pending pairing-store write, an instant same-key auto-approval (~6ms later, second store write), and a trusted-proxy browser device auto-approved warn. Nothing new was ever granted.

Root cause chain:

  1. The Control UI requests its full default operator scope set (incl. operator.admin, operator.pairing) whenever it has no stored device-token scopes.
  2. With gateway.roles configured, the Gateway intentionally issues no device tokens to human operators, so the browser never learns its narrowed grant and re-requests the full set on every connect.
  3. Requested ⊃ paired always holds, so every reconnect entered the upgrade lane even though the outcome was deterministic.

The security-audit log on a busy team gateway reads as continuous privilege-escalation attempts by every user (admins included, since their operator.admin comes from identityScopes and never lands on the device row). This is a doctrine-class recorded-fact bug: the audit entry implies operator intent that never existed.

Why This Change Was Made

requirePairing now short-circuits the deterministic case: for a same-key trusted-proxy scope-upgrade where the auto-approvable scope set is already covered by the existing paired grant, the session simply narrows to that grant — no pairing request, no store writes, no audit warns. Intent-driven widening stays on device.scopes.requestUpgrade; genuine durable widening (operator broadened deviceAutoApprove.scopes after pairing) still flows through the existing request + auto-approve lane and still audits.

The device access upgrade requested audit warn moved from the call sites into requirePairing, so it fires exactly when a pairing request is materialized — restoring the invariant that an audit entry corresponds to a real pending upgrade. The narrowed session set is (requested ∪ auto-approvable) ∩ paired under operator scope-implication semantics, so sessions never exceed the durable device grant, and owner-granted extras (e.g. a manually added operator.pairing) now survive reconnects instead of being clobbered to the config intersection.

User Impact

  • Team-gateway operators: the security-audit log stops crying wolf; scope-upgrade entries once again mean someone actually asked for elevation.
  • No more double pairing-store write per Control UI page load.
  • No behavior change for: first-time pairing, key-mismatch repairs (still manual), non-trusted-proxy auth, node/bootstrap flows, the explicit upgrade button, identityScopes, role policies, or the x-openclaw-scopes cap (still applied in resolveEffectiveConnectionScopes).
  • Docs: docs/gateway/trusted-proxy-auth.md rule 2 was stale (predates fix(gateway): auto-approve trusted-proxy same-key device scope upgrades #111916) and now describes actual same-key behavior.

Evidence

  • Live root-cause evidence: journalctl on the team gateway (2026-08-21 18:05–18:08 UTC) shows request→auto-approve pairs ~6ms apart for every reconnect; bursts correlate with page reloads (code-1001 disconnects), not user action.
  • New regression test narrows same-key reconnects without a pairing round-trip (src/gateway/server.auth.trusted-proxy-device-autoapprove.test.ts): second connect over-requesting admin+pairing succeeds with hello scopes narrowed to the paired grant, leaves no pending request, leaves the paired row untouched, and emits neither audit warn. Verified failing on pre-fix code (fails on the false device access upgrade requested warn).
  • Existing lanes stay green: server.auth.trusted-proxy-device-autoapprove.test.ts (13 passed, incl. the durable-widening same-key test), server-methods/device-scope-upgrade.test.ts (4 passed), server.auth.control-ui.test.ts (40 passed), node scripts/check-changed.mjs clean.
  • Production LOC: +58/−47 (net +11, the fast path); tests +54; docs 1-line rewrite.

Note: this branch briefly carried a minimal heal for the red core-unit-fast lane (#129282 cross-lane assertion breakage); it was dropped after #129370 landed the canonical fix on main, and this PR is rebased on top of it.

After-fix final-effect proof (real Gateway harness)

Per the repo's real-behavior-proof gate, the mock-gateway harness (real in-process Gateway, real WebSocket handshake, real pairing store) covers the changed path:

  • Allowed reconnect (final effect): the new regression connects a paired trusted-proxy browser re-requesting operator.admin+operator.pairing; the connect succeeds and the hello reports auth.scopes = ["operator.read","operator.write"] (the paired grant), with zero pending pairing requests, an untouched paired row, and neither device access upgrade requested nor auto-approved audit warn.
  • Nearest forbidden case: a connect proving a different key for the same paired deviceId stays a manual pending approval with no session ("rejects a foreign-key connect for an already-paired deviceId", passing); a row revoked mid-handshake fails the fast path's live reread and falls through to the pairing lane.

ClawSweeper P1 (stale-authority race)

Applied: the fast path now rereads the authoritative paired row (getPairedDevice) as the last await before the decision and validates key + role + auto-approve coverage against that live row; the return is synchronous after the read. The interleaved-revocation window itself is a microtask boundary not reachable deterministically from the black-box WS harness without a test-only seam (which repo policy forbids); the reachable end states are regression-covered and the ordering invariant is enforced and commented at the code site. resolvePairingApprovalPlan moved to connect-pairing-approval-plan.ts to keep the authorization owner under the 700-line boundary (move-only).

@clawsweeper

clawsweeper Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete
steipete marked this pull request as ready for review August 25, 2026 19:13
@steipete
steipete requested a review from a team as a code owner August 25, 2026 19:13
@clawsweeper clawsweeper Bot added 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. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 25, 2026
@steipete
steipete force-pushed the steipete/trusted-proxy-scope-narrowing branch from 1a1e12a to b6ba998 Compare August 25, 2026 20:01
@clawsweeper

clawsweeper Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 25, 2026, 8:28 PM ET / August 26, 2026, 00:28 UTC.

ClawSweeper review

What this changes

The PR narrows same-key trusted-proxy reconnects to their existing paired grant instead of creating and auto-approving a redundant scope-upgrade request.

Regression provenance

Possible regression — suspected (known regression link). No predecessor PR is attributed.

Merge readiness

⛔ Blocked until stronger real behavior proof is added - 6 items remain

Keep open: the fast path still permits a paired-device revoke, replacement, or scope reduction to race session registration. Likely related people: steipete (high confidence).

Priority: P1
Reviewed head: 8a1c59479a28cce6e7a4ead5dc97ffea3e5fda91

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The functional regression case is well targeted, but the remaining final-effect authority race blocks readiness.
Proof confidence 🦐 gold shrimp (3/6) Needs stronger real behavior proof before merge: Authority-chain proof required: the harness covers the allowed reconnect and a foreign key, but not a revocation or replacement after the final paired-row check and before session registration. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: Authority-chain proof required: the harness covers the allowed reconnect and a foreign key, but not a revocation or replacement after the final paired-row check and before session registration. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 5 items Changed authority check: The new fast path rereads the paired row and immediately returns success, but that is not the final session-registration boundary.
Later awaited work: After the fast-path return, the existing-device caller awaits metadata persistence; session attachment then performs further async profile work before setClient registers the connection.
Existing regression coverage: The added harness test proves the allowed narrowed reconnect and absence of pairing/audit writes, but it does not interleave revocation or replacement before attachment.
Findings 1 actionable finding [P1] Revalidate the paired grant at the session-attachment boundary
Security Needs attention Stale paired grant can reach session registration: A live paired-row reread is followed by more awaited work before the client is registered, permitting a revocation or replacement to race the final effect.

Live Verification

Command: pnpm test src/gateway/server.auth.trusted-proxy-device-autoapprove.test.ts

Result: FAIL (failed) — step 1 run pnpm test src/gateway/server.auth.trusted-proxy-device-autoapprove.test.ts: previous terminal command was still running after 30 seconds: "pnpm test src/gateway/server.auth.trusted-proxy-device-autoapprove.test.ts"

$ node --import tsx scripts/test-projects.mts src/gateway/server.auth.trusted-proxy-device-autoapprove.test.ts
[test] starting test/vitest/vitest.gateway.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-129563-KajgSo/target

Assertions:

  • FAIL expect_output: trusted-proxy browser device auto-approval

How this fits together

Gateway WebSocket connects authenticate a trusted-proxy client, compare requested scopes with a paired-device grant, and then register the session. Genuine upgrades enter pairing approval; no-op reconnects should narrow without generating pairing writes or false audit warnings.

flowchart TD
  A[Browser reconnect] --> B[Trusted-proxy authentication]
  B --> C[Paired device lookup]
  C --> D{Existing grant covers access}
  D -->|No| E[Pairing request and approval]
  D -->|Yes| F[Narrow session scopes]
  E --> G[Attach gateway session]
  F --> G
Loading

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: Authority-chain proof required: the harness covers the allowed reconnect and a foreign key, but not a revocation or replacement after the final paired-row check and before session registration. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Revalidate the paired grant at the session-attachment boundary (P1) - The new reread only precedes return true. The caller then awaits paired-device metadata refresh, and session attachment performs further awaits before setClient; a revoke, replacement, or scope reduction in that interval can still register this connection. Revalidate immediately before registration and prove the revoked/replaced case cannot attach.
  • Resolve security concern: Stale paired grant can reach session registration - A live paired-row reread is followed by more awaited work before the client is registered, permitting a revocation or replacement to race the final effect.
  • Resolve merge risk (P1) - The paired grant can be revoked, replaced, or reduced after the fast-path reread and before session registration.
  • Resolve merge risk (P1) - The reported production delta is net +11 for a bug fix; the final authorization repair should consolidate rather than add another parallel path.
  • Complete next step (P2) - A protected maintainer-owned authorization change needs the final-effect repair and proof before merge.

Findings

  • [P1] Revalidate the paired grant at the session-attachment boundary — src/gateway/server/ws-connection/connect-device-pairing.ts:195-207
  • [high] Stale paired grant can reach session registration — src/gateway/server/ws-connection/connect-device-pairing.ts:207
Agent review details

Security

Needs attention: The new authorization fast path does not retain paired-device authority through final session attachment.

PR surface

Source +34, Tests +54, Docs 0. Total +88 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 3 304 270 +34
Tests 1 54 0 +54
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 359 271 +88

Review metrics

Metric Value Why it matters
Production versus test delta production net +11; tests +54; docs 1 line changed The bug fix adds a reconnect authorization path, so its final authority boundary should remain consolidated.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/gateway/server.auth.trusted-proxy-device-autoapprove.test.ts, migration/backfill/repair: src/gateway/server/ws-connection/connect-existing-device.ts, vector/embedding metadata: src/gateway/server/ws-connection/connect-pairing-approval-plan.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Validate at session attachment (recommended)
    Move or repeat the paired-row validation immediately before the Gateway registers the client, then cover revocation and replacement at that final effect.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Revalidate the paired-device row immediately before session attachment, reject stale, revoked, or replaced grants, and add final-effect regression coverage.

Technical review

Best possible solution:

Revalidate the exact paired-device authority immediately before session registration, reject stale grants before I/O, and keep the reconnect policy on one canonical path.

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

Yes from source: a revoke or replacement after the fast-path reread but before session attachment reaches later awaits without another paired-row check.

Is this the best way to solve the issue?

No; the recheck belongs at the final session-attachment boundary rather than before later metadata and profile work.

Full review comments:

  • [P1] Revalidate the paired grant at the session-attachment boundary — src/gateway/server/ws-connection/connect-device-pairing.ts:195-207
    The new reread only precedes return true. The caller then awaits paired-device metadata refresh, and session attachment performs further awaits before setClient; a revoke, replacement, or scope reduction in that interval can still register this connection. Revalidate immediately before registration and prove the revoked/replaced case cannot attach.
    Confidence: 0.96

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: The changed trusted-proxy authorization path can attach a session after its paired grant is revoked or replaced.
  • merge-risk: 🚨 security-boundary: The PR changes the authority check that admits a paired browser session.
  • merge-risk: 🚨 compatibility: It changes reconnect behavior for existing trusted-proxy device approvals.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: Authority-chain proof required: the harness covers the allowed reconnect and a foreign key, but not a revocation or replacement after the final paired-row check and before session registration. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

Security concerns:

  • [high] Stale paired grant can reach session registration — src/gateway/server/ws-connection/connect-device-pairing.ts:207
    A live paired-row reread is followed by more awaited work before the client is registered, permitting a revocation or replacement to race the final effect.
    Confidence: 0.96

What I checked:

Likely related people:

  • steipete: Authored the current reconnect authorization change and the related merged trusted-proxy same-key scope-upgrade work. (role: feature owner; confidence: high; commits: 8a1c59479a28, 59bc78a5b271; files: src/gateway/server/ws-connection/connect-device-pairing.ts, src/gateway/server.auth.trusted-proxy-device-autoapprove.test.ts)

Rank-up moves

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

  • Revalidate the paired grant immediately before setClient and add a boundary proof for revocation or replacement in the intervening interval.
  • Post redacted final-effect evidence after the repaired run.

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 (3 earlier review cycles)
  • reviewed 2026-08-25T19:31:56.033Z sha 1a1e12a :: needs real behavior proof before merge. :: [P1] Revalidate the paired grant before authorizing the reconnect | [P2] Keep the anti-fabrication contract covered
  • reviewed 2026-08-25T20:30:51.320Z sha 7f3f83e :: needs real behavior proof before merge. :: [P1] Revalidate the paired grant before accepting the fast path
  • reviewed 2026-08-25T23:01:25.131Z sha 4d20d64 :: needs real behavior proof before merge. :: [P1] Revalidate after metadata refresh before attaching the session

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: S maintainer Maintainer-authored PR labels Aug 25, 2026
@steipete
steipete force-pushed the steipete/trusted-proxy-scope-narrowing branch from b6ba998 to 7f3f83e Compare August 25, 2026 20:25
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 25, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Applied the review. Per-item status:

  • Revalidate the paired grant before accepting the fast path (P1) — fixed. The fast path now rereads the authoritative row (getPairedDevice) as the last await before the decision and validates key + role + auto-approve coverage against that live row (pairingStateAllowsRequestedAccess(livePaired, …)); the narrowed set is computed from the live row's scopes and the return is synchronous after the read. A revoke, key replacement, or grant reduction landing during the plan await now fails the check and falls through to the normal pairing lane. The pre-plan snapshot is no longer consulted by the fast path.
  • Security concern "fast path admits a stale paired-device grant" — resolved by the same change; this matches the delegated-authority doctrine's "revalidate the exact authoritative instance after awaited policy work, decision synchronous after the read".
  • Interleaving regression case — skip stated. The race window is a microtask boundary between the caller's row read and the fast-path decision; it is not reachable deterministically from the black-box WS harness without adding a test-only seam into the authorization path (which repo policy forbids). The reachable end states are covered: key replacement stays manual ("rejects a foreign-key connect for an already-paired deviceId", passing), a revoked row makes the live reread fail closed into the pairing lane, and the ordering invariant (authoritative read → synchronous decision) is enforced at the code site with a comment citing the contract.
  • Real behavior proof — added to the PR body. Allowed reconnect: the mock-gateway harness regression (real in-process Gateway + real WS + real pairing store) proves the second connect succeeds with hello.auth.scopes narrowed to the paired grant, zero pending requests, an untouched paired row, and neither device access upgrade requested nor auto-approved audit warn. Nearest forbidden case: foreign-key connect for the same deviceId is rejected into manual approval with no session. Both run in src/gateway/server.auth.trusted-proxy-device-autoapprove.test.ts on the exact head; per the repo's real-behavior-proof gate this harness satisfies the requirement for gateway-visible changes, and the pre-fix live symptom evidence (team-gateway journalctl, request→auto-approve pairs ~6ms apart per reconnect) is already cited in the body.
  • Absorb the +11 production LOC (P1) — skip stated. The fast path is the canonical repair site: deterministic narrowing belongs in requirePairing (the authorization owner), and absorbing it into approveDevicePairing would preserve the pairing-store round-trip that constitutes the bug. The +11 net buys the removal of a false security-audit signal and two store writes per Control UI reconnect; the closure-param cleanup already offsets most of the fast path.
  • Live Verification FAIL in the review was the review harness's own 30s command timeout while the suite was still starting (previous terminal command was still running after 30 seconds); the suite passes locally (13/13, ~84s) and the same file runs green in exact-head CI.

@steipete
steipete force-pushed the steipete/trusted-proxy-scope-narrowing branch from 79f9f55 to 4d20d64 Compare August 25, 2026 22:55
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 25, 2026
…y reconnects

Same-key trusted-proxy reconnects whose auto-approvable scopes are already
covered by the paired grant now narrow the session in place instead of
running the pairing request/approve machinery: no pending-store writes and
no false 'device access upgrade requested' / 'auto-approved' security-audit
warns on every Control UI page load. The upgrade audit warn moved into
requirePairing so it fires only when a pairing request is materialized.
Durable widening (broadened deviceAutoApprove.scopes) and key-mismatch
repairs keep the existing lanes.
…path

Address ClawSweeper P1: the narrowing decision now rereads the
authoritative paired row as the last await before returning, so a
concurrent revoke, key replacement, or grant reduction fails closed into
the pairing lane instead of riding the pre-plan snapshot. Extract the
pairing approval-plan resolver into connect-pairing-approval-plan.ts to
keep the authorization owner under the 700-line lint boundary.
@steipete
steipete force-pushed the steipete/trusted-proxy-scope-narrowing branch from 4d20d64 to 8a1c594 Compare August 26, 2026 00:19
@steipete

Copy link
Copy Markdown
Contributor Author

Re-review finding "revalidate at the session-attachment boundary" — skip stated, with evidence:

  • The residual window (authorization decision → setClient registration) is a pre-existing property of every connect lane, not introduced or widened here: the plain paired-match lane (scopesAllowed true) authorizes from the caller's earlier snapshot with no reread at all, the silent-local and trusted-CIDR lanes decide before metadata persistence and token issuance awaits, and the pre-fix trusted-proxy lane held its snapshot across the request+approve store round-trip. This PR's fast path is the only lane that rereads the authoritative row as its last await; it strictly narrows the window relative to main.
  • The durable owner of revocation-vs-live-connection consistency is the removal path itself: device.pair.remove invalidates and disconnects clients for the device (context.invalidateClientsForDevice + disconnectClientsForDevice, src/gateway/server-methods/devices.ts). A registration that races the sweep is bounded by that owner; fencing revocation against in-flight registration across all lanes is a connection-lifecycle refactor with its own owner boundary, out of scope for this fix and unchanged by it.
  • Per the pre-fix baseline, the old lane could additionally re-create a pairing for a just-revoked device via approveDevicePairing on the still-pending request; the fast path cannot grant anything absent from the live row.

The review's Live Verification FAIL is again the review harness's own 30-second command timeout while the suite was still booting; the suite passes locally (13/13) and in exact-head CI (green on 8a1c594).

All previously actionable findings are applied (live-row revalidation as the last await, approval-plan module split) or skip-stated above; landing per review policy.

@steipete
steipete merged commit 91cc37b into main Aug 26, 2026
197 checks passed
@steipete
steipete deleted the steipete/trusted-proxy-scope-narrowing branch August 26, 2026 00:59
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 26, 2026
…y reconnects (openclaw#129563)

* fix(gateway): stop fabricating scope-upgrade requests on trusted-proxy reconnects

Same-key trusted-proxy reconnects whose auto-approvable scopes are already
covered by the paired grant now narrow the session in place instead of
running the pairing request/approve machinery: no pending-store writes and
no false 'device access upgrade requested' / 'auto-approved' security-audit
warns on every Control UI page load. The upgrade audit warn moved into
requirePairing so it fires only when a pairing request is materialized.
Durable widening (broadened deviceAutoApprove.scopes) and key-mismatch
repairs keep the existing lanes.

* fix(gateway): revalidate the live paired grant in the reconnect fast path

Address ClawSweeper P1: the narrowing decision now rereads the
authoritative paired row as the last await before returning, so a
concurrent revoke, key replacement, or grant reduction fails closed into
the pairing lane instead of riding the pre-plan snapshot. Extract the
pairing approval-plan resolver into connect-pairing-approval-plan.ts to
keep the authorization owner under the 700-line lint boundary.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR 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. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant