,

Cómo proteger Zimbra de ataques por fuerza bruta

Zimbra no está libre de ningún ataque y uno de los más comunes es el ataque de fuerza bruta al algun buzón del sistema. Como causa de este ataque, la cuenta atacada puede quedar bloqueda o en el peor de los casos vulnerada, añadido a esto está el continuo tráfico entrante que generan los bots para realizar el ataque contra el servidor.

Para evitar este tipo de ataques se usa fail2ban, con unos pocos pasos queda listo para defender nuestro servidor zimbra:

1 ) Una vez instalado Fail2ban en el sistema (Ubuntu, Debian, Centos…) hay que crear el fichero /etc/fail2ban/filter.d/zimbra.conf y con el este contenido:

# Fail2Ban configuration file
##
Author:
##
$Revision: 1 $
#[
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 and is only an alias for
# (?:::f{4,6}:)?(?P<host>[\w\-.^_]+)
# Values: TEXT
#f
ailregex = \[ip=<HOST>;\] account – authentication failed for .* \(no such account\)$
\[ip=<HOST>;\] security – cmd=Auth; .* error=authentication failed for .*, invalid password;$
;oip=<HOST>;.* security – cmd=Auth; .* protocol=soap; error=authentication failed for .* invali
\[oip=<HOST>;.* SoapEngine – handler exception: authentication failed for .*, account not found
WARN .*;ip=<HOST>;ua=ZimbraWebClient .* security – cmd=AdminAuth; .* error=authentication faile
NOQUEUE: reject: RCPT from .*\[<HOST>\]: 550 5.1.1 .*: Recipient address rejected:
# .*\[ip=<HOST>;\] .* – authentication failed for .* \(invalid password\)
#
# Option: ignoreregex
# Notes.: regex to ignore. If this regex matches, the line is ignored.
# Values: TEXT
#i
gnoreregex =

2) Hay que modificar el fichero SASL (Capa de Seguridad y Autenticación Simple), /etc/fail2ban/filter.d/sasl.conf:

# Fail2Ban configuration file
##
Author: Yaroslav Halchenko
##
$Revision: 728 $
#[
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 and is only an alias for
# (?:::f{4,6}:)?(?P<host>[\w\-.^_]+)
# Values: TEXT
##
##failregex = (?i): warning: [-._\w]+\[<HOST>\]: SASL (?:LOGIN|PLAIN|(?:CRAM|DIGEST)-MD5) authentication f
A-Za-z0-9+/]*={0,2})?$
failregex = (?i): warning: [-._\w]+\[<HOST>\]: SASL (?:LOGIN|PLAIN|(?:CRAM|DIGEST)-MD5) authentication fail
#Jul 31 15:05:45 zimbratest postfix/smtpd[24158]: warning: host.dominio.cl[X.X.X.X]: SASL PLAIN authenticat
# Option: ignoreregex
# Notes.: regex to ignore. If this regex matches, the line is ignored.
# Values: TEXT
#i
gnoreregex =

3) Luego hay que añadir los “jails” correspondientes en /etc/fail2ban/jail.local:

[zimbra-account]
enabled = true
filter = zimbra
action = iptables-allports[name=Zimbra-account]
logpath = /opt/zimbra/log/mailbox.log
bantime = 600
maxretry = 5
[zimbra-audit]
enabled = true
filter = zimbra
action = iptables-allports[name=Zimbra-audit]
logpath = /opt/zimbra/log/audit.log
bantime = 600
maxretry = 5
[zimbra-recipient]
enabled = true
filter = zimbra
action = iptables-allports[name=Zimbra-recipient]
logpath = /var/log/maillog
findtime = 604800
bantime = 600
maxretry = 5
[postfix]
enabled = true
filter = postfix

action = iptables-multiport[name=Postfix, port=smtp, protocol=tcp]
logpath = /var/log/maillog
bantime = 600
maxretry = 5
[sasl-iptables]
enabled = true
filter = sasl
action = iptables-allports[name=sasl]
logpath = /var/log/maillog
bantime = 600

4) Por último solo falta reiniciar fail2ban:

service fail2ban restart

Ahora toca revisar logs y ver que todo esta bien, los ataques desaparecerán en minutos. ¿Necesitas ayuda en materia de ciberseguridad?

Comparte:
WhatsApp
LinkedIn
Facebook