Skip to content

Mail queue spike on cPanel — the compromised-account detection pattern

A mail queue that jumps from 50 to 5,000 messages is almost always a compromised cPanel account. Here is how to confirm it and find which one.

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

  1. Confirm the spike isn’t legitimate. A newsletter blast can produce 5,000 messages. Check with the customer first if you have any doubt.
  2. Find the source account: grep "cwd=" /var/log/exim_mainlog shows which directory the messages were generated from. That is the compromised account.
  3. 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.
  4. Suspend the account following the postmortem-friendly workflow above. Preserve evidence first.
  5. Freeze the queue from that account: exim -bp | grep <user> | awk '{print $3}' | xargs -n1 exim -Mrm removes the bad messages. Or use exiqgrep -i -f <user>@... | xargs exim -Mrm.
  6. Rotate credentials: every mail account, FTP account, cPanel password, and any database with mail-related credentials.
  7. Patch the entry point: outdated WordPress, vulnerable plugin, weak mail password, shared password between cPanel and an external service.
  8. Alert on this in the future: set a CSF/LFD alert when queue depth exceeds 1,000 (or your baseline + 3x). LF_QUEUE_ALERT = 1 in csf.conf.

Stack Harbor monitors mail queue depth as part of monitoring and support.