Skip to content

feat(security): per-IP rate limits on sync/meta/presence POST endpoints - #37

Merged
kevincodex1 merged 1 commit into
Twigpine:mainfrom
Ayush7614:feat/write-endpoint-rate-limits
Sep 13, 2026
Merged

kevincodex1 merged 1 commit into
Twigpine:mainfrom
Ayush7614:feat/write-endpoint-rate-limits

Conversation

@Ayush7614

Copy link
Copy Markdown
Contributor

Three unauthenticated write endpoints had no rate limit while every sibling does: sync is the most expensive route in the app (10/min), meta is unsigned by design so the IP bucket is the only spam defense (20/min), and presence hashes caller-controlled UA into a DB row per variant (30/min after the bot short-circuit). All follow the existing edit/posts 429 slow-down pattern. New write-limits.test.ts pins the wiring; limiter behavior is covered in editServer.test.ts. Verified: full app suite 338/338, lint, typecheck, build.

- sync had no limit despite being the most expensive route (tx-less calls fan
  out over every chain); 10/min per IP
- meta is unsigned by design, so the IP bucket is the only spam defense;
  20/min per IP before validation
- presence hashes caller-controlled UA into a DB row per variant; 30/min per
  IP after the bot short-circuit
- write-limits.test.ts pins the wiring (429 shape, limit-before-work order)
@coderabbitai

coderabbitai Bot commented Sep 12, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 26 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

This review ran on the open-source allowance, not this organization's plan, because the pull request author doesn't have an assigned seat. Waiting won't change this — ask an organization admin to assign them a seat, or add seats in Billing if every seat is already assigned, then retry.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: f365beca-8965-4731-abc3-fcd5e3d22936

📥 Commits

Reviewing files that changed from the base of the PR and between 400143b and d5cabbe.

📒 Files selected for processing (4)
  • app/src/app/api/launch/meta/route.ts
  • app/src/app/api/launch/sync/route.ts
  • app/src/app/api/presence/route.ts
  • app/src/app/api/write-limits.test.ts

Comment @coderabbitai help to get the list of available commands.

@Vasanthdev2004 Vasanthdev2004 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a useful, focused improvement. The limits run before the protected sync, metadata and presence work, and normal presence polling stays comfortably below the threshold.

The five submitted tests passed. Isolated route checks using the actual limiter also confirmed the 10/20/30 limits, next-request 429s before protected work, independent IP buckets and unchanged sync validation. External work was stubbed; this was not a production load test. Current app and contract CI are green.

Approving for the current Fly setup. One non-blocking limitation worth documenting: these counters are per process, not a global limit across machines. Alternate proxy deployments also need their own trusted-client-IP handling.

@Vasanthdev2004

Copy link
Copy Markdown
Collaborator

Thanks for the fixes, @Ayush7614, and for working through the earlier feedback. For the next batch, could you prioritize the outstanding review comments and group small changes that solve the same issue? Separate PRs are welcome for independent fixes; linking related work and adding a reproduction and regression test will help us review them faster.

@kevincodex1 kevincodex1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks great! thanks Ayush

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.

3 participants