Repository navigation
Bruteforce protection [WIP] - #1603
LukasReschke wants to merge 5 commits into
Conversation
This will block IP addresses for 15 minutes which tried to login more than 10 times in the last 15 minutes. @karlitschek Check it out.
|
Hi Lukas, This is awesome! Thanks a lot for your work. |
|
To be honest, I'd really like to have this in ownCloud 5.0 since this is - from a security point of view - a real important feature and rules are there to be broken ;-) But it needs some polishing before I'd say that it can be merged with being 100% sure that it won't break something. (e.g. the CSRF check should be included and the timeframe/allowed logins need some more fine-tuning and I'd like to check if the request has been done using a proxy etc... - I'll take care of all that later this week) For a future release (read: ownCloud 6.0) I have also some additional ideas to make it even cooler! (e.g. white- and blacklisting IP addresses via the GUI for persons with enhanced security requirements e.g. governments or companies) :-) The code itself is pretty straight forward and shouldn't break anything, but I need some feedback on the index in Ok for you, @karlitschek? |
|
Hmmm. O.K. with me if:
@icewind1991 What do you think about the code? |
That won't probably happen since I have other things to do just now. - But well, I won't blame you for delaying it until oC 6.0 ;-) |
|
What about adding this to 5.1 then? |
|
There is no 5.1 planed at the moment. There will be an ownCloud 6 from master with new features 3 month after the 5 release and 5.0.1, 5.0.2, ... with only bugfixes from a stable branch. |
There was a problem hiding this comment.
This will be executed on every login attempt, maybe move this to 'logInvalidAttempt'
There was a problem hiding this comment.
Agreed. Also in 'logInvalidAttempt' it should be inside the OC_Config::getValue( "bruteforce", true) condition, otherwise it would be a performance hit even if the bruteforce option is disabled.
There was a problem hiding this comment.
Sorry, after second thought a performance hit on a failed login request is not an issue (and even desirable in some cases).
|
@karlitschek Regarding your OC6 schedule, please consider this (and other) threads in the forum: http://forum.owncloud.org/viewtopic.php?f=23&t=9108 Greetz |
|
@LukasReschke any update on this btw? |
|
Hi ! I believe the patch has two issues in its current form:
|
|
A properly configured reverse proxy setup makes sure that owncloud gets the correct via REMOTE_ADDR. If X-Forwarded-For is to be supported it might make sense to have a whitelist of IPs from which the X-Forwarded-For headers are trusted (for all other sources, X-Forwarded-For headers are thrown away). |
|
I am not sure this patch is a good idea. It might create more problems than it solves: NATs are used almost everywhere for mobile internet and some DSL providers are using it too because of IPv4 address exhaustion. Universities are another good example. This patch can be easily abused when behind a NAT for a Denial of Service attack against all the other users behind the same NAT. As long as you send login attempts fast enough, nobody else behind the same NAT will be able to log in. Also, this patch does not work against brute force attacks via IPv6 because an attacker is likely able to freely pick a few bits of his IP address (usually ca. 64 bits). Consider the following instead:
and finally as a strategy consider
cc @karlitschek |
|
Guys, this is a 3 month old PR which was written in about 10 - 20 minutes and is more of a proof of concept instead of a working solution. - I'm absolutely aware of the potential problems and am currently working on a proper two-factor authentication. (Actually I have in mind to send the server response a little bit slower after every invalid login attempt to make bruteforcing more inefficient. - e.g. after 3 invalid logins there is a timeout of 10 seconds, after 5 a timeout of 20 seconds etc...)
I'd blame the shitty provider here ;-)
Dude - you can easily DoS a oC instance with an authenticated user account in two minutes. Believe me, there are bigger issues an admin should care for at the moment ;-)
That's why it will be configurable. - But the current login procedure is really more than insufficient.
ACK - but I hadn't had the time to implement this yet. |
|
Don't understand me wrong - I'm really grateful for every comment here! I really believe that discussing security related code is the only way to ensure that it is adequate. |
Sounds like you perfectly understood the problem of IPv4 exhaustion there. ;-)
Well, owncloud has to start somewhere with stopping making mistakes. :-P
You're welcome. :) |
|
There is another problem that could be solved with this patch: currently we are detecting blocked users in our LDAP, due to ownCloud desktop login retries whenever a user changes his password. This is becoming a big problem for our users. Every password change ends in a blocked account. The only thing that we can do now, is to configure the oC desktop client not to store the password, and close the oC desktop before a password change. |
Could you backup this claim with some documentation please ? I fail to see how a reverse proxy, by definition, can change a PHP variable. |
|
@kaworu I said "reverse proxy setup", not just "reverse proxy". The proxy adds a header, e.g. "X-Real-IP" containing the remote IP connecting to the proxy before forwarding the request to the webserver. The webserver checks whether the connecting remote IP is a valid proxy. If it is, it uses X-Real-IP as the remote IP instead, which will be available to PHP. See |
|
@bantu thank you for the clarification. |
|
Admins should be able to manually remove blocks. |
@ext-caucesystem have you reported this issue already on the mirall repo? THX |
|
@LukasReschke I know you are pretty busy at the moment. But what's the status of this? THX |
|
Maybe someone should take this. @Kondou-ger @Raydiation @georgehrke @ringmaster ? |
|
On the client side, there is no special status code required if existing sessions are unaffected. For new log ins, simply use 403. |
Conflicts: config/config.sample.php core/templates/login.php lib/base.php lib/user.php lib/util.php
|
Did my best to do a merge here. I'll take this over, when I'm done with my avatars. |
|
@Kondou-ger This would be great :-) |
|
@Kondou-ger are you still working on this? Or has this already been solved elsewhere? :) |
|
Status update (just saying the obvious) I'm not working on this anymore – anybody feel free to take this over. |
|
As this is actually outdated and wouldn't work properly with the current core. I'm therefore closing this pull request. Let's look whether we have time to implement this in the near future. |
Don't merge this! - This is scheduled for
6.07.0This is a simple (but configurable) brute force protection for logins, it will block all IP addresses for 15 minutes who tried to login 10 times with invalid credentials within 15 minutes. Additionally, it will add an entry to the ownCloud log with the username + IP address.
I think this is enough, since I don't know anyone who enters his password wrong 10 times in 15 minutes ;-) - nevertheless, if one does this he will get a warning instead of the login screen saying that he should wait 15 minutes and then try it again.
Currently, it does not work with reverse proxies in place. This should get fixed before merging.
I'm not sure about the index in
db_structure.xml, could anyone check if this is correct? THX.Btw. every improvement is appreciated - just commit it to the
bruteforce-protectionbranch!Todos:
Ref #1580
\cc @jancborchardt @karlitschek