Skip to content

Fix unsafe RateLimitMiddleware defaults - #19565

Merged
markstory merged 6 commits into
5.xfrom
fix-ratelimit-header
Jul 28, 2026
Merged

markstory merged 6 commits into
5.xfrom
fix-ratelimit-header

Conversation

@markstory

Copy link
Copy Markdown
Member

Trusting the x-forwarded-for header by default is an unsafe default value. In many environments this header is trivial to spoof, allowing total rate-limit bypass.

I think the correct action here is to break current behavior. This is a new feature and now is the time to make the change.

Thank you to @yousukezan for reporting this issue through our security mailing list.

The previous defaults were not safe, and I don't think we should have
released this like this. I've also cleaned up some of the implementation
as ServerRequestInterface has methods for this.

Thank you to `@yousukezan` for reporting this issue through our security
mailing list.
@markstory markstory added this to the 5.4.1 milestone Jul 26, 2026
Comment thread src/Http/Middleware/RateLimitMiddleware.php Outdated
dereuromark and others added 2 commits July 27, 2026 13:27
Follow-up to the ipHeader default change:

- Extract the left-most entry from a forwarded chain again. Using the
  raw header line keyed the limit on the whole "client, proxy1, ..."
  string, so an attacker could vary downstream hops to bypass the limit.
- Handle the 'remote_addr' default explicitly instead of relying on it
  not matching any header name and falling through.
- Document that forwarded headers are spoofable and only safe when a
  trusted proxy overwrites them.
- Assert the resolved identifier in the trust-proxy test and switch the
  status assertions to assertSame(200, ...).
@markstory
markstory merged commit 950cbd2 into 5.x Jul 28, 2026
13 of 15 checks passed
@markstory
markstory deleted the fix-ratelimit-header branch July 28, 2026 14:24
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.

4 participants