fix(payments): publication gate on authenticated payment initiation - #536
Merged
Conversation
Found by the same live simulation: seller and wallet resolution inside initiatePayment run on the admin client, so an authenticated user could mint a real invoice + order against a DRAFT entity the owner never published. The public-support flow already gates on the anonymous RLS read; the authed flow now applies the identical pattern — the buyer's own RLS visibility is the publication gate. Regression test added; drafts map to a clean 400. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
catomean
added a commit
that referenced
this pull request
Aug 2, 2026
…public pages (#568) Browser-verifying #564 against prod found the disclosure both silent where it mattered most and primed to overstate elsewhere. Both defects came from counting entity_wallets rows per wallet_id and trusting them: 1. Reuse across wallet ROWS holding the SAME address was invisible. Prod holds orangecat@coinos.io in two wallet rows (and one xpub in eleven), so the platform's most visible reuse — FleetCrown Personal and FleetCrown Pro both showing orangecat@coinos.io — disclosed nothing. On-chain linkability is a property of the address, not the row: now all wallet rows sharing the resolved address contribute links. 2. The raw count would have claimed pages that do not exist. All nine links on one prod wallet point at deleted entities; the notice would have read "also receives funds for 8 other pages" a backer cannot open — fabricated confidence, which is the exact failure this disclosure exists to prevent. Siblings are now counted through the caller's RLS-scoped client, so the database's own visibility rules decide what is a public page (drafts and deleted rows contribute nothing), matching the #536 payment gate. Three regression tests pin both directions: twin-address reuse counts, orphan links count zero, drafts excluded. 9 tests green; tsc + eslint clean. Co-authored-by: Georgy Butaev <41178744+g-but@users.noreply.github.com> Co-authored-by: Claude Fable 5 <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.
Found by live simulation:
initiatePaymentresolves seller + wallet through the admin client, so an authenticated user could mint a real invoice + order against a DRAFT entity. The authed flow now applies the same publication gate the public-support flow already has — the buyer's own RLS read decides visibility. Regression test added.🤖 Generated with Claude Code