Skip to content

Designing WHM API token scopes — one token per purpose, never a god token

A single root token "for automation" is the most common audit finding on takeover. Scoped tokens by purpose, with ACLs trimmed to what each integration needs, is the only sustainable shape.

Every cPanel server audit I’ve done in the last five years has at least one root API token named “automation” or “scripts” with no ACL restrictions, last rotated never. The team that created it left, the integrations it powers are vague, and the operator on duty does not have permission to revoke it because nobody knows what would break. The way to never be in that position is to design token scopes the way you’d design service accounts: one token per integration, ACL-trimmed to what that integration actually needs.

What’s happening

WHM API tokens are first-class identities in cPanel since version 84. Each token has a name, an associated user, a set of ACLs, and optionally an IP allowlist and an expiration. The ACL set is the meaningful scope — a token with only list-accts can read account state and nothing more; a token with all-acl is equivalent to root. The token registry lives in /var/cpanel/authn/api_tokens_v2/whostmgr/<user>.json. Naming is the audit affordance: a token called backups-2026-05 tells the next operator what it’s for and when it was issued.

How to verify

List the tokens currently issued for the root user and any reseller you suspect:

whmapi1 api_token_list_tokens
whmapi1 api_token_list_tokens user=acmevpn
cat /var/cpanel/authn/api_tokens_v2/whostmgr/root.json
tail -f /usr/local/cpanel/logs/access_log | grep -E 'token=.*acl'

For each token, note the ACL list. Anything with all-acl or no ACL list is a god token; anything older than your rotation policy is a stale token. Both are findings.

The fix

  1. Define the integration matrix first. Each cron job, monitoring agent, billing sync, backup runner gets its own row: purpose, required ACLs, allowed source IPs, rotation cadence.
  2. Create one token per row: whmapi1 api_token_create token_name=backups-2026-05 acl-1=list-accts acl-2=basic-system-info. Add --allow_from=10.0.0.0/24 to bind it to the source IP range when the integration runs from a known network.
  3. Store the token in your secret store (Vault, AWS Secrets Manager, sealed-secrets) keyed by token name. Never in a script file, never in environment variables checked into git, never in a chat message.
  4. Set a rotation calendar. Quarterly is the floor; annually is the maximum. Rotation means creating a new token with the same ACLs, updating the consumer, then revoking the old one: whmapi1 api_token_revoke token_name=backups-2026-02.
  5. Audit quarterly. List all tokens, cross-check against the integration matrix, revoke anything that doesn’t have a current owner.

For shops with token sprawl on legacy servers, Stack Harbor’s cPanel and WHM management practice runs a token inventory as the first step of any takeover and rebuilds the scope model from current operational reality.