top of page

How to Secure a cPanel Server from Malware


A compromised cPanel server can become a serious security problem for both hosting providers and website owners. Malware can infect WordPress, Joomla, Drupal, custom PHP applications, email accounts, databases, and other files stored on the server.


An attacker who gains access to one hosting account may use it to spread malware, send spam, redirect visitors, steal credentials, or distribute malicious files.


Securing a cPanel server requires multiple layers of protection, including malware scanning, software updates, strong authentication, web application security, account isolation, secure file permissions, backups, firewall protection, and continuous monitoring.



What Is Malware on a cPanel Server?


Malware is malicious software or code designed to perform unauthorized actions.


On a cPanel hosting server, malware may appear as:

  • PHP backdoors

  • Web shells

  • Malicious JavaScript

  • Cryptocurrency miners

  • Phishing pages

  • SEO spam scripts

  • Mailer scripts

  • Ransomware

  • Malicious redirects

  • Obfuscated PHP code

  • Injected database content

  • Compromised WordPress plugins or themes

  • Modified .htaccess files

  • Unauthorized cron jobs


An infected website may continue to look normal to visitors while secretly executing malicious code in the background.

Regular scanning and monitoring are therefore important.


Why Do cPanel Servers Get Infected With Malware?


There is rarely one single reason for a malware infection. Several weaknesses can combine to give attackers an opportunity.


1. Outdated CMS Software

Old versions of WordPress, Joomla, Drupal, Magento, and other applications may contain security vulnerabilities.


2. Vulnerable Plugins and Themes

Third-party plugins and themes are common targets because attackers can exploit vulnerable versions to upload or execute malicious files.


3. Weak Passwords

A compromised cPanel, FTP, SSH, email, or CMS password can provide an attacker with an entry point.


4. Stolen Credentials

Credentials can be stolen through phishing attacks, infected computers, browser malware, or password reuse.


5. Poor File Permissions

Incorrect permissions can allow unauthorized users or processes to modify files that should be protected.


6. Unprotected Upload Functions

Poorly designed PHP applications may allow attackers to upload executable scripts.


7. Outdated Server Software

Old operating-system packages, PHP versions, Apache components, database software, or control-panel software can increase the attack surface.


8. Insecure Third-Party Software

Unmaintained scripts and abandoned applications can become easy targets.


1. Keep cPanel & WHM Updated


One of the first steps in protecting a cPanel server is keeping cPanel & WHM and the underlying operating system updated.


Security updates can address vulnerabilities in the control panel, system components, and related software.


Use WHM to review your update configuration and make sure the server receives appropriate maintenance updates.


You can also review:

WHM → Security Center → Security Advisor

Security Advisor scans the server and provides recommendations for detected security issues.


Best Practice

Do not postpone security updates indefinitely.

Before making major changes, maintain a reliable backup so you have a recovery option if an update causes an unexpected compatibility problem.


2. Install a Malware Scanner


A dedicated malware scanner is an important security layer for a cPanel hosting server.

cPanel documents ImunifyAV as a malware-scanning option. It can scan websites and identify malicious files through the WHM interface.

You can access it through:

WHM → Plugins → ImunifyAV

Depending on your security requirements, paid solutions such as ImunifyAV+ or Imunify360 may provide additional capabilities.


Why Malware Scanning Matters

A malware scanner can help identify:

  • Suspicious PHP files

  • Web shells

  • Malicious scripts

  • Known malware signatures

  • Infected website files

  • Suspicious modifications


Malware scanning should be treated as one layer of security rather than a complete security solution.


3. Use ClamAV Where Appropriate


ClamAV is another antivirus option available for cPanel servers.

It can scan areas such as:

  • Home directories

  • Mail folders

  • FTP-accessible areas

  • Public web space


For environments where ClamAV is already deployed or specifically required, it can still be useful.


If you use ClamAV, schedule regular scans during periods of lower server activity.

Test scanning schedules on your specific server before deploying resource-intensive scans across a large number of hosting accounts.


4. Enable ModSecurity


ModSecurity provides another layer of protection against malicious web requests.

You can configure it through:


WHM → Security Center → ModSecurity

ModSecurity can help detect and block suspicious HTTP requests before they reach vulnerable applications.


It can help defend against attack patterns associated with:

  • SQL injection

  • Cross-site scripting

  • Malicious file uploads

  • Exploit attempts

  • Common web application attacks


Configure WAF rules carefully because overly aggressive rules can block legitimate requests.


5. Keep PHP Versions Updated


Many websites hosted on cPanel use PHP.

Running obsolete PHP versions increases security risk because older releases may no longer receive security fixes.


Review the PHP versions installed on your server and encourage customers to use supported versions.


PHP configurations can be managed through the appropriate WHM and EasyApache interfaces.


A simple policy can be:

  • Supported PHP version: Recommended

  • Old but still supported version: Migration required

  • End-of-life PHP version: Upgrade immediately

This is particularly important for WordPress and other PHP-based applications.


6. Secure WordPress and Other CMS Applications


A secure server does not automatically mean that every website hosted on it is secure.

Every CMS installation should be maintained separately.


For WordPress websites:

  • Update WordPress regularly.

  • Update plugins.

  • Update themes.

  • Remove unused plugins.

  • Remove unused themes.

  • Avoid pirated themes and plugins.

  • Use strong administrator passwords.

  • Enable two-factor authentication where available.

  • Restrict unnecessary administrator accounts.

  • Monitor unexpected file changes.

  • Keep independent backups.


The same principles apply to Joomla, Drupal, Magento, PrestaShop, and custom PHP applications.


7. Remove Unused Software and Websites


Every unused application can become another potential entry point.

If an old website is no longer required, remove it rather than leaving an abandoned application on the server.

Pay special attention to:

  • Old WordPress installations

  • Development websites

  • Test domains

  • Temporary scripts

  • Unused plugins

  • Abandoned themes

  • Old PHP applications

  • Forgotten subdomains


A server with fewer unnecessary applications generally has a smaller attack surface.


8. Use Strong cPanel and Hosting Account Passwords


Weak passwords remain one of the easiest ways for attackers to gain unauthorized access.

Use unique passwords for:

  • WHM

  • cPanel

  • SSH

  • FTP/SFTP

  • MySQL

  • Email accounts

  • WordPress administrators

  • Hosting-reseller accounts


Avoid dictionary words and easily predictable information.

Never reuse the same password across multiple services.


9. Enable Two-Factor Authentication


Two-factor authentication adds another layer of protection.

Even if an attacker obtains a password, they may still be unable to access the account without the second authentication factor.


Where supported, enable 2FA for:

  • WHM administrators

  • cPanel accounts

  • CMS administrators

  • Hosting management systems

  • Other security-sensitive services

Protecting administrative accounts is particularly important because administrator-level access can allow an attacker to modify multiple websites.


10. Enable cPHulk Brute Force Protection


cPHulk is designed to protect cPanel services against brute-force attacks.

It monitors authentication attempts involving services such as:

  • cPanel

  • WHM

  • Mail services

  • FTP

  • SSH

You can configure it through:


WHM → Security Center → cPHulk Brute Force Protection


cPHulk works best alongside strong passwords and other authentication controls.

Be careful when configuring IP whitelists so legitimate administrators do not accidentally get locked out.


11. Secure SSH Access


SSH provides powerful administrative access to the server.

If SSH is compromised, an attacker may gain access far beyond a single website.

Recommended practices include:


  • Use SSH keys where practical.

  • Disable unnecessary authentication methods.

  • Restrict administrative access.

  • Avoid exposing unnecessary services.

  • Use firewall rules to limit access.

  • Keep SSH software updated.

  • Monitor authentication logs.

  • Avoid sharing root credentials.


For production servers, SSH security should be treated as a critical part of the overall security architecture.


12. Use SFTP Instead of Plain FTP


Traditional FTP does not provide the same encryption protections as secure alternatives.

Where possible, use:

SFTP

If FTP is not required, consider disabling it.

Reducing the number of exposed services can reduce the server's overall attack surface.

13. Configure Correct File Permissions

Incorrect file permissions can make malware infections easier to spread or persist.

Website files should not generally be writable by everyone.

Avoid permissions such as:

777

unless there is a specific and carefully understood requirement.

Review:

  • Website directories

  • PHP files

  • Configuration files

  • Upload directories

  • .htaccess

  • CMS files

  • Temporary directories


The exact permissions required depend on the CMS, PHP handler, hosting architecture, and application design.


Do not blindly apply the same permissions to every cPanel account.


14. Protect Configuration Files


Files containing credentials or application secrets require special attention.

Examples include:


wp-config.php

.env

configuration.php

Database configuration files

API credential files

These files may contain database passwords, API keys, encryption secrets, or other sensitive information.

Make sure they are not unnecessarily exposed through the web server.

15. Scan for Suspicious PHP Files

Attackers frequently use PHP backdoors because PHP is widely deployed on hosting servers.

Look for suspicious files containing:

  • Obfuscated PHP

  • Unexpected eval() usage

  • Suspicious encoded strings

  • Unexpected file-upload functions

  • Remote code execution patterns

  • Unknown administrator scripts

  • Recently modified files

  • PHP files inside upload directories


Do not delete files simply because they contain a suspicious-looking function.

Legitimate applications can also use functions that appear in malware detection rules.

Always verify the file against the application's original source and investigate its context before deleting it.


16. Monitor Recently Modified Files


Unexpected file modification can be an important indication of compromise.

When investigating an infected account, examine:

  • Recently modified PHP files

  • New files

  • Changed .htaccess files

  • New JavaScript files

  • Unexpected cron jobs

  • New administrator accounts

  • Modified CMS configuration files


A file timeline can help identify when an infection occurred and which application may have been compromised.


17. Monitor Cron Jobs


Attackers sometimes create scheduled tasks that restore malware after administrators remove it.


Check cron jobs for:

  • Unknown commands

  • Suspicious scripts

  • Recently created schedules

  • Commands referencing unusual directories

  • Obfuscated shell commands

  • PHP scripts outside normal application paths

If you find an unknown cron job, investigate it before deleting it so you understand how the compromise works.


18. Secure Email Services


Malware and compromised accounts are frequently associated with email abuse.

Monitor:


  • Exim mail queues

  • Outbound email volume

  • Suspicious authenticated logins

  • Unknown mail accounts

  • PHP mail activity

  • Spam complaints


A compromised website can also contain scripts that send large volumes of spam.

Malware protection and email monitoring should therefore be treated as connected security tasks.


19. Use a Firewall


A properly configured firewall can restrict unnecessary network access.

Your firewall strategy should allow only services that your server actually needs.

Depending on the services enabled, this may include:


  • HTTP

  • HTTPS

  • DNS

  • SMTP

  • IMAP/POP

  • SSH

  • cPanel

  • WHM

  • FTP/SFTP

The exact configuration depends on your server.


Do not copy a generic firewall configuration without checking which services your server actually uses.


20. Maintain Reliable Backups


Backups are essential when dealing with malware.

A malware infection can result in:


  • Deleted files

  • Modified files

  • Encrypted files

  • Corrupted databases

  • Compromised accounts

  • Defaced websites


Maintain backups that are separated from the production environment.

Ideally, keep multiple backup versions so you can restore from a point before the infection occurred.

A backup containing malware is not a clean recovery strategy.

Periodically test your backups and verify that restoration actually works.


21. Scan Backups Before Restoring Them


Never assume an old backup is automatically clean.

If a website was compromised several weeks ago, older backups may contain the same malicious files.


Before restoring a backup:

  1. Identify the likely infection date.

  2. Choose a backup from before the compromise.

  3. Scan the restored files.

  4. Update the CMS.

  5. Update plugins and themes.

  6. Change passwords.

  7. Review administrator accounts.

  8. Check cron jobs.

  9. Verify database content.

  10. Monitor the website after restoration.


22. Use Security Advisor Regularly


cPanel's Security Advisor provides a centralized way to review server security recommendations.

Access it through:

WHM → Security Center → Security Advisor

The interface scans the server and reports security issues that require attention.

Security Advisor should be part of a recurring server-security routine, but it should not replace a complete security audit.


23. Monitor Server Logs


Logs can provide valuable evidence when investigating malware.

Depending on the suspected attack, review:

  • Apache logs

  • Nginx logs, if applicable

  • PHP logs

  • SSH authentication logs

  • Exim logs

  • cPanel logs

  • CMS logs

  • ModSecurity logs

  • Firewall logs


Look for:

  • Repeated login attempts

  • Unexpected POST requests

  • Suspicious upload requests

  • Unknown IP addresses

  • Requests to unusual PHP files

  • Large volumes of outbound mail

  • Repeated requests for vulnerable URLs


Log monitoring can help identify an attack before it becomes a major compromise.


24. Investigate Malware Instead of Only Deleting It

Simply deleting infected files may not solve the problem.

For example, if an attacker exploits a vulnerable WordPress plugin and uploads a PHP backdoor, deleting the backdoor while leaving the vulnerable plugin installed may allow the attacker to compromise the website again.

A proper malware investigation should determine:

  • How the attacker gained access

  • Which account was compromised

  • Which file was originally exploited

  • Whether passwords were stolen

  • Whether additional backdoors were installed

  • Whether cron jobs were created

  • Whether other accounts were affected

Finding and closing the original entry point is critical.


25. Change Credentials After a Compromise


If malware has been discovered, assume that credentials may have been exposed.

Depending on the incident, consider changing:

  • cPanel passwords

  • WHM passwords

  • SSH credentials

  • FTP/SFTP passwords

  • MySQL passwords

  • Email passwords

  • WordPress administrator passwords

  • API keys

  • Application secrets


Do not change only the website administrator password while leaving potentially compromised hosting credentials unchanged.


26. Check for Cross-Account Infection


On a server hosting multiple websites, one infected account may not be the only affected account.

After discovering malware:

  1. Scan the affected account.

  2. Scan other hosting accounts.

  3. Check common directories.

  4. Review recent file modifications.

  5. Examine suspicious processes.

  6. Check outbound email activity.

  7. Review server authentication logs.

  8. Look for common malware signatures.

This is particularly important on shared hosting environments.


27. Consider Account Isolation


Account isolation can reduce the impact of a compromised website.

Avoid configurations where one website can freely access another customer's files.


The exact isolation strategy depends on your cPanel architecture, PHP handler, CloudLinux configuration, permissions, and hosting model.


For larger shared-hosting environments, stronger isolation can substantially reduce the impact of a single compromised account.


28. Use HTTPS Everywhere


HTTPS does not directly prevent malware infections, but it protects data exchanged between visitors and websites.

Use valid SSL/TLS certificates for:

  • Websites

  • cPanel

  • WHM

  • Webmail

  • Other administrative services where applicable


HTTPS also helps protect login credentials from interception during transmission.


29. Avoid Pirated Themes, Plugins and Scripts


Pirated or "nulled" software is a major security risk.

Modified packages can contain:

  • Backdoors

  • Hidden administrators

  • Spam scripts

  • Cryptocurrency miners

  • Data-stealing code

  • Remote-access mechanisms

Only install software from trusted sources.


30. Create a cPanel Malware Prevention Checklist


A regular security routine can make server protection easier.


Daily

  • Review security alerts.

  • Check malware scanner results.

  • Monitor unusual outbound email.

  • Investigate suspicious server activity.

  • Review critical alerts.


Weekly

  • Check CMS updates.

  • Review administrator accounts.

  • Examine suspicious file changes.

  • Review cron jobs.

  • Check disk usage and unusual processes.


Monthly

  • Review firewall rules.

  • Audit hosting accounts.

  • Remove unused software.

  • Review SSH access.

  • Test backup restoration.

  • Review server security settings.


After Every Malware Incident

  • Identify the infection source.

  • Isolate the affected account if necessary.

  • Scan the server.

  • Remove malicious files.

  • Patch vulnerable software.

  • Change credentials.

  • Review logs.

  • Scan other accounts.

  • Restore from a known-clean backup when appropriate.

  • Monitor for reinfection.


What Should You Do If Your cPanel Server Is Already Infected?


If you suspect that your cPanel server has already been compromised, avoid immediately deleting large numbers of files.


Instead, follow a controlled incident-response process.


Step 1: Identify the Affected Account

Determine which cPanel account contains the suspicious files.


Step 2: Take a Backup or Forensic Copy

Preserve relevant evidence before making destructive changes when practical.


Step 3: Scan the Account

Use your installed malware scanner.


Step 4: Identify the Original Vulnerability

Look for:

  • Outdated plugins

  • Stolen credentials

  • Vulnerable applications

  • Exposed services


Step 5: Isolate the Affected Website

Temporary isolation can help prevent further damage.


Step 6: Remove Malware

Clean malicious files carefully and replace compromised application files with verified originals.


Step 7: Patch the Vulnerability

Update the CMS, plugin, theme, PHP application, or server component responsible for the compromise.


Step 8: Change Passwords

Rotate credentials that may have been exposed.


Step 9: Scan Other Accounts

Do not assume the infection is limited to one website.


Step 10: Monitor for Reinfection

Continue monitoring logs, malware scans, file modifications, and outbound traffic.

If you suspect a root-level server compromise, professional incident-response assistance is strongly recommended.


Is ImunifyAV Enough to Protect a cPanel Server?


No.

A malware scanner is an important security layer, but it should not be considered complete server protection.


A stronger security architecture combines:

Malware scanning + WAF + firewall + updates + strong authentication + account isolation + backups + monitoring + incident response


Each layer addresses a different part of the threat.


For example:

  • A WAF can block malicious web requests.

  • Malware scanning can identify infected files.

  • cPHulk can reduce brute-force attacks.

  • Strong passwords can reduce credential attacks.

  • Backups can help recover damaged websites.

  • Monitoring can reveal suspicious activity.

  • Updates can eliminate known vulnerabilities.


Layered security is more effective than relying on a single security application.


Recommended cPanel Malware Security Stack


For a production cPanel server, consider implementing these security layers:


cPanel and WHM

Keep cPanel and WHM updated.


Malware Scanning

Use ImunifyAV or another appropriate security solution.


Web Application Firewall

Configure ModSecurity.


Authentication

Use strong passwords and 2FA.


Brute-Force Protection

Enable cPHulk.


SSH

Harden and restrict SSH access.


File Transfer

Prefer SFTP over plain FTP.


PHP

Use supported PHP versions.


CMS

Keep applications, plugins, and themes updated.


Firewall

Allow only required services.


Backups

Maintain separate and tested backups.


Monitoring

Review logs and security alerts.


File Permissions

Use least-privilege permissions.


Incident Response

Maintain a documented recovery process.


Final Thoughts


Securing a cPanel server from malware requires more than installing an antivirus scanner.

The strongest approach is a layered security model combining malware detection, secure authentication, application updates, firewalls, WAF protection, account isolation, backups, monitoring, and regular security reviews.


Start with the basics: keep cPanel and applications updated, install appropriate malware scanning, configure ModSecurity, enable cPHulk, secure SSH, use strong passwords, maintain reliable backups, and monitor your server regularly.


Most importantly, if malware is detected, investigate how the attacker gained access rather than simply deleting the infected file. Closing the original vulnerability is key to preventing the same infection from returning.


Frequently Asked Questions


How do I scan a cPanel server for malware?

You can use a malware-scanning solution such as ImunifyAV through WHM. cPanel also provides ClamAV integration for environments that use it.


Is ImunifyAV available for cPanel?

Yes. cPanel documents ImunifyAV as a malware-scanning option that can be installed through WHM.


Can a malware scanner prevent every infection?

No. Malware scanners are only one component of server security. Vulnerability management, authentication security, WAF protection, firewalls, backups, monitoring, and proper account isolation are also important.


How often should I scan a cPanel server?

The appropriate frequency depends on the number of websites, server resources, risk profile, and malware solution being used. Higher-risk hosting environments should use continuous or scheduled monitoring where practical.


Can malware spread between cPanel accounts?

It can, depending on the vulnerability, account isolation, permissions, server configuration, and type of malware involved.


After discovering an infection on a multi-account server, it is prudent to investigate other accounts as well.


Should I delete an infected PHP file immediately?

Not necessarily.

First determine whether the file is legitimate, how it was modified, and whether other malicious files or persistence mechanisms exist.


Deleting one file without fixing the underlying vulnerability can result in reinfection.


What is the best way to secure a cPanel server?

Use a layered approach that includes:

  • Regular updates

  • Malware scanning

  • ModSecurity

  • Firewall protection

  • Strong authentication

  • cPHulk

  • Secure SSH

  • Proper file permissions

  • Application security

  • Backups

  • Monitoring

  • An incident-response plan

 
 
 

Comments


PRODUCTS

BOOKING & SUPPORT

Linux Web Hosting

© 1998-2026 Dawar Creativity. Website designed by Graphic Designer

bottom of page