-
Notifications
You must be signed in to change notification settings - Fork 51
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
Protecting from spammy requests #820
Comments
Fwiw, I've grown tired of updating the list of banned URLs already, and so instead I've started whitelisting URLs... This makes it really helpful that most of the functionality in a BulletTrain app is under /account :-)
|
This is an interesting idea. I definitely like things that point in the direction of "secure by default". @gazayas @kaspth @pascallaliberte @andrewculver, what do y'all think? I wonder if we could generate that allow list dynamically by inspecting/walking the actual routes in the application. |
Fwiw, blocklisting became a Sisyphean task so I've ended up going for whitelisting instead:
Since I put this in, my |
Looks like there's a Something like this maybe? Rack::Attack.blocklist('block paths that are not in routes') do |request|
Rails.application.routes.recognize_path(request.path, method: request.method, extras:)
end I have no idea what the extras are supposed to be. |
It may be costly to run through the routing tree twice — Rails already does that to serve the request, so I think there'd have to be somewhere internally where Rails raises on an unknown route. Because by default, Rails rescues some exceptions and converts them into 404 responses. These seem pertinent: https://github.com/rails/rails/blob/692f25a9254c58c64b138770e6b604e73de38620/actionpack/lib/action_dispatch/middleware/exception_wrapper.rb#L13-L14 You may be able to go further based on these exceptions and ignore them specifically in Rollbar. I'm not sure if there's cases where you'd want to have 404 exceptions in Rollbar in general. |
As soon as a site goes live properly, it's going to be hit by an endless stream of spammy requests trying to hack into the server. These end up causing some annoyance and filling up the error logs (and using up the error logging capacity on nothing).
One simple solution is to install
rack-attack
, and implement a simple blocklist:This blocks anyone accessing a URL that contains one of those strings somewhere in it. Possibly some of those should not be blocked, application-dependent, but for example just blocking all requests with "wp-" in them will remove 90% of the hack attempts which try to break into an insecure Wordpress blog. Worth noting the block is per-request. If a user mistakenly requests one of those they are not blocked permanently.
While at it, it may be worth adding the other two recommended rack-attack throttles:
Thoughts?
The text was updated successfully, but these errors were encountered: