Mail queue depth is the single best early indicator of cPanel account compromise. A healthy server runs in the low hundreds at most. A compromised account turns that into 5,000+ deferred messages within minutes. By the time the reputation feeds notice and you get blocklisted, the queue is the proof. Watch it.
What’s happening
A compromised cPanel account, usually via a stolen mail password or a webshell, sends large volumes of outbound mail. Exim accepts what it can, queues what it cannot deliver immediately, and the queue grows. The pattern is consistent: a baseline queue under 500, then a spike to thousands over an hour. The destination domains in the spike are not the customer’s normal correspondents — they are bulk lists.
How to verify
exim -bpc
exim -bp | head -20
exim -bp | awk '{print $4}' | sort | uniq -c | sort -rn | head -10
grep "cwd=" /var/log/exim_mainlog | awk '{print $NF}' | sort | uniq -c | sort -rn | head -10
grep -E "T=|U=" /var/log/exim_mainlog | tail -20
The third command groups the queue by recipient domain — if gmail.com, outlook.com, yahoo.com are the top destinations and your customer is a B2B shop in Quebec, the queue is spam.
The fix
- Confirm the spike isn’t legitimate. A newsletter blast can produce 5,000 messages. Check with the customer first if you have any doubt.
- Find the source account:
grep "cwd=" /var/log/exim_mainlogshows which directory the messages were generated from. That is the compromised account. - Or find the source authenticated user:
grep -E "A=courier_login|A=dovecot_login" /var/log/exim_mainlog | grep "U=" | sort | uniq -c | sort -rn | head— top counts are the offending mail accounts. - Suspend the account following the postmortem-friendly workflow above. Preserve evidence first.
- Freeze the queue from that account:
exim -bp | grep <user> | awk '{print $3}' | xargs -n1 exim -Mrmremoves the bad messages. Or useexiqgrep -i -f <user>@... | xargs exim -Mrm. - Rotate credentials: every mail account, FTP account, cPanel password, and any database with mail-related credentials.
- Patch the entry point: outdated WordPress, vulnerable plugin, weak mail password, shared password between cPanel and an external service.
- Alert on this in the future: set a CSF/LFD alert when queue depth exceeds 1,000 (or your baseline + 3x).
LF_QUEUE_ALERT = 1incsf.conf.
Stack Harbor monitors mail queue depth as part of monitoring and support.