As mentioned here, you can restrict how many emails per hour a user can send out with the following in your exim configuration:
ratelimit = 50 / 1h / strict / $authenticated_sender
Personally I’ve used csf to alert on such an occasion. You can set the emails sent to root to forward to an email account that you can keep an eye on. You can do this by placing a file with an email address named
/root/.forward. Some systems may prefer a different method or settings (SELINUX contexts for example).
CSF controls the firewall by writing it’s own iptables rules. You can use the
/etc/csf/csf.conf file to set the default allowed ports in and out for both TCP and UDP. There are other configuration files like
/etc/csf/csf.pignore where you can whitelist IP addresses and processes.
LFD is another component that is installed with CSF. It stands for Login Failure Daemon. That process will watch for failed login attempts and automatically block IP addresses. It will also watch mail logs and alert when there are excessive emails sent per hour or suspicious processes running.
Here is an article that describes the install and setup of CSF on Ubuntu.
While it’s a little more complex than rate limiting exim, it really helps pinpoint the issue and the exact cause. More often than not you’ll be notified of the exact script generating the emails.
Platform Support Specialist