Skip to content

Narrow share-link access: stop granting generic chat read#878

Open
bdart wants to merge 1 commit into
feature/ermain-485-shared-chat-read-dedicated-server-filtered-messages-3379from
feature/ermain-486-narrow-share-link-access-to-the-dedicated-shared-route-stop
Open

Narrow share-link access: stop granting generic chat read#878
bdart wants to merge 1 commit into
feature/ermain-485-shared-chat-read-dedicated-server-filtered-messages-3379from
feature/ermain-486-narrow-share-link-access-to-the-dedicated-shared-route-stop

Conversation

@bdart

@bdart bdart commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #866 (ERMAIN-485). The dedicated share-link messages route landed in 485 — now authorized in the policy via shared_read — but a share link still also granted any logged-in viewer generic Chat::Read on the chat_id, so a viewer could hand-craft GET /chats/{id}/messages and receive every edit/regen branch. This removes that grant, closing the leak 485's route alone did not.

Change

  • Remove the chat-read allow clause in backend.rego that rode on can_read_shared_chat. Share-link viewers now hold only shared_read (modeled in Serve shared chats via a dedicated active-thread-only messages route #866), which the dedicated GET /share-links/{id}/messages route authorizes against.
  • Keep the can_read_shared_chat helper and the file-upload-via-shared-chat rule — attachments in the shared view still work (the file rule propagates from the same helper shared_read derives from).
  • Flip the rego test to assert a share-link viewer is denied generic chat read; the linked-file rule test stays green.
  • Integration test: the viewer reads via the dedicated route (200), the generic route is denied (404), and after the owner disables the link the dedicated route denies too (shared_read policy deny → 404).
  • e2e: the recipient's hand-crafted GET /chats/{id}/messages → 404.

Effect

The generic messages route, token-usage estimate, and chat metadata now deny a share-only viewer (they all check Chat::Read); the dedicated route is unaffected (shared_read). Attachments keep working via the kept file-upload rule.

Stacks on #866; part of the 485 → 486 → 489 set meant to land together.

Closes ERMAIN-486.

Validated locally: opa test 66/66, backend suite green (3 pre-existing local MCP-env failures also fail on main), test_chat_share_link_enable_disable_flow green against Postgres.

@bdart
bdart force-pushed the feature/ermain-486-narrow-share-link-access-to-the-dedicated-shared-route-stop branch from e71a2d0 to 72c89bd Compare July 24, 2026 15:46
@bdart
bdart force-pushed the feature/ermain-485-shared-chat-read-dedicated-server-filtered-messages-3379 branch from 1432dfd to 54eeda1 Compare July 24, 2026 17:39
@bdart
bdart force-pushed the feature/ermain-486-narrow-share-link-access-to-the-dedicated-shared-route-stop branch from 72c89bd to cdb44a9 Compare July 24, 2026 17:39
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