How to ban IP via shared links protected form


#1

Hi,

Fail2ban is correctly banning IPs that try to force the login form. That’s really fine, and I would like to extend this feature to the form on shared links protected by password. Is there a way to do that?

Thank you for your help !


#2

As far as I can tell, Nextcloud has had Bruteforce Protection built-in since Nextcloud 11 (https://nextcloud.com/blog/nextcloud-11-delivers-verified-security-improvements/). I assume that this works on the login form as well as the password form for shared links but you may want to test this. This built-in protection only slows down logins for 24 hours so it’s not a permanent ban. Maybe this is sufficient for your needs.

As for fail2ban, I don’t know much about it but I think it works by checking log files for specific lines that indicate that something wrong has happened. So as long as the failed attempt in the password form is shown in the log, it should be possible to have fail2ban react to it. I don’t know how exactly to configure that though but there might be some fail2ban tutorials available for that.


#3

Yeah, you’re right about bruteforce. And concerning Fail2ban, there’s a way to catch people trying to log on the shared link password page.

I’ve created a filter with this regex: ^ - - ."POST /s/ENTERHASH*/authenticate/showShare HTTP/2.0" 200

And it works ! It’s important to keep the 200 response code, cause in case of success, it’s a redirection 303.

Hope this can help