Skip to content

fix(ui): avoid forbidden requests from restricted operator roles - #189850

Merged
steipete merged 3 commits into
mainfrom
steipete/perf-micro-control-ui-role-gated-requests-20260919
Oct 31, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/perf-micro-control-ui-role-gated-requests-20260919

Conversation

@steipete

@steipete steipete commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes repeated forbidden diff requests when an operator requires sandboxing but views a host-workspace conversation, and optional branch/background requests without their required scopes.

User Impact

Review explains the workspace restriction before making a request. Branch controls stay hidden without write scope, and Appearance skips background reads without read scope. A workspace change during a diff returns retryable UNAVAILABLE; genuine authorization denials remain FORBIDDEN.

Why This Change Was Made

Conversation visibility does not imply access to its host files. The existing session-row projection now carries workspaceReadDisabledReason, using the same policy as file reads and the existing materialized workspace facts. Sandbox classification consumes the physical row owner already resolved by projection topology; request-facing resolvers retain their strict routing checks. The UI uses its selected-row owner and granted scopes. Server authorization remains authoritative. No new configuration, cache, database schema, or protocol version.

Canvas already binds widget reads to their session and handles pending widgets; cron already gates its view. Those owners are unchanged.

Evidence

Restricted-operator browser regression: two forbidden diff calls per dashboard visit become zero, with an explanatory Review affordance. Session-only viewer: New Conversation branch calls 1→0; Appearance background calls 1→0; cron remains 0. The chat-header branch owner also goes 1→0.

Production UI against an isolated real Gateway: 5,000 synthetic sessions and 62,000 files / 1.14 GB; zero automatic diff requests and zero UI FORBIDDEN responses. A deliberate direct diff RPC still returns FORBIDDEN. This used APFS and a small synthetic database, not a 35 GiB database or btrfs; unrelated startup UNAVAILABLE responses occurred. No private data or live deployment was used.

Five interleaved owner benchmark pairs, with A/A controls:

Measurement Before After
Denied RPCs / 5,000 diff activations 5,000 0
Client-owner elapsed median 15.69 ms 3.38 ms
Client-owner CPU median 16.83 ms 4.51 ms
Sampled allocation 18.45 MB 7.31 MB
Session projection CPU / read 1.004 ms 0.985 ms
Session projection allocation / read 692.6 KB 724.5 KB

These are owner measurements, not end-to-end production latency. Client A/A CPU medians were 16.83/16.96 ms. Projection timing shows no meaningful speed claim on the loaded host; allocation rises 4.6%, and an unconditional 100-row response grows 15.7% to carry explanations. Existing shared-field transport can deduplicate repeated values.

Focused regression and affected-consumer proof covers projection invalidation, real RPC race classification, retained UI loaders, allowed diff behavior, and scope-gated browser navigation. The real Gateway test body took 21.3 s (63 s runner); focused test and final check details follow below.

Simplification: reused existing row materialization and selected-row lookup; shared file/presentation policy replaces duplicated admission text. Production delta +173 lines, generated validator +3, test delta +206, with a matching test-line allocation for the distinct regressions. Tooling adds reproducible owner measurements. Growth is needed to project a previously missing fact and distinguish permission from retryable workspace changes.

Focused results: 148 UI owner tests passed (7.21 s runner), 51 scope-owner tests passed, four diff-browser tests passed (21.60 s runner), the extended scope-browser scenario passed (16.37 s runner; other 13 cases passed separately), 12 projection/config tests passed, 64 file/race sibling tests passed, and three publication tests passed (43.72 s runner, 2.16 s test bodies). Publication snapshots were regenerated and verified to differ only by the additive nullable field.

Known main regression: production Knip reports CHAT_SEARCH_HIGHLIGHT and syncChatSearchHighlight as unused exports. The identical two failures reproduce on the exact main parent d5be7a6a42934658aacc09803c52d056b1fba29b, which introduced that module in #170434. This change does not touch that owner. It remains a main follow-up, not a passing check.

Pre-PR pnpm check:changed: all format, type, lint, schema, boundary, and lifecycle checks passed; exit 1 solely for the two exact-parent Knip failures documented above. Independent Codex autoreview is scoped-clean through P2.

Before: restricted workspace sends forbidden diff requests

After: Review explains sandbox requirement without a diff request

Before: Appearance reports missing read scope

After: Appearance skips the unavailable background request

CI repair: the first run exposed re-resolution of physical legacy row ownership in the new projection and older allowed-session fixtures missing the new fact. Both are fixed. Only the failed owners and affected sandbox policy were replayed: 46 backend/sandbox tests and 59 UI tests passed. Targeted type checks, lint, formatting, and a fresh Codex autoreview passed. Final exact-head CI provides the broad proof.

The subsequent CI run exposed an obsolete whole-module sandbox mock in environment-execution tests. Removing it lets those 18 tests use the real classifier; all passed locally, and focused Codex review was clean. This follow-up changes no production code and reduces test growth to +206 lines. All other test jobs in that run passed.

Final validation: CI run 41253510831 passed on 13ed5bc6260f3c9123362103393e0c1341a1163d, with all planned jobs complete and no failed jobs.

Project workspace read restrictions through existing session rows and gate diff, branch, and background requests before transport. Keep server policy authoritative; classify workspace changes during diff reads as retryable UNAVAILABLE.
@clawsweeper

clawsweeper Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@steipete
steipete marked this pull request as ready for review October 31, 2026 23:08
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime scripts Repository scripts size: L labels Oct 31, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-31T23:27:37.857077Z bd16ace New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 13ed5bc6260f3c9123362103393e0c1341a1163d
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/sandbox/runtime-status.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/gateway/server-methods/session-file-read-authority.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/session-mutation-authorization-error.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

@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. labels Oct 31, 2026
Consume the physical row owner without re-routing legacy keys through fixed-store defaults. Keep strict request-facing sandbox resolution intact and update allowed-session fixtures for the projected permission fact.
@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Oct 31, 2026
@steipete
steipete merged commit 0731967 into main Oct 31, 2026
149 of 150 checks passed
@steipete
steipete deleted the steipete/perf-micro-control-ui-role-gated-requests-20260919 branch October 31, 2026 23:57
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 1, 2026
…nclaw#189850)

* fix(ui): avoid forbidden requests from restricted operator roles

Project workspace read restrictions through existing session rows and gate diff, branch, and background requests before transport. Keep server policy authoritative; classify workspace changes during diff reads as retryable UNAVAILABLE.

* fix(ui): preserve resolved session ownership in workspace projection

Consume the physical row owner without re-routing legacy keys through fixed-store defaults. Keep strict request-facing sandbox resolution intact and update allowed-session fixtures for the projected permission fact.

* test(gateway): use real sandbox classification in execution fixtures
RomneyDa added a commit that referenced this pull request Nov 17, 2026
Release adaptation: backport only the Socket Mode reconnect waiter owner
and focused regression tests; omit the performance harness and main-only
transport documentation addition. Add listener-count assertions for timer
settlement and disconnect cancellation; adjust the test allocation to 41.

Companion dispositions: #198007 is specific to SDK 3.2 callback/abort
semantics and is not applicable to this line pinned to socket-mode 3.1.0.
#197657 retires main allocations; other audit hits (#200523, #197009,
#194964, #184507, #192197, #192051, #190003, #189850) only overlap the
excluded shared perf README. No later #188745 mention through bd692e9.

(cherry picked from commit a1d1da7)

Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui 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. docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts security-sensitive-changed size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant