-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Security][RateLimiter] Added request rate limiter to prevent breadth-first attacks #38308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
4d9b8be
to
36b5f98
Compare
src/Symfony/Component/RateLimiter/AbstractRequestRateLimiter.php
Outdated
Show resolved
Hide resolved
61f02fb
to
21e97c2
Compare
src/Symfony/Component/Security/Http/EventListener/LoginThrottlingListener.php
Outdated
Show resolved
Hide resolved
cddd5ef
to
209cda6
Compare
...ymfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/LoginThrottlingFactory.php
Outdated
Show resolved
Hide resolved
@wouterj why is the |
I'm thinking about the interface/abstract class as a generic "request rate limiter" - not necessarily limited to login throttling. The normal Instead of duplicating the |
209cda6
to
857a989
Compare
Can you rebase to take changes from #38257 into account? |
857a989
to
6edfae3
Compare
Rebased and added the |
src/Symfony/Component/RateLimiter/AbstractRequestRateLimiter.php
Outdated
Show resolved
Hide resolved
9eaab61
to
ccf7c33
Compare
Rebase needed again :) |
Yes, and Fabien discovered a bug: the login throttling feature doesn't yet work if the username is invalid. I'll investigate later this day. |
ccf7c33
to
95fc76a
Compare
This allows limiting on different elements of a request. This is usefull to e.g. prevent breadth-first attacks, by allowing to enforce a limit on both IP and IP+username.
95fc76a
to
5d03afe
Compare
Rebased and fixed the last bug + added tests |
Thank you @wouterj. |
This allows limiting on different elements of a request. The normal
CompoundLimiter
requires the same key for all its limiters.This request limiter is useful to e.g. prevent breadth-first attacks, by allowing to enforce a limit on both IP and IP+username. It can also be useful for applications using some sort of API request limiting (or e.g. file upload limiting).
The default login throttling limiter will allow
max_attempts
(default: 5) attempts per minute forusername + IP
and5 * max_attempts
forIP
. Customizing this will require creating a new service that extendsAbstractRequestRateLimiter
and implementinggetLimiters(Request $request): LimiterInterface[]
.