Join our Newsletter — 33% off our NHI Course

crontab -e (Linux Cron Table Editor)

crontab -e is the Linux command used to edit a user’s cron table, where scheduled jobs are defined. Attackers abuse it to add persistence or execute payloads repeatedly, so defenders should audit cron entries, review changes by privileged and non-privileged users, and look for jobs that call unusual paths or scripts.

What crontab -e Does

crontab -e opens a user’s cron table for editing, which is the place Linux uses to store recurring scheduled commands. That makes it a simple administrative tool, but also a high-value target because a small change can create repeated execution at login, every minute, or on any other schedule the attacker chooses.

In security terms, the command matters because the cron table is not just convenience infrastructure, it is an execution path. If an attacker can edit a user’s crontab, they can often turn one-time access into durable persistence without needing a separate service install or startup mechanism.

How Cron Scheduling Works

Cron jobs run according to time fields and a command line, usually under the context of the user whose crontab owns them. That means the same editor can be used for harmless automation, such as backups and housekeeping, or for abuse, such as launching a script from a writable directory or calling an unexpected binary path.

Because cron is interpreted by the system rather than by an application wrapper, the trust boundary is thin. A job that points at a script path, shell wrapper, or environment-dependent command may behave differently than intended if the file is replaced, the path is manipulated, or the job inherits unsafe assumptions about permissions and execution context.

Why Attackers Abuse crontab -e

Attackers like cron persistence because it is reliable, low-noise, and easy to blend into normal administration. A scheduled command can re-run a payload after reboot, respawn a deleted file, or periodically re-establish access even when the original entry point is removed.

It is also useful for staging, because a cron job can fetch content, run a script, or trigger another living-off-the-land mechanism on a fixed interval. The command itself is not malicious, but the scheduling capability makes it attractive for repeated execution and for hiding persistence in ordinary user automation.

If you want a broader view of how scheduled tasks and other persistence mechanisms are used across platforms, Persistence Techniques Guide covers common attacker persistence patterns and the corresponding detection and eviction logic.

Defensive Monitoring and Review

Reviewing cron is most effective when it is treated as a change-control and integrity problem, not just a configuration file check. The important questions are who changed the crontab, what changed, whether the command is expected, and whether the target path or script is owned, writable, and consistent with the account that runs it.

Defenders should pay close attention to jobs that invoke unusual absolute paths, pipe output to hidden locations, chain through shell expansion, or reference scripts outside standard admin-owned directories. Newly added entries, altered schedules, and jobs created by accounts that normally do not manage automation are especially important to validate.

Operationally, cron review fits naturally with audit logging, file integrity monitoring, and periodic asset review. A benign scheduled task should be understandable at a glance, while a suspicious one often reveals itself through opaque naming, uncommon execution frequency, or dependencies on a script that nobody can clearly account for.

Risk and Threat Considerations

Malformed or malicious cron entries can create durable persistence, trigger repeated payload execution, and reintroduce compromise even after an initial cleanup. The main risk is not the editor itself, but the fact that cron gives an attacker a built-in mechanism to keep executing code under a legitimate user context.

Failure mechanism: An attacker who gains write access to a user’s crontab or to a script referenced by that crontab can schedule recurring execution, then rely on the system to keep launching the payload until the entry or referenced file is removed.

Impact: This can prolong intrusion, complicate eradication, and create a false sense of recovery if the visible malware is deleted but the scheduled trigger remains in place.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

MITRE ATT&CK addresses the attack and risk surface, while CIS Controls v8 and NIST SP 800-53 Rev 5 set the governance and control requirements practitioners need to meet.

Framework Control / Reference Relevance
MITRE ATT&CK T1053.003 — Scheduled Task/Job: Cron Cron jobs are a classic scheduled execution persistence mechanism.
Recommendation — Map suspicious cron entries to scheduled-job persistence and hunt for recurring execution paths.
CIS Controls v8 CIS-8 — Audit Log Management Cron abuse is best surfaced through review of administrative and configuration changes.
Recommendation — Centralise and review cron-related change and audit events to detect unauthorized scheduling.
NIST SP 800-53 Rev 5 CM-2 — Baseline Configuration Cron tables are configuration state that should be established, reviewed, and controlled.
AU-2 — Event Logging Changing a crontab is an administrative event that should be logged for review.
SI-7 — Software, Firmware, and Information Integrity Cron persistence often depends on trusting the integrity of scheduled commands and scripts.
Recommendation — Baseline approved cron entries and investigate deviations from the authorised schedule set. Log cron modifications so investigators can trace who changed scheduled execution and when. Verify the integrity of scripts and commands referenced by scheduled jobs before execution.

Practitioner Guidance

What to watch for: Treat any unexpected crontab change as a persistence event, not just a scheduling change. The most useful review questions are whether the job is documented, whether the path is trusted and immutable enough for scheduled execution, and whether the account that owns it should be able to alter that schedule at all.

Practitioner takeaway: For cron-based persistence, the fastest path to confidence is to validate both the schedule and the target command, because either one can be the malicious element.