fix: critical bugs in comments, likes, and Convex mutation auth#108
Draft
cursor[bot] wants to merge 1 commit into
Draft
fix: critical bugs in comments, likes, and Convex mutation auth#108cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
- comments.list: include ancestors when selecting top-N by score so high-scoring replies no longer appear with a false deleted parent - likes: count distinct ipHashes and sync denormalized counter after each mutation (fixes inflated counts from duplicate race rows) - security: require HMAC ipProof on public write mutations so direct Convex calls cannot forge ipHash to bypass bans/rate limits - SeriesList: stop empty href reload on the active series item Co-authored-by: Injoon Oh <injoon5@icloud.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Summary
Daily critical-bug investigation found three unfixed issues on
main(fixes existed on unmerged branches). This PR applies minimal, high-confidence patches.Bugs fixed
1. Comment thread orphans (user-facing)
Impact: On busy pages,
comments.listtook the top 200 comments by score. A high-scoring reply could be included while its lower-scored parent was dropped, so the UI showed a false[deleted]parent.Root cause: Flat
slice(0, MAX_COMMENTS)without pulling in ancestors.Fix: When selecting top comments, always include the ancestor chain for each selected reply.
2. Inflated like counts (user-facing)
Impact: Parallel
setLikeraces could insert duplicatelikesrows for one visitor. Reads counted rows (not unique visitors), and dedup decrements desynced the denormalized counter.Root cause: Row-count semantics + increment/decrement per duplicate row.
Fix: Count distinct
ipHashvalues;syncLikeCountForUrlafter each mutation; backfill rebuilds per-URL totals from unique visitors.3. Convex write auth bypass (security)
Impact: Public mutations accepted arbitrary
ipHash, so directConvexHttpClientcalls could bypass per-IP bans, rate limits, and inflate likes.Root cause: Trusting client-supplied
ipHashwith no server attestation.Fix: SvelteKit API routes attach
ipProof(HMAC ofipHashwithIP_HASH_SECRET); mutations verify viaassertIpProof(admin bypass unchanged).4. Series navigation reload
Impact: Active series item used
href="", reloading the page on click.Fix: Render current item as a non-link; use absolute
/blog/{slug}hrefs for siblings.Deploy notes
After merge, set Convex env (same value as Vercel):
Without this, legitimate writes will fail with
Forbiddenonce Convex functions deploy.Validation
dcf7ab6,b2dc165,e36fedascripts/ip-proof-test.mjsandscripts/like-unique-count-test.mjs(require live Convex/dev server)npm run check— pre-existing errors only (no new files in changed Svelte components)