Skip to content

Incident response for a cPanel account takeover

The first 60 minutes when a cPanel account is confirmed compromised — what to preserve, what to stop, what to communicate, in what order.

Account takeover is the most common security incident on a cPanel host. A customer reports their site is defaced, or you spot a mail queue spike, or rkhunter alerts. The response in the first 60 minutes determines how clean the recovery is. The mistake is jumping straight to remediation without preserving evidence or notifying the customer.

What’s happening

Account takeover means an attacker has functional access to the account — they can log in to cPanel, deploy files, send mail, read databases. The path is usually a weak password, a stolen credential from a third-party leak, an exploited plugin, or an unpatched application. The attacker’s goals are typically: send spam, host malware, defacement, or exfiltrate data. Your job in the first hour is to stop them while keeping the evidence intact.

How to verify

last -i | head -20
grep <user> /usr/local/cpanel/logs/access_log | tail
exim -bp | grep -c <user>
find /home/<user>/public_html -mtime -7 -type f -name "*.php" | head
imunify-antivirus malware list --user <user>

The first command shows recent successful logins by IP — an unfamiliar IP with a still logged in flag is a smoking gun.

The fix

The 60-minute incident response runbook:

  1. Minute 0–5: stop the bleed. whmapi1 suspendacct user=<user> reason="ir-$(date +%Y%m%d%H%M)". Then exim -bp | grep <user> | awk '{print $3}' | xargs -n1 exim -Mrm to clear the spam queue if relevant.
  2. Minute 5–15: snapshot evidence. tar czf /backup/ir/<user>-$(date +%Y%m%d%H%M).tar.gz /home/<user>. Copy the access logs, exim mainlog slice, and any rkhunter or Imunify alerts to the same directory.
  3. Minute 15–20: notify the customer. Use a templated email: “we detected a security incident on your account at [time], we have suspended access to stop further damage, we are preserving evidence, we will have an update by [time+24h].” Honest and short.
  4. Minute 20–40: identify the entry point. Compare the access log for cPanel and WHM around the time of the first malicious activity. Find the source IP. Cross-reference with any leaked credential dumps the customer may know of. Examine WordPress audit logs if relevant.
  5. Minute 40–55: rotate every credential. cPanel password (operator action), all mail account passwords (operator action), database passwords (operator action, update wp-config and similar), API keys (customer action — list them and tell the customer).
  6. Minute 55–60: write the timeline. A short Markdown file with timestamps, evidence pointers, root cause hypothesis, and the next 24-hour plan. This becomes the postmortem.

Recovery beyond the first hour follows the defacement clean-room restore procedure. For environments where Stack Harbor handles incident response, this is part of monitoring and support.