Skip to content

Fix: Prevent Rate Limit Bypass via Header Spoofing#280

Open
riddhima25bet10005-a11y wants to merge 3 commits into
knoxiboy:mainfrom
riddhima25bet10005-a11y:fix-270
Open

Fix: Prevent Rate Limit Bypass via Header Spoofing#280
riddhima25bet10005-a11y wants to merge 3 commits into
knoxiboy:mainfrom
riddhima25bet10005-a11y:fix-270

Conversation

@riddhima25bet10005-a11y
Copy link
Copy Markdown
Contributor

Description

Fixes a security vulnerability in the rate limiter (\middleware.tsx) where the \X-Forwarded-For\ header was blindly trusted as the rate limit key. Since this header is client-controlled, it could be spoofed to bypass rate limits (Issue #270).

The middleware now attempts to use the authenticated \userId\ as the primary rate limit key. For unauthenticated requests, it falls back to
eq.ip\ (which is securely populated by hosting platforms like Vercel and cannot be spoofed by the client), before falling back to the headers.

Fixes #270

Changes Made

  • Updated \middleware.tsx\ to extract \userId\ from \�uth()\ for rate limiting
  • Updated fallback IP resolution to prioritize
    eq.ip\ over \X-Forwarded-For\

Checklist

  • I have tested my changes locally
  • I have followed the GSSoC '26 contribution guidelines
  • The code is clean and well-documented

@vercel
Copy link
Copy Markdown

vercel Bot commented May 24, 2026

@riddhima25bet10005-a11y is attempting to deploy a commit to the Karan Mani Tripathi 's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot requested a review from knoxiboy May 24, 2026 13:54
@github-actions github-actions Bot added gssoc'26 GSSoC program issue type:bug Bug fix gssoc labels May 24, 2026
@knoxiboy knoxiboy removed the gssoc label May 24, 2026
@riddhima25bet10005-a11y
Copy link
Copy Markdown
Contributor Author

Hey @knoxiboy
Kindly review and approve.

@knoxiboy knoxiboy added the level:advanced Advanced level task label May 24, 2026
@riddhima25bet10005-a11y
Copy link
Copy Markdown
Contributor Author

@knoxiboy reviewed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc'26 GSSoC program issue level:advanced Advanced level task size/xs type:bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rate Limit Bypass via Header Spoofing (middleware.tsx)

2 participants