Operator On The Wire
Join
← Back to Knowledge Base
BLUE TEAM / THREAT HUNT / LINUX / PERSISTENCE

Cron Persistence

This note documents detection patterns related to Cron Persistence on Linux systems.


Direct Indicators

SourceGrep Pattern / ArtifactMeaningForensic ValueNotes
/etc/crontabNew scheduled commandSystem-wide persistence entryCriticalPrimary cron persistence artifact.
/etc/cron.d/New cron fileDrop-in scheduled persistenceCriticalCommon stealth location.
/var/spool/cron/User cron entryPer-user persistenceCriticalOften tied to compromised account.
Shell historycrontab -eInteractive cron modificationCriticalStrong operator evidence.
Shell history`echo ...crontab`Inline cron insertionCritical
Shell history@rebootBoot-triggered persistenceCriticalVery high-value persistence signal.
Cron entrycurl, wgetRemote payload retrievalCriticalStrong malicious automation signal.
Cron entrybash, sh, pythonScripted executionCriticalCommon shell persistence pattern.
Cron entry/tmp, /dev/shmTemp payload executionCriticalHighly suspicious path.
auditdwrite to cron filesProcess-level persistence evidenceCriticalBest attribution if enabled.
File timestampsrecent cron modificationPersistence timing anchorCriticalCorrelates with intrusion window.
journalctlcron daemon executionScheduled execution traceHighUseful when execution already occurred.
SyslogCRON entriesJob execution recordsCriticalConfirms active trigger.
File ownership anomalyunexpected cron ownerHighCan reveal attacker mistakes.

Indirect Indicators

IndicatorWhat To Look ForForensic ValueNotes
Cron added after SSH successStabilization after footholdCriticalCommon attacker progression.
Cron under dormant accountHidden persistenceCriticalOften low-visibility tactic.
Frequent short interval jobEvery minute executionCriticalCommon beacon pattern.
Hidden script called by cronSecondary payload in temp/homeCriticalCommon staged persistence.
Cron runs downloader repeatedlyRe-fetch resilienceCriticalOperator durability pattern.
Root cron modified unexpectedlyPrivileged persistenceCriticalHigh severity.
Cron plus key/user creationMulti-layer persistenceCriticalStrong hostile sequence.
Commentless cron drop-in fileMinimalist attacker insertionHighOften manually dropped.
Cron file recent but no admin ticketContext anomalyHighImportant operational clue.
Cron executes deleted file pathCleanup attempt after persistenceHighIndicates incomplete cleanup.

Common Tools

ToolUsage
crontab -eInteractive cron editing.
`echo ...crontab`
Direct file edit/etc/crontab, /etc/cron.d/*.
sed -iSilent cron modification.
printf >>Append persistence line.

Relevant Artifacts

ArtifactPath / CommandForensic ValueNotes
System cron/etc/crontabCriticalMain system persistence file.
Cron drop-ins/etc/cron.d/CriticalVery common attacker location.
User cron/var/spool/cron/, /var/spool/cron/crontabs/CriticalPer-user persistence truth.
Periodic jobs/etc/cron.hourly, /etc/cron.daily, /etc/cron.weekly, /etc/cron.monthlyHighScript placement persistence.
Shell history.bash_history, .zsh_historyCriticalCron insertion commands.
Audit logs/var/log/audit/audit.logCriticalFile write attribution.
Syslog / auth logs/var/log/syslog, /var/log/cron, /var/log/messagesCriticalExecution evidence.
JournaldjournalctlHighCron execution visibility.
Script targetsreferenced file pathsCriticalOften actual payload location.

MITRE ATT&CK References

  • T1053 Scheduled Task or Job
  • T1053.003 Cron
  • T1059 Command and Scripting Interpreter

Decision Tree

  1. Is cron modified?

    • Enumerate system and user cron sources.
  2. Which account owns persistence?

    • Determine privilege and account legitimacy.
  3. What executes?

    • Inspect command, path, interpreter, interval.
  4. Has cron already executed?

    • Review syslog / journal execution traces.
  5. Is payload present?

    • Inspect referenced scripts/binaries.
  6. Pivot

    • Cron owner → login history.
    • Script path → payload analysis.
    • Timestamp → intrusion correlation.
  7. Confirm persistence

    • Unknown cron + suspicious command + intrusion timeline = malicious persistence.

Example Detection Templates

Grep

grep -R "@reboot\|curl\|wget\|bash\|python\|/tmp\|/dev/shm" /etc/crontab /etc/cron* /var/spool/cron 2>/dev/null
grep -R "crontab" /home/*/.bash_history /root/.bash_history 2>/dev/null
grep -R "echo .*crontab\|crontab -e" /home /root 2>/dev/null

Journalctl

journalctl | grep CRON

File Inspection

find /etc/cron* /var/spool/cron -type f -printf '%TY-%Tm-%Td %TT %p\n' 2>/dev/null | sort
stat /etc/crontab

Sigma

title: Linux Cron Persistence
id: linux-cron-persistence
status: experimental
description: Detects suspicious cron persistence entries and scheduled execution indicators
logsource:
  product: linux
detection:
  selection_keywords:
    message|contains:
      - 'CRON'
      - '@reboot'
      - 'curl'
      - 'wget'
  condition: selection_keywords
fields:
  - message
  - hostname
falsepositives:
  - Legitimate scheduled administration
level: high
tags:
  - attack.persistence
  - attack.t1053.003

Mitigation & Hardening

Control AreaMitigationEffectivenessNotes
Cron reviewBaseline all cron entriesCriticalUnknown jobs should stand out.
File monitoringWatch cron paths for writesCriticalExcellent invariant detection.
Least privilegeRestrict cron accessHighReduces persistence options.
AuditdTrack writes to cron locationsHighStrong attribution.
Temp execution controlPrevent temp payload executionHighBlocks common cron payloads.
LoggingPreserve cron execution logsHighNeeded to confirm runtime behavior.

Fast Triage Checks

QuestionCommand / ArtifactWhy It Matters
Any suspicious cron entries?grep cron filesImmediate persistence check.
Which user owns cron?inspect spool ownershipActor context.
Does cron call temp file?inspect pathsHigh-confidence suspicion.
Has cron executed?grep CRON logsConfirms active trigger.
Is payload still present?inspect target fileExecution target analysis.
Was cron added post-login?correlate timestampsIntrusion chain.

High Value Grep Strings

PatternWhy It Matters
@rebootBoot persistence.
curlRemote retrieval.
wgetRemote retrieval.
bashShell execution.
pythonInterpreter execution.
/tmpTemp payload path.
/dev/shmStealth temp path.
crontab -eInteractive modification.

Analyst Notes

ScenarioInterpretation
Every-minute cron + temp shellStrong beacon persistence.
Root cron modified recentlyHigh severity privileged persistence.
Cron calls deleted fileCleanup after persistence insertion likely.
User cron under fresh accountPersistence tied to compromise.
Cron plus downloaderResilient payload staging pattern.
Multiple cron layersOperator redundancy.