Skip to content

fix(middleware): default rate limiter proxy strategy to last for security#2088

Merged
bpamiri merged 2 commits intodevelopfrom
peter/fix-ratelimiter-proxy-default
Apr 10, 2026
Merged

fix(middleware): default rate limiter proxy strategy to last for security#2088
bpamiri merged 2 commits intodevelopfrom
peter/fix-ratelimiter-proxy-default

Conversation

@bpamiri
Copy link
Copy Markdown
Collaborator

@bpamiri bpamiri commented Apr 10, 2026

Summary

  • Change proxyStrategy default from "first" (spoofable leftmost IP) to "last" (rightmost proxy-appended IP) when trustProxy is enabled
  • Prevents attackers from bypassing rate limiting via X-Forwarded-For header spoofing
  • Updates doc comments to reflect the new secure default

Test plan

  • Existing rate limiter tests pass (all use explicit proxyStrategy values)
  • New test verifies default behavior uses rightmost IP
  • Run bash tools/test-local.sh middleware

🤖 Generated with Claude Code

…rity

Change proxyStrategy default from "first" (spoofable leftmost IP) to
"last" (rightmost proxy-appended IP) when trustProxy is enabled. This
prevents attackers from bypassing rate limiting via X-Forwarded-For
header spoofing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…te method

The test was calling $getClientKey which doesn't exist. Rewrite to use
handle() and verify rate limiting behavior proves the default strategy
is "last" (same last IP = same bucket = blocked on second request).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@bpamiri bpamiri merged commit 029ca17 into develop Apr 10, 2026
3 checks passed
@bpamiri bpamiri deleted the peter/fix-ratelimiter-proxy-default branch April 10, 2026 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant