- Tactics
- Persistence, Privilege Escalation
- Platforms
- macOS, Linux
- Version
- 1.1
- Created
- 24 January 2020
- Last modified
- 24 October 2025
Adversaries may establish persistence by executing malicious content triggered by an interrupt signal. The trap command allows programs and shells to specify commands that will be executed upon receiving interrupt signals. A common situation is a script allowing for graceful termination and handling of common keyboard interrupts like ctrl+c and ctrl+d.
Offense vs defense T1546.005
Is defensive coverage keeping up with adversary use? Eight counts, each ranked against all 697 ATT&CK techniques. Attack sits left, defense right, so a shape leaning left means adversaries are better documented here than defenders are equipped. Hover any spoke for its percentile and the share of techniques that have more. The timeline below shows when each side arrived.
Trap detection strategy DET0369
MITRE names one behaviour worth catching for this technique and breaks it into 2 analytics, one per platform. Each carries the log sources it needs and the fields you tune per environment.
Detection Strategy for Event Triggered Execution via Trap (T1546.005)
AN1038 · Linux
Correlate file modifications in shell startup scripts (e.g., .bashrc, .profile) with embedded trap commands and observe if those changes are followed by the unexpected execution of child processes when terminal signals (e.g., SIGINT) are triggered. Use contextual linking with user session activity to detect privilege misuse.
Log sources
The data this analytic draws on. You do not need every component — each one you already collect covers part of it. Each links to its ATT&CK record.
| Data component | Name | Channel |
|---|---|---|
| Process CreationDC0032 | auditd:SYSCALL | execve |
| File AccessDC0055 | auditd:SYSCALL | open |
| File ModificationDC0061 | auditd:SYSCALL | Modification of user shell profile or trap registration via echo/redirection (e.g., echo "trap 'malicious_cmd' INT" >> ~/.bashrc) |
Tunable fields
MITRE calls these the analytic’s mutable elements: the thresholds and filters you set for your own environment.
| Field | What you tune |
|---|---|
| TargetShellFilePath | The path to user profile scripts (e.g., ~/.bashrc, ~/.zshrc); may differ by distro or shell type. |
| SignalTrapName | Trap signal (e.g., INT, HUP, TERM) can be environment-specific or attacker-tuned to evade. |
| TimeWindow | Temporal threshold to correlate trap insertion and process execution (e.g., 10s-5min) |
AN1039 · macOS
Detect unauthorized trap command registrations in shell startup files (e.g., .zprofile, .bash_profile, .zshrc) followed by execution chains during user terminal interaction. Use Unified Logs and EDR telemetry to correlate shell command parsing and process tree anomalies.
Log sources
The data this analytic draws on. You do not need every component — each one you already collect covers part of it. Each links to its ATT&CK record.
| Data component | Name | Channel |
|---|---|---|
| Process CreationDC0032 | macos:unifiedlog | Command line containing `trap` or `echo 'trap` written to login shell files |
| File ModificationDC0061 | macos:unifiedlog | File write or append to .zshrc, .bash_profile, .zprofile, etc. |
Tunable fields
MITRE calls these the analytic’s mutable elements: the thresholds and filters you set for your own environment.
| Field | What you tune |
|---|---|
| LoginShellConfigPaths | Startup files vary by shell (.bash_profile, .zshrc, etc.) |
| TrapCommandLengthThreshold | Short benign traps may differ from longer/multi-command malicious traps |
| ParentProcessAnomalyThreshold | Score or detect if new child process deviates from shell’s typical behavior |
Tests from Atomic Red Team (MIT licence) · technique definition