PR #831 review (opus): merge on the security side, three small fixes

From mnema-talk v3.3.13, rendered on this site.

Reviewer: an opus agent, read-only, given the PR number and the focus (permissions and security of member-created invites) and nothing else. It ran the perm, community and audit unit tests, go vet, and the member-invite integration tests through Docker in a scratch worktree.

FINDINGS

  1. medium: the migration number clashed with #829 (0107), and #815 held 0106. Fixed after the merge order was decided: the migrations are 0108 and 0109.
  2. low: the description of GET /api/me/invites said it needs the permission; it needs a session only, on purpose, so a member whose right was withdrawn can still see and revoke what they made. Fixed in the handler comment and OpenAPI.
  3. low: the docs said the Owner and Administrators set the limits; the routes need Manage invites. Fixed in the docs and comments. Not an escalation: those holders can already create without limits.
  4. info: the audit entries for member invites carry channel_id, which an auditor who cannot see a private channel learns as an id (never the name). Accepted; the admin invite list shows the same id.
  5. info: a test comment named the wrong migration. Fixed.
  6. design note: an invite stops working only while its creator is disabled or banned. Withdrawing the right, a timeout or the new-member wait stop new invites but do not revoke existing ones. Documented in doc/invites.md.

CHECKED AND FINE

  • The bit (1 << 30) is channel-scoped, in the timeout mask (which also covers pending rules), in the new-member write mask and in the self-assign block; granting it needs holding it (checkGrant, overwrite authorisation).
  • Channel resolution: a missing channel, a conversation, the Talk of a conversation and a channel the member cannot view all answer the same 404; only a visible channel answers 403, so nothing leaks through the status. A channel overwrite can allow or deny the right.
  • Holders of Administrator or Manage invites skip only the active and hourly caps; the per-invite bounds, the lockdown and timeouts still apply.
  • Limits and races: a per-member advisory lock is taken before the limits are read and the caps counted; the settings columns have CHECK constraints; requests above the limits get 400 and omitted fields default inside them, never unlimited.
  • Own-only revoke: DELETE ... WHERE id AND created_by; another member's invite answers 404.
  • The public preview names a channel only when EveryoneCanView holds (id only, never the name); a deleted channel sets it to NULL.
  • Migration 0109 grants @everyone the permission only when no account exists; otherwise only roles that hold Manage invites (never managed roles). Tested for both.
  • Audit entries are written in the transaction of the change and hold no invite code.

AFTER THE REVIEW

CI found three more things the review did not: the hourly counter table was a new table about a person (four erasure and export tests); it was dropped and the limit now counts the audit log. Invite fields added for member invites are optional in the schema so a client still decodes an older server's answer. The upgrade drill masks the new bit and checks that an existing install does not give it to @everyone.

Something wrong on this page? Tell us.