Reject inbox pagination cursor minted under a different filter (CL-7206) - #486
Merged
Merged
Conversation
Reproduces CL-7206: GET / decodes a caller's pagination cursor but never checks it was minted under the same group/status filter as the current request. Paging ?group=action, then replaying that nextCursor against ?group=mention, currently reaches the mailbox store and 500s on the stubbed db rather than being rejected before any DB access.
@corbits/mailbox embeds the view/sort/filter a cursor was minted
under specifically so a caller can reject a cross-set replay --
GET / decoded the cursor but never performed that check, so a
mention-tab fetch reusing an action-tab cursor silently seeked into
the wrong result set and served a 200 with newer mentions skipped.
cursorScopeMismatch() (packages/inbox/src/cursor.ts) reuses
@corbits/mailbox's own canonicalMailboxFilter and mirrors the error
vocabulary its mount.ts route already uses ("cursor does not match
inbox <field>"), so the two routes answer identically. GET /'s
listMailboxOpts now pins sort: "date" explicitly rather than relying
on @corbits/mailbox's own default, since the new check asserts
against that exact value.
This was referenced Aug 30, 2026
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.
Stacking
1 of 3 in a stack on
packages/inbox/src/routes.ts: CL-7206 (this PR) → CL-7207 → CL-7208. Base branch ismain; CL-7207 branches off this PR's tip.Summary
@corbits/mailboxembeds theview/sort/filtera pagination cursor was minted under directly in the cursor, specifically so a caller can reject a cross-set replay — its ownmount.tsroute already performs this cross-check.packages/inbox/src/routes.ts'sGET /decoded the cursor but never performed it, so paging?group=action, then replaying thatnextCursorunder?group=mention, returned a 200 seeking into the wrong result set — silently skipping every newer mention.packages/inbox/src/cursor.ts:cursorScopeMismatch(), a pure function reusing@corbits/mailbox's exportedcanonicalMailboxFilterand mirroring itsmount.ts's exact error vocabulary ("cursor does not match inbox view/sort/filter"), so the two routes answer identically to the same condition.GET /now rejects a scope-mismatched cursor with400before any DB access, and pinssort: "date" as conston itslistUserMailboxcall explicitly (previously relied on the mailbox package's internal default) since the new check asserts against that literal.Tests
packages/inbox/test/routes.test.ts(new): HTTP-level regression test via Honoapp.request— adbstub that throws if touched proves the rejection happens before any DB access. Verified by hand that this test fails (500, not 400) against pre-fixroutes.ts.packages/inbox/test/cursor.test.ts(new): pure unit tests ofcursorScopeMismatch(match, view/sort/filter mismatch, check ordering).@corbits/inboxsuite: 29 pass / 3 skip / 0 fail.Verification
WORKBENCH_CHECK_SINCE=origin/main bun run typecheck— cleanbun run check:structural— cleanbun run lint— cleanbunx prettier --checkon touched files — cleanKnown follow-ups (not blocking this PR)
@corbits/mailbox'smount.tsand this newcursor.ts). Filed as a follow-up to upstream the check into@corbits/mailboxitself rather than duplicate it a third time if another caller needs it.Closes CL-7206.