First let me state that the mail server is working fine and users can connect and send email.
Basically there is a local web script connecting into the mail server trying to send mail every few minutes. It has the wrong password. Problem is we don't know what script is connecting in so we are looking for a way to get the username which is being tried.
UGFzc3dvcmQ6 - decodes to Password: so isn't much help. A full log line is below.
Dec 11 20:15:37 HOST postfix/smtpd[642]: warning: HOST[x.x.x.x]: SASL LOGIN authentication failed: UGFzc3dvcmQ6
Server is running Debian/Postfix/Dovecot.
We were able to trace the username by using Dovecot itself.
In the
/etc/dovecot/conf.d/10-logging.conf
config we enabled verbose auth logging usingThis put the information in
I was able to prevent this by setting up SSL and requiring auth attempts over SSL only with
This doesn't present the
AUTH
option to the remote client afterEHLO
and so the spammers/hackers give up because establishing a SSL connection is too much time. They work a numbers game. Now instead it hangs up when they tryAUTH
and I get this in my logs:If you have fail2ban installed you can enable sasl (or sometimes called postfix-sasl) in your jail.local (or jail.d) and that should make the annoyances go away.
There are at least two ways of finding the user name(s) being tried.
Logging SMTP transactions with Postfix
If you know which host(s) your strange connections are coming from, you can enable verbose debugging for them by specifying a debug_peer_list in
/etc/postfix/main.cf
:This will yield, among other things, a message like this in syslog:
You will want to use this setting for very specific debugging only, since the full SMTP session is logged, including the password.
In this example, a LOGIN attempt for user "info" has failed after the password "foobar" was presented. Like the challenges, you can decode the replies as base64:
Logging authentication with Dovecot
Postfix itself does not include a SASL implementation. Traditionally, it was hooked up to Cyrus SASL, but if you are using the Dovecot POP/IMAP server, Postfix can reuse its SASL module.
As you have found out, Dovecot has its own debugging facility, enabled with
in its config file, often
/etc/dovecot/conf.d/10-logging.conf
. The output in/var/log/dovecot-info.log
will look something like this:While there is no host-based control here, there are a number of related options to control what gets logged, specifically whether or not to include the attempted passwords. From the example config:
See also the Dovecot documentation for details.
About SMTP authentication
As you note, the string
UGFzc3dvcmQ6
in the log message is the base64-encoding of "Password:". What Postfix is logging here is the particular authentication "challenge" that it has sent and received an erroneous reply for. There is also a preceding challenge for "Username:" (VXNlcm5hbWU6
). However, even for nonexistent users, the failure will only be reported after the password.The values of the challenge strings are actually unimportant and should be ignored. The first challenge is always for the user name, and the second is for the password. The details about this can be found in the specification for the LOGIN method.
NB: Since this is all a bit noodly for just transfering and checking the username-password pair, LOGIN is long obsoleted. The PLAIN method works essentially the same but packs both pieces of information into the same base64 string.
Finally, the fact that parts of this conversation are base64-encoded is actually a feature of SMTP Authentication in general. The idea is to easily allow arbitrary (possibly binary) data to be exchanged between the SASL modules of client and server, without those SASL modules needing to know or care about SMTP itself. You can get an idea of how SASL operates from the Cyrus SASL documentation.