Skip to content

Exim ACLs to throttle authenticated submission

How to write Exim ACL conditions that limit how much an authenticated user can send per minute, hour, and day from a cPanel host, so one compromised mailbox cannot blow through reputation.

A compromised mailbox does not announce itself. Credentials get phished or weak passwords get cracked, and the attacker authenticates as a legitimate user. Without per-user throttles, that single mailbox can push 50,000 messages through your Exim queue in under an hour, get the IP listed across half a dozen blocklists, and leave you spending the next week getting back to neutral. ACL-based rate limits stop the bleeding inside the first minute.

What’s happening

Exim’s ACLs run on every SMTP event — connection, authentication, sender, recipient, and DATA. The ratelimit ACL condition tracks sender activity in a sliding time window and can be keyed on authenticated user, IP, or any combination. When a user trips the threshold, Exim returns a 4xx code and the message defers. Real users barely notice; attackers either give up or get loud enough to be obvious in the logs.

How to verify

Check the current outbound volume per authenticated user:

grep "A=dovecot_login:" /var/log/exim_mainlog | awk '{print $NF}' | sort | uniq -c | sort -rn | head

A normal mailbox sends tens to low hundreds of messages per day. A user pushing 5,000 in an hour is either running a sanctioned list (in which case you should know about it) or compromised.

The fix

  1. Add a ratelimit ACL in /etc/exim.conf.local under @CUSTOM_BEGIN_MAILACL. A reasonable starting shape:

    deny  ratelimit = 60 / 1h / strict / per_mail / $authenticated_id
          message  = Rate limit exceeded for $authenticated_id

    This limits each authenticated user to 60 outbound messages per hour. Adjust upward for users who legitimately need more.

  2. Stack a tighter per-minute limit to catch burst activity. ratelimit = 10 / 1m / per_mail / $authenticated_id rejects bursts even if the hourly count is still under quota.

  3. Apply a per-IP rate limit too so an attacker who rotates through harvested credentials still hits a ceiling. ratelimit = 200 / 1h / per_mail / $sender_host_address.

  4. Configure WHM > Tweak Settings > “Max hourly emails per domain” as a backstop. cPanel’s built-in throttle works at the domain level; ACL throttles work at the user and IP level. Both should be active.

  5. Alert on throttle hits. A ratelimit message in the log is a signal — not just a defer. Send a notification when any authenticated user trips the limit so a human can decide whether to keep them locked or raise the cap.

For environments where one compromised mailbox can cost you a week, Stack Harbor wires the ACL rate limits and the alerting into WHM server management from day one.