The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu
Go agent-ai-cliagent-harnessesagent-securitybrowser-extensionciclaude-codecloudcodexcursordetection-engineeringjevknowledge-basememorymobile-device-managementobservabilitysecuritysecurity-information-and-event-managementsecurity-toolstelemetrytraces
id: crontab-modification
version: 2
title: Crontab modified (user, system, or spool)
description: >
A persistent-scheduling primitive was modified: the user crontab
(crontab -e, crontab <file>, echo '...' | crontab -, crontab -r to
remove), the system crontab (/etc/crontab), a drop-in under
/etc/cron.d/ or /etc/cron.{hourly,daily,weekly,monthly}/, or a
user's spool file under /var/spool/cron/. Adding a cron entry is a
near-universal persistence primitive — once installed, the job runs
on schedule even after the originating agent session ends. The rule
is anchored on the command binary or the file path so a `crontab -l`
list or a `cat /etc/crontab` read does not fire.
severity: high
status: experimental
posture: detect
taxonomy:
beacon_category: risky-command
owasp_llm: LLM06
mitre_atlas: AML.T0011
match: >
(e.event.action == "command.executed" && (
e.command.command.matches("(?i)(^|[;&|]\\s*|\\bsudo\\s+)\\s*crontab\\b[^;&|]*(\\s-e\\b|\\s-[a-z]*r\\b|\\s-\\s+[a-zA-Z0-9_./-]+|\\s-\\s*$|\\b[^;&|]*\\|\\s*crontab\\b)") ||
e.command.command.matches("(?i)(^|[;&|(]\\s*|\\bsudo\\s+)\\s*crontab(\\s+-u\\s*[^\\s;&|]+)?\\s+[a-zA-Z0-9_./~][a-zA-Z0-9_./~-]*\\s*($|[;&|)])")
)) || (
e.event.action in ["file.modified", "file.created", "file.edited"] && (
e.file.path.matches("(?i)(^|/)etc/crontab$") ||
e.file.path.matches("(?i)(^|/)etc/cron\\.d/[^/]+$") ||
e.file.path.matches("(?i)(^|/)etc/cron\\.(hourly|daily|weekly|monthly)/[^/]+$") ||
e.file.path.matches("(?i)(^|/)var/spool/cron/[^/]+$")
)
)
emit:
reason: "Crontab modified (user crontab -e/-r, system /etc/cron.*, or spool) — persistence primitive"
tests:
- name: crontab_edit
verdict: match
events:
- event: { action: command.executed }
command: { command: "crontab -e" }
session: { id: s1 }
- name: crontab_load_from_file
verdict: match
events:
- event: { action: command.executed }
command: { command: "crontab /tmp/payload.cron" }
session: { id: s1 }
- name: crontab_load_then_cleanup
verdict: match
events:
- event: { action: command.executed }
command: { command: "crontab /tmp/payload.cron && rm /tmp/payload.cron" }
session: { id: s1 }
- name: crontab_load_from_home
verdict: match
events:
- event: { action: command.executed }
command: { command: "crontab ~/jobs.cron" }
session: { id: s1 }
- name: crontab_list_then_command
verdict: no_match
events:
- event: { action: command.executed }
command: { command: "crontab -l && echo done" }
session: { id: s1 }
- name: crontab_backup_then_command
verdict: no_match
events:
- event: { action: command.executed }
command: { command: "crontab -l > ~/crontab.bak && echo saved" }
session: { id: s1 }
- name: pipe_into_crontab
verdict: match
events:
- event: { action: command.executed }
command: { command: "echo '* * * * * /tmp/x.sh' | crontab -" }
session: { id: s1 }
- name: crontab_remove
verdict: match
events:
- event: { action: command.executed }
command: { command: "crontab -r" }
session: { id: s1 }
- name: write_etc_cron_d
verdict: match
events:
- event: { action: file.modified }
file: { path: "/etc/cron.d/agent-persist" }
session: { id: s1 }
- name: write_etc_cron_hourly
verdict: match
events:
- event: { action: file.modified }
file: { path: "/etc/cron.hourly/rotate" }
session: { id: s1 }
- name: write_var_spool_cron
verdict: match
events:
- event: { action: file.modified }
file: { path: "/var/spool/cron/root" }
session: { id: s1 }
- name: crontab_list_only
verdict: no_match
events:
- event: { action: command.executed }
command: { command: "crontab -l" }
session: { id: s1 }
- name: read_etc_crontab
verdict: no_match
events:
- event: { action: file.read }
file: { path: "/etc/crontab" }
session: { id: s1 }
- name: ordinary_shell_command
verdict: no_match
events:
- event: { action: command.executed }
command: { command: "echo hello world" }
session: { id: s1 }
- name: write_etc_cron_d_created
verdict: match
events:
- event: { action: file.created }
file: { path: "/etc/cron.d/agent-persist" }
session: { id: s1 }