Skip to content
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

Throttling based on previous 4xx/5xx responses? #216

Closed
jdelStrother opened this issue Jan 30, 2017 · 2 comments
Closed

Throttling based on previous 4xx/5xx responses? #216

jdelStrother opened this issue Jan 30, 2017 · 2 comments

Comments

@jdelStrother
Copy link
Contributor

jdelStrother commented Jan 30, 2017

I keep thinking it would be useful to block/throttle clients that have produced a high number of 4xx/5xx responses recently, to cut down on errors from badly behaved spiders / script kiddies.

I couldn't see an obvious way of bending rack-attack to do this. Am I missing anything, or any thoughts on whether this functionality might belong in rack-attack or elsewhere?

@ktheory
Copy link
Collaborator

ktheory commented Jan 31, 2017

Hi @jdelStrother,

rack-attack is built to make decisions based on the request, not the response. So indeed blocking/throttling clients based on 4xx/5xx response codes isn't what rack-attack was designed for. There's a bit of history here.

@jerojasro
Copy link

jerojasro commented Dec 21, 2018

I am sort of looking for the same feature: I want to throttle failed login attempts (which get a 4XX response).

As I see there is no way of achieving it with rack-attack currently, I think maybe I could write a custom middleware, which checks the response, and if so, manually increases the request count using the proper throttle name and discriminator. And, if it simplifies things, neither this middleware, nor rack-attack, would modify the response. I would get an off-by-one throttling, because it would be caught up upon the next request, where rack-attack can check and stop it...

Does this seem reasonable to you? if so, how could I perform the "please rack-attack increase this throttle count for this discriminator"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants