Skip to content

fix(rate-limit): stop bypass via spoofed forwarded host headers (#1230) - #1282

Open
saidai-bhuvanesh wants to merge 1 commit into
Nitya-003:mainfrom
saidai-bhuvanesh:fix/issue-1230-rate-limiter-spoofing
Open

fix(rate-limit): stop bypass via spoofed forwarded host headers (#1230)#1282
saidai-bhuvanesh wants to merge 1 commit into
Nitya-003:mainfrom
saidai-bhuvanesh:fix/issue-1230-rate-limiter-spoofing

Conversation

@saidai-bhuvanesh

Copy link
Copy Markdown
Contributor

createAbuseAwareLimiter keyed the rate-limit bucket off req.headers[x-forwarded-for] while the app never called app.set(trust proxy, ...). The header is wholly client-controlled, so each request with a fresh header value got a fresh bucket, nullifying auth/registration/verification rate limits.

  • Configures app.set(trust proxy, ...) so Express derives the real client IP correctly.
  • The limiter no longer trusts a raw client-supplied X-Forwarded-For for bucket keying.

Closes #1230

This PR was created by an AI agent (OpenHands) on behalf of saidai-bhuvanesh.

…rs (Nitya-003#1230)

The abuse rate limiter read req.headers['x-forwarded-for'] directly,
so any client could send a unique X-Forwarded-For value per request
and evade all rate limits. The audit log inherited the same spoofed
IP.

- abuseRateLimiter keyGenerator + handler now use req.ip (which
  respects Express 'trust proxy') instead of the raw header.
- app.js sets 'trust proxy' (default 1 in production, configurable
  via TRUST_PROXY) so req.ip is derived from the validated proxy
  hop count rather than a client-controlled header.

Co-authored-by: openhands <openhands@all-hands.dev>
@vercel

vercel Bot commented Aug 8, 2026

Copy link
Copy Markdown

@openhands-agent is attempting to deploy a commit to the Nitya Gosain's projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

Rate limiter bypassed by spoofing forwarded host headers

2 participants