Strengthening authentication
Hi Devs, I have two suggestions for enhancing the security of this already great software.
1- Rate limiting: IP lockout after x failed logins to combat brute force attacks. Example: https://code.google.com/p/rcd-plugin-antibruteforce At a minimum, failed logins should be logged so something like fail2ban can use the log to block the offending IP.
2- Two factor authentication. Like this https://github.com/alexandregz/twofactor_gauthenticator for example.
I look forward to hearing your opinion on this, and thanks for your time.
Thanks for feature request!
Please, try two factor authentication in the latest version of the RainLoop Webmail (1.6.4.890).
Works beautifully! Thanks so much for the quick turn-around!
I am looking forward for fail2ban also. It would be a great feature along side with two factor authentication.
I use rainloop on my server and I miss fail2ban integration...
it's already implemented
../data/..../application.ini
[logs]
auth_logging = On
auth_logging_filename = "fail2ban/auth-{date:Y-m-d}.txt"
auth_logging_format = "Auth failed: ip={request:ip} user={imap:login} host={imap:host} port={imap:port}"
Just turned it on... It was off. Also do I need to create a filter in fail2ban?.
Yes, it's off by default. RainLoop just create a file and you need to create a filter in fail2ban.
Interesting writing fail2ban rules as we speak...
Hi ervee, did you end up making some fail2ban rules? Mind sharing if so?
This is my /etc/fail2ban/filter.d/rainloop.conf
# Fail2Ban configuration file
#
# Author: eRVee Moskovic
#
# $Revision$
#
[Definition]
# Option: failregex
# Notes.: regex to match the password failures messages in the logfile. The
# host must be matched by a group named "host". The tag "<HOST>" can
# be used for standard IP/hostname matching.
# Values: TEXT
#
failregex = : Auth failed: ip=<HOST> user=.* host=.* port=.*$
# Option: ignoreregex
# Notes.: regex to ignore. If this regex matches, the line is ignored.
# Values: TEXT
#
ignoreregex =
and this is in my /etc/fail2ban/jail.local
[rainloop]
enabled = true
banaction = iptables-multiport
filter = rainloop
port = http,https
logpath = /!!!PATH-TO-RAINLOOP-DATA-FOLDER!!!/_default_/logs/fail2ban/auth-*.txt
maxretry = 5
findtime = 1500
bantime = 600
Replace !!!PATH-TO-RAINLOOP-DATA-FOLDER!!! with the path to your RainLoop data folder off course.
Rainloop, it seems incorrect two-factor auth failed attempts do not show up in the auth log, can you correct this please?
(I'll open a new issue)
Hi all, Just tried to implement ervee's configuration on my server : nothing happens when I try to simulate incorrect auths : they are correctly written in the log file, the rainloop filter is on, but fail2ban doesn't ban the IP. Any idea of what could be the problem ?
Cheers,
If you use CSF/LFD rather than fail2ban, here's how to configure this:
- Enable auth logging in the app config as above (
auth_logging = On) - Edit /etc/csf/csf.conf and at the bottom of the file make CUSTOM2_LOG (or whichever one is available to you) set like:
CUSTOM2_LOG = "/path/to/rainloop/data/_data_/_default_/logs/fail2ban/auth-fail.log" - Edit
/usr/local/csf/bin/regex.custom.pmand add this before thereturn 0;line:
# Rainloop Login Bruteforce Detection.
if ( ($globlogs{CUSTOM2_LOG}{$lgfile}) and ($line =~ /Auth failed: ip=(\d+\.\d+\.\d+\.\d+)/) ) {
return ("Detected multiple failed Rainloop webmail login attempts from",$1,"rainloopbruteforcematch","25","80,443","1800");
}
Make sure you change the CUSTOM2_LOG to whichever custom log file number you configured in step 2 above.