Malware scan
Nightly scans of app files.
Answers one question every night: did anything change in this app that no deploy put there? Integrity first, then ClamAV on upload folders. Off until you enable it.
Commands#
cipi scan enable # nightly at 04:40 cipi scan [myapp] # now cipi scan status | report cipi scan manifest myapp # re-baseline after a legitimate manual change cipi scan disable
How it works#
When a deploy finishes, Cipi records a fingerprint (sha256) of every file in the release. Stored root-only, so the app can't rewrite it.
Every night the live release is compared to that fingerprint. A file changed or added without a deploy is exactly what an attacker leaves behind.
Upload folders change legitimately, so they're scanned differently: ClamAV plus signatures for PHP webshells.
You get an e-mail (and your other channels) listing changed or extra files. A scan that didn't finish is reported as incomplete, never as clean.
Design choices#
| Design choice | Why |
|---|---|
Manifests in /var/lib/cipi/manifests, root-only | A webshell in the app's home can't rewrite them |
| Antivirus only on upload folders | The manifest already covers everything a deploy put there; less noise, less RAM |
Every re-baseline logged in events.log | A manifest rewrite without a deploy is the thing to look for |
scan_incomplete is never called "clean" | A check that didn't finish told you nothing |
| Filenames compared exactly (spaces, backslashes) | Tricks like sh\ell.php can't hide |
Refused below 2 GB free RAM / 3 GB on /var | ClamAV loads all signatures; an OOM kill could take the database down |
Alerts: scan_integrity (changed or extra files, plus PHP isolation drift) and scan_incomplete.
It detects change between deploys; it doesn't prevent it. Isolation (per-app users, open_basedir) remains the first line of defence; this verifies it still holds.