ClamAV vs Maldet: Which Malware Scanner for a Web Server?
ClamAV is a general antivirus engine. Maldet was built for hacked websites. On a web server the useful question is how to combine them, and what to add on top.
ClamAV versus Maldet sounds like a choice between two scanners, but on a web server it is closer to a choice of how to combine them. ClamAV is a general-purpose antivirus engine. Linux Malware Detect, usually called Maldet or LMD, was designed around what turns up on hacked hosting accounts, and it can use ClamAV's engine to do the scanning. Knowing what each one is good at saves you from trusting a clean result that means less than it looks.
What each one is built for
| ClamAV | Linux Malware Detect (Maldet) | |
|---|---|---|
| Focus | General antivirus engine, used widely on mail and file servers | Web hosting threats: PHP shells, injected JavaScript, encoded backdoors |
| Signatures | ClamAV's own databases, updated with freshclam | MD5, SHA-256, hex patterns, compound signatures and YARA rules, according to its README |
| Real-time watching | clamonacc with clamd, using fanotify | maldet -m using inotify, batch-scanned every 15 seconds by default |
| Response | Reports, and can move or remove files with options | Quarantine (-q), clean attempts (-n) and restore (-s) per scan |
| Hosting awareness | None built in | Its daily cron scans recently changed files under detected control panel paths |
Public head-to-head tests of the two are old or anecdotal, and results swing with the sample set. That is the honest state of things. Treat any claim that one catches "far more" than the other with suspicion, and test both against your own server.
Use them together
Maldet's README describes an engine priority: a remote or local clamd first, then clamscan, and its own scanner otherwise. In practice that means installing ClamAV first and letting Maldet drive it. You get ClamAV's speed and signatures plus Maldet's hosting-focused rules.
maldet -a /home/?/public_html
maldet -r /home/?/public_html 2
The first command scans everything under each account's web root. The second scans only files changed in the last two days, which is the one to run regularly. Each run prints a scan ID. Read the report before acting on it, then quarantine the hits from that scan if they are what they look like.
maldet --report SCANID
maldet -q SCANID
maldet -s SCANID
Real-time scanning, and its cost
A nightly scan finds yesterday's upload. Watching files as they change shortens that window. ClamAV's on-access scanning runs clamonacc alongside clamd, watching the paths in OnAccessIncludePath, and with OnAccessPrevention it can block access to a malicious file. It needs Linux 3.8 or later, and if the kernel lacks fanotify access permissions it runs in notify-only mode, which reports but cannot block. ClamAV refuses / as an include path, because blocking across the whole filesystem could lock up the system.
maldet -b -m users
maldet -k
The first command starts Maldet's inotify monitoring of user home directories in the background, and the second stops it. Both real-time approaches use memory and inotify watches, so on a server with millions of files check /proc/sys/fs/inotify/max_user_watches before you turn them on, and watch the load for a day.
What neither of them covers
- Custom or heavily obfuscated code. A backdoor written for one attack may match no signature. Checking file integrity against known-good releases catches what signatures miss, as shown in Check WordPress for Hacked Files with WP-CLI Checksums.
- Malicious behaviour at runtime. A file scanner looks at what is on disk. It does not see a request that abuses a vulnerable plugin to run a command without writing a file.
- The entry point. Neither tool tells you which plugin or password let the attacker in, so removal without a fix leads to reinfection.
- False positives. Both will sometimes flag legitimate minified or encoded code. Verify before deleting, using the diff method in cPanel Malware Scan False Positive? How to Confirm It.
Where BashSecure fits
ClamAV with Maldet is a sensible free baseline, and plenty of servers should run it. BashSecure is aimed at the gaps in that list. It scans file contents rather than trusting names, watches the filesystem and reports new malicious files within seconds, and adds Live Defense, which observes PHP while it runs and can log or abort a harmful action depending on the mode you choose. It connects detections to the source address, URL, script and hosting account, reports modified WordPress, Joomla and Drupal core files separately from malware, and never labels an account clean when a scan did not finish.