Thank you very much!

I didn't know about auth_policy, and I can see that an auth_policy server
would be ideal for me.

I could transfer a lot of the logic to that server and dispense with most (and
maybe even all) of my logfile monitoring.

I'm already using RBL with postfix, and it will probably indeed be helpful
with dovecot, as well.

As for immediate triggering against impossible auth attempts, I guess I could
come up with some sort of dictionary of these kinds of terms.

I very much appreciate all these ideas.




--
 hippoman@gmail.com
 Take a hippopotamus to lunch today.


On Wed, May 25, 2022 at 6:03 PM Joseph Tam <jtam.home@gmail.com> wrote:
On Tue, 24 May 2022, Hippo Man wrote:

Late to this party.

> * Hacker makes numerous login attempts one after the other with various
> passwords, and without disconnecting in between attempts. I've seen 10 and
> more of these repeated attempts rapidly during a single imap or pop3
> connection.

Maybe this settings helps?

        auth_failure_delay = 5 secs

I get lots of BFD, and although they have no chance of guessing a password
this way, it produces an annoying amount of rubbish in my logs.  This slow
them down to either reduce the volume of attempts (and logs), but also
gives you ample time to enact a countermeasure.

> I will get the latest dovecot source code and modify it so that dovecot
> will disconnect after "N" failed imap or pop3 login attacks, where "N" is
> some sort of configuration variable (with a default of zero, meaning do not
> disconnect). I will then use this personal version of dovecot with "N" set
> to a fairly low value (probably 1!).

1, in my opinion, is really too low.  This can lockout a legitimate user
with a simple typo, or network hiccough.

It would be better to externalize this, rather than bake it into dovecot.
Have you considered

        https://doc.dovecot.org/configuration_manual/authentication/auth_policy/

> Furthermore, I will continue to automatically monitor the logs and
> perform the same iptables DROP actions for the failed login attempts.
> The combination of these two actions will give me the behavior that I
> desire.

You can also preempt many BFD runs without resorting to one-strike-you're-out
policy

        1) Look up connecting host in RBL and do a prememptive block
        e.g. bl.websitewelcome.com, bl.blocklist.de, dnsbl.darklist.de
        are some examples of brute force DNSRBLs.  You'll find many of
        attacking IPs are represented on one of these lists.

        2) Triggerimmediate block against authentication attempts that
        can not possibly be real (e.g. "mysql", "testuser", "nagios", etc.)

Joseph Tam <jtam.home@gmail.com>