The tool guarding your web server let the attacker in
If your website or email runs on a server that you, or your web agency, manage through a control panel, the software around that panel holds the keys to everything on it. Control panels such as cPanel, Plesk, DirectAdmin, and Control Web Panel, and the security tools installed alongside them, run with root access, the highest level there is. That is what lets them do their job. This week two separate incidents showed what happens when that access is turned around.
A security update that stole the keys
cPGuard is a security suite for Linux web servers: firewall, malware scanning, protection against password-guessing. It is widely used by hosting firms and sold as an add-on with some virtual servers, including Namecheap's.
On 2 November at 02:06 UTC, an attacker used stolen login details to get into the system its maker, OpsShield, uses to send out updates. According to OpsShield's advisory, the attacker pushed a malicious script out through the normal update channel in cPGuard versions 5.88.12 to 5.88.19. It ran for about 12 hours before OpsShield caught it.
The script installed a backdoor and collected some of the most sensitive files on each server:
- The file holding the password hashes for every local account
- The database administrator's configuration file
- The administrator's command history, which often contains passwords typed on the command line
- The administrator's SSH files, which control which other computers can log in
It then uploaded what it gathered to OpsShield's own licensing server, using a compromised account there, for the attacker to collect later. OpsShield's preliminary estimate is that the attacker retrieved 32 of those collections. A spokesperson told BleepingComputer that 2,946 servers were affected and had that information copied, and that OpsShield's billing database was copied too.
The awkward part is the fix. cPGuard 5.88.25 and later removes the backdoor and the files it left behind. It does nothing about the passwords and keys that were already taken. OpsShield is explicit that any server which installed an affected version should be treated as potentially compromised, even if it is now fully up to date.
A control panel that was the backdoor
The second incident is quieter and probably older. Researchers at XLab have found a doctored copy of cwpsrv, the program that serves the admin screens of Control Web Panel, a free alternative to cPanel. They call it CWPdoor.
It behaves exactly like the real thing until it receives a specially signed web request, then runs whatever command that request carries. It hides those requests from the server's logs, and the script that installs it puts the file dates back to how they were, so a quick look shows nothing changed. When XLab checked, none of the 63 antivirus engines on VirusTotal flagged it. A copy turned up in an archive uploaded from Brazil in September, which XLab reads as a sign of real victims.
Installing it needs root access first, so CWPdoor is something an attacker plants after getting in, not how they get in. It is still a reason to check, because XLab counted more than 340,000 Control Web Panel installations exposed on the internet over the past month.
What to do
If any server runs cPGuard:
- Check the update history:
grep 'Successfully updated' /opt/cpguard/logs/install_log. Any entry for 5.88.12 to 5.88.19 means the server installed an affected update. A missing or incomplete log does not prove it did not. - Update with
cpgcli update --start, then confirmcpgcli --versionreports 5.88.25 or later. - On any server that may have run the script, follow OpsShield's list: reset the root password and every other local password from a trusted recovery environment, change those passwords anywhere else they are reused, rotate database passwords and any cloud or storage keys on the server, and replace root's SSH keys, removing the old public keys from every system that trusted them.
If any server runs Control Web Panel, run XLab's three checks:
ss -axp | grep integrity: any result namingngx_http_integrity_helperis a sign of infection.ps aux | grep cwpsrv: look for unexpected helper processes.strings /usr/local/cwpsrv/bin/cwpsrv | grep X-Ngx-Integrity: any output is the backdoor.
If you find it, treat the whole server as compromised: upgrade to the latest version, confirm the first check returns nothing, change every control panel password, and look for whatever got the attacker root in the first place.
For every server, whatever it runs:
- Look at who has standing access. Check root's list of authorised SSH keys and ask what each one is for. Vendor support keys added once for a ticket tend to stay forever. OpsShield is now removing its own, which tells you something.
- Keep passwords out of the command line, where they end up in history files that scripts like this one go looking for.
- Keep fewer secrets on the server, and know where each one lives so you can change it in an afternoon.
If an agency or host runs your server, ask them directly: "Do any of our servers run cPGuard or Control Web Panel, and what did you check and change this week?" We wrote about asking the same kind of question after the cPanel flaw in April. A good supplier will already have the answer.
How Steelwise can help
Working out who and what has standing access to your servers, and what you would need to change if one of them turned, is the kind of infrastructure review we do. Get in touch.
Further reading
- OpsShield: cPGuard security advisory, update channel compromise
- XLab: CWPdoor, the invisible backdoor living inside Control Web Panel
- NCSC: Secure system administration