WHMCS handles payment data, server credentials, and customer PII. A compromised WHMCS install is an existential event for a hosting business. The good news: the hardening that prevents 95% of attacks takes one afternoon. The bad news: almost nobody does it.
This is the working checklist.
The threat model
- Automated scanning — bots probe known vulnerabilities. 90% of attacks. Patching + IP allowlisting blocks them.
- Credential stuffing — bots try leaked passwords. 2FA + rate limiting blocks them.
- Targeted attacks — rare unless you're notable. Defense-in-depth helps.
- Insider threats — staff with admin access. Least-privilege + activity logging.
The first two account for 95% of real-world compromises.
Step 1 — Patch hygiene
- WHMCS: subscribe to security alerts, patch within 7 days of critical CVEs.
- OS: enable automatic security updates.
# RHEL / Rocky / AlmaLinux yum install dnf-automatic systemctl enable --now dnf-automatic.timer # Debian / Ubuntu apt install unattended-upgrades dpkg-reconfigure unattended-upgrades - PHP, MySQL, web server: covered by OS updates if installed from packages.
- SSL certificates: auto-renew (Let's Encrypt + certbot).
- Kernel: live-patch with KernelCare or reboot regularly. See my CloudLinux kernel guide.
Step 2 — Network firewall (CSF)
Install ConfigServer Security Firewall — free, mature, well-supported.
cd /tmp
wget https://download.configserver.com/csf.tgz
tar -xzf csf.tgz
cd csf
sh install.sh
# Test for required iptables modules
perl /usr/local/csf/bin/csftest.pl
Edit /etc/csf/csf.conf with the values that matter:
TESTING = 0 # turn off after initial testing
TCP_IN = "20,21,22,25,53,80,443,587,993,995"
TCP_OUT = "20,21,22,25,53,80,110,443,465,587,993,995"
# Brute-force detection
LF_TRIGGER = 5 # 5 failed logins = ban
LF_TRIGGER_PERM = 600 # ban for 10 min
LF_PERMBLOCK = 1 # permanent ban after 3 temp blocks
# Country-level blocking — if you don't sell in certain regions
CC_DENY = "CN,RU,KP" # examples; configure per your business
# Login failure daemon
LF_SSHD = 5
LF_FTPD = 5
LF_APACHE_404 = 50
Apply:
csf -e # enable
csf -r # restart
Step 3 — Lock down the WHMCS admin area
Rename admin folder
Default /admin/ is a known attack target.
- Edit
configuration.php:$customadmin = 'secretadmin';. - Rename the folder:
mv /path/to/whmcs/admin /path/to/whmcs/secretadmin. - Test: visit
https://yourwhmcs.com/secretadmin.
IP allowlist for admin
WHMCS Admin → Setup → Staff Management → Administrator Roles → edit → Restricted IP Addresses. Add your office / VPN IPs. Staff without those IPs can't log in.
2FA mandatory
Setup → Two-Factor Authentication → Enable + Require for all staff. Use Google Authenticator / Authy / 1Password.
Strong password policy
Setup → General Settings → Security → Password Policy. 14+ characters, mixed case, numbers, symbols.
Step 4 — File permissions
cd /path/to/whmcs/
# Files: read-only for web user
find . -type f -exec chmod 644 {} \;
# Directories: read+execute
find . -type d -exec chmod 755 {} \;
# Writable directories (and only these)
chmod -R 755 attachments/
chmod -R 755 downloads/
chmod -R 755 templates_c/
chmod -R 755 storage/
# Configuration file — readable only by web user
chmod 400 configuration.php
chown www-data:www-data configuration.php
# Delete install folder
rm -rf install/
Step 5 — HTTPS enforced everywhere
- WHMCS: Setup → General Settings → Security → Force SSL: enabled.
- Web server: redirect HTTP → HTTPS at the server level.
- HSTS header: add to your web server config (force HTTPS for 1 year minimum).
- Cipher suite: TLS 1.2 + TLS 1.3 only. Disable TLS 1.0 / 1.1.
Verify at SSL Labs. Target A+ rating.
Step 6 — Database security
- MySQL user has only the privileges WHMCS needs (SELECT, INSERT, UPDATE, DELETE on the WHMCS DB — NOT GRANT, FILE, SUPER).
- MySQL bind to localhost only (not 0.0.0.0).
- Strong DB password — auto-generated, 32+ chars.
- If MySQL is on a separate server, use SSL for the connection.
Step 7 — Application-layer protection
Add WAF / IDS:
- Cloudflare (free tier): blocks generic attacks, DDoS mitigation, bot protection.
- ModSecurity (free): rule-based WAF you self-host.
- Imunify360 (paid): comprehensive WAF + malware scanning + intrusion detection.
Step 8 — Detection & alerts
- File integrity monitoring: AIDE, Wazuh, or basic
find -mtime -1cron. Alert on unexpected changes. - Login alerts: WHMCS can email admin on new IP login (Setup → Notification settings).
- Failed login monitoring: CSF's LFD handles SSH; WHMCS logs admin attempts.
- Outbound traffic alerts: unusual outbound (sudden 100 GB of upload) often signals breach.
Step 9 — Backups (test them)
- Daily
mysqldumpoff-server. - Weekly full file backup.
- Off-server destination (S3, Backblaze B2, separate VPS).
- Encrypted at rest.
- Test restore monthly. Untested backups are not backups.
Step 10 — Incident response plan
Write it before you need it:
- Who to call.
- Where backups live + how to restore.
- Contact info for hosting provider (for IP changes, traffic blocking).
- WHMCS support contact.
- Customer notification template (data breach disclosure if relevant).
See my cPanel incident response guide for the playbook.
How to verify hardening is real
- External scan:
nmap -p- your-server. Only intended ports open. - SSL Labs: A+ rating.
- Admin URL: 404 from internet (because IP-restricted) or non-default.
- 2FA prompt appears on admin login.
- CSF logs show automated blocks (you'll see them within hours of going live).
- Backup restore test succeeds.
Common pitfalls
"CSF blocked my legitimate IP." CSF auto-bans you for too many failed admin logins. csf -dr YOUR_IP to remove. Adjust LF_TRIGGER higher if it's too aggressive.
"Custom admin folder breaks redirects." Some integrations hardcode /admin/. Search your install for hardcoded paths.
"Force SSL breaks payment gateway callbacks." Make sure your gateway is configured with the HTTPS callback URL, not HTTP.
"Backup ran but restore fails." Permissions, encryption key, MySQL version mismatch. Test restores monthly so you find out before the bad day.
My take — the discipline that prevents incidents
The hardening above is one afternoon of work. Then quarterly:
- Patch review (apply security updates manually for anything not auto-patched).
- Backup restore test.
- Permission audit.
- Review of admin staff list (any leavers still have access?).
- SSL Labs scan.
Boring. Effective. Cheaper than one incident.
Going further
I harden WHMCS deployments for hosting businesses — firewall, admin lockdown, monitoring, backup verification. Tell me about your current setup and I'll send a quote in 24 hours.