feat(acl): gate run_stored_query to admin — close the last read-gap#173
Merged
Conversation
run_stored_query executes pre-declared arbitrary SQL over the whole corpus (pages/blocks/links) and projects arbitrary columns (aggregates, joins), so there is no reliable per-row owner against which to apply the per-instance read ACL. The sound gate is at the capability level: operator/analytics only, exactly like the admin_* inspection tools (require_admin). A non-admin member is now refused; the unauthenticated dev/on-host path (role None) is unaffected. Carl's only caller is the operator dashboard read-proxy, which forwards under the operator's minted escurel:admin token — so no member path regresses. Red/green, real HTTP MCP: stored_query_acl.rs (non-admin refused / admin runs). Existing mcp.rs run_stored_query route test (AuthMode::Disabled) stays green. Documents the access rule in docs/spec/protocol.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the final point-3 read-gap.
run_stored_queryexecutes pre-declared arbitrary SQL over the whole corpus (pages/blocks/links) and projects arbitrary columns (aggregates, joins) — there is no reliable per-rowpage_id/owner to filter on, so the per-instance read ACL (whichresolve/neighbours/expand/list/searchuse) can't apply row-by-row.The sound gate is at the capability level: stored queries are an operator/analytics affordance, so admin-only — exactly like the
admin_*inspection tools (require_admin). A non-admin member is now refused (admin role required); the unauthenticated dev/on-host path (roleNone, no verifier) is unaffected.No consumer regresses: Carl's only caller is the operator dashboard read-proxy, which forwards under the operator's minted
escurel:admintoken. No member-facing Carl path usesrun_stored_query.Tests (red/green, real HTTP MCP)
stored_query_acl.rs:non_admin_member_cannot_run_stored_query(refused, no rows leaked) +admin_runs_stored_query(count query returns the row).mcp.rs::run_stored_query_routes_through_http(AuthMode::Disabled) stays green — the dev/on-host path is unchanged.docs/spec/protocol.mddocuments the access rule.With this, all three read tools that previously leaked across owners —
resolve,neighbours(#172), and nowrun_stored_query— are closed. Remaining ACL items are non-read:assign_eventadmin-gate (deferred pending a caller audit so it can't break the matching write path) andcapture_event(left open by design — members capture their own erasure/opt-in events).🤖 Generated with Claude Code