Skip to content

Revoking a leaked WHM API token without breaking the integrations that still need it

A token leak forces an instant revoke, but a clean revoke means listing what the token was used for first. A short incident runbook in the right order.

A bug bounty report lands at 3 AM: a WHM API token was committed to a public GitHub repo six months ago. The token grants all-acl and is still active. The right move is to revoke it now and triage downstream consequences after — but the operator who runs whmapi1 api_token_revoke without knowing what the token is wired to will break things they cannot quickly identify. A two-minute pre-revoke check makes the difference between a clean kill and a Tuesday morning of unexplained alerts.

What’s happening

whmapi1 api_token_revoke token_name=<name> invalidates the token immediately; any subsequent request using it returns HTTP 401. WHM does not pre-warn the integrations that depended on the token; they will start failing on their next call. The cPanel logs do record token usage — both successful calls and failures — so you can grep history to see what was using the token before you killed it.

How to verify

Before the revoke, capture the token’s recent usage:

whmapi1 api_token_list_tokens
grep -h 'token_name=backups-2026-02' /usr/local/cpanel/logs/access_log
grep -h 'api_token=.*backups-2026-02' /var/cpanel/api_tokens.log 2>/dev/null
zgrep 'backups-2026-02' /usr/local/cpanel/logs/access_log-*.gz | head -50

The access log shows the source IP and the API endpoint each token was hitting. That’s your “what would break” list. Note every IP and every endpoint.

The fix

  1. Revoke immediately if the leak is confirmed public: whmapi1 api_token_revoke token_name=backups-2026-02. Public exposure beats integration uptime — the longer the token is live, the more damage a malicious actor can do.
  2. Capture the source-IP and endpoint list from the grep above. Each unique IP-endpoint pair is a consumer that needs a new token.
  3. Issue replacement tokens one per consumer (don’t reuse the leaked token’s name; pick a new name with the date): whmapi1 api_token_create token_name=backups-2026-05. ACL-trim to the actual endpoints the grep showed.
  4. Distribute new tokens through your secret store, not chat or email. Update each integration; restart it; confirm with a fresh access-log entry.
  5. Force-rotate all tokens for the same user account if you suspect lateral compromise — a single leaked token is a smell, not a guarantee that’s the only one out there.
  6. Forensics: pull six months of access log for that token (the cron-archived gzipped logs typically go back that far). Look for source IPs outside your expected ranges and unusual endpoint mixes. If you find evidence of exploitation, escalate to the full incident-response playbook.

Token leaks land in our queue more often than they should — Stack Harbor’s cPanel server management team runs the revoke, the forensics pull, and the replacement-token rollout as one workflow so consumers come back up before customers notice.