Suspicious cron entries
CriticalL10Linux serversCron lines that download and run outside files are signs of a break-in.
What is the risk
To survive cleanup, attackers add cron lines that pipe a script fetched with curl or wget into a shell. Crypto miners are a common example.
Commands hidden with base64 and lines that run files from /tmp or /dev/shm follow the same pattern.
How to check
Linux
sudo grep -rnE 'curl|wget|base64 -d|/tmp/|/dev/shm' /etc/crontab /etc/cron.d /etc/cron.hourly /etc/cron.daily /var/spool/cron 2>/dev/null
sudo crontab -l
sudo crontab -l -u www-data
systemctl list-timers --allThe web server account (www-data, apache, nginx) normally has no cron jobs. Also look for unfamiliar names in the system timers.
How to fix
Linux
sudo cp -a /var/spool/cron /root/evidence-cron
sudo crontab -e -u www-data
ps -eo pid,user,cmd | grep -E 'curl|wget|/tmp/|/dev/shm'
sudo kill 1234Copy first, then delete the suspicious lines and stop the processes they started (replace 1234 with the PID you found). Also check ~/.bashrc and ~/.ssh/authorized_keys of the same account.
A line like this means the server is already compromised. Find and close the way in (web shell P01, weak SSH password L02, old software L04) and change every password and key. If in doubt, rebuild on a clean server.
How to prevent it
- Mount /tmp and /dev/shm with noexec so downloaded files cannot run (L11).
- List only the accounts allowed to use cron in /etc/cron.allow so the web server account cannot.
Check again after fixing
Linux
sudo grep -rnE 'curl|wget|base64 -d|/tmp/|/dev/shm' /etc/crontab /etc/cron.d /var/spool/cron 2>/dev/nullNo output means clean.
Run the downloaded check again and make sure this item passes.