Skip to content

Projection-failure ops leave out restricted namespaces the caller cannot read - #204

Merged
zlareb1 merged 7 commits into
mainfrom
fix/projection-failures-org-scope
Nov 3, 2026
Merged

zlareb1 merged 7 commits into
mainfrom
fix/projection-failures-org-scope

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Critical Bug Fix (data loss, cross-tenant read, auth bypass)

Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):

ops.projection_failures.list, .retry and .resolve no longer let an org admin or platform admin read, retry or resolve the projection failures of a restricted namespace the admin holds no grant and claim for; an org admin also no longer reaches those of a collection it cannot read.

Why

The three ops set skip_namespace_authz, so an admin can address a whole org. That means authz_target hands the gate namespace=None (server/transport/gates.py:108), and the restricted-namespace check never runs. The handlers filtered by org and the optional namespace only, so:

  • list returned a restricted namespace's failure rows, including their memory_keys, error_message and payload (entity pairs and links);
  • retry replayed them;
  • resolve resolved them by id.

The security page says no org_admin or platform_admin role bypasses a restricted namespace (docs/architecture/security.md, restricted namespaces).

The fix applies resolve_org_scope, the privacy filter the org-wide rollup ops and audit.list already use. For an admin it leaves out every restricted namespace the caller cannot read (restricted_namespaces_hidden_from) and every collection it cannot read. For a caller with nothing in scope it returns empty before any statement runs. The filter goes into the one SELECT that list and retry share, and into the ALTER TABLE ... UPDATE that resolve runs.

Scope and risk

  • Touches: the three handlers in server/insights/app/ops.py, plus an optional scope fragment on list_projection_failures, retry_projection_failures and mark_projection_failures_resolved.
  • Callers that pass no scope are unchanged: the projection-repair worker, mark_resolved and the write paths that record failures.
  • Not covered here: ops.health (also skip_namespace_authz, ORG_ADMIN) reports a named namespace's aggregate counts (pending embedding stubs, op mix, procedure plane) without the org scope. It returns no memory content; closing it means threading the scope into three aggregate queries, so it is a change of its own.
  • Collections: resolve_org_scope also leaves out, for an org admin (not a platform admin), every collection it cannot read, as it does for audit.list and the org-wide rollups. The unit tests check that filter reaches every statement.
  • Risk: an admin who used these ops on a restricted namespace now gets an empty answer. That is the documented rule.
  • resolve counts ids, not rows: it reports the number of ids it was given, as before. A hidden id therefore reads the same as an unknown one and confirms nothing.

Compatibility, rollout and rollback

  • Wire: no op or field changes. A restricted namespace the caller cannot read now answers empty on these three ops.
  • Operator steps: none.
  • Rollback: revert. No rows or migrations.

Tests

  • tests/unit/test_projection_failures_org_scope.py checks, for each of the three ops, that the statement carries the namespace NOT IN {ns_hidden} clause. It also checks that a caller whose namespace classification cannot be read (restricted_namespaces_hidden_from answers *) runs no statement.

    • All four tests fail on main and pass here.
  • tests/integration/test_projection_failures_restricted.py runs an org admin with no grant on a restricted namespace and an ordinary namespace in the same org:

    • org-wide list returns only the ordinary namespace's failure;
    • list naming the restricted namespace returns nothing;
    • resolve given both ids resolves the ordinary one and leaves the restricted one active.

    It needs auth on, so it joins CI's auth-on isolation pass and skips on the auth-off pass. It passed against a local auth-on server.

  • make format lint typecheck test-unit pass.

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated (an agent wrote most of the diff): Claude Code. The gate path (authz_target, check_authorized, resolve_org_scope) was read end to end, and the unit tests were run against main to see them fail.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • make format-check, make lint, make typecheck and make test-unit pass; the integration suite passes if server behaviour changed.
  • Generated files are regenerated in this PR, not by hand (none change).
  • A new migration is additive and numbered after the latest on main; no merged migration is edited (none).
  • A behaviour change to any file a plugin ships bumps both plugin manifests' version (none).
  • The frontend builds and its tests pass, if frontend/ changed (unchanged).
  • Docs under docs/ describe the system as it now is, and this description names any operator steps and wire changes.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers.
  • Commits are signed off (git commit -s).

🤖 Generated with Claude Code

@zlareb1
zlareb1 force-pushed the fix/projection-failures-org-scope branch 3 times, most recently from 01a3cfe to 750a74b Compare November 3, 2026 13:01
zlareb1 and others added 7 commits November 3, 2026 13:15
…not read

ops.projection_failures.list, .retry and .resolve skip the transport's namespace gate, so an org or platform admin read, retried and resolved the failures of a restricted namespace it holds no grant and claim for. The handlers now narrow every statement by resolve_org_scope, as audit.list and the org-wide rollups do.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…tion test says what it covers

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…the handlers short-circuit alike

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…e statement

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
… to its builder; platform-admin case

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
@zlareb1
zlareb1 force-pushed the fix/projection-failures-org-scope branch from 750a74b to d05f50f Compare November 3, 2026 13:15
@zlareb1
zlareb1 merged commit 9fac950 into main Nov 3, 2026
21 of 22 checks passed
@zlareb1
zlareb1 deleted the fix/projection-failures-org-scope branch November 3, 2026 13:18
@pufit pufit mentioned this pull request Nov 4, 2026
9 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant