Fix unsafe RateLimitMiddleware defaults - #19565
Merged
Merged
Conversation
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.
othercorey
reviewed
Jul 26, 2026
Co-authored-by: othercorey <[email protected]>
LordSimal
approved these changes
Jul 26, 2026
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, ...).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Trusting the
x-forwarded-forheader 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
@yousukezanfor reporting this issue through our security mailing list.