Trap command written into a shell startup file
Matches a Linux process whose command line registers a `trap` handler and names a shell startup file in the same invocation — the shape a one-liner takes when it appends `trap 'payload' INT` to ~/.bashrc, whether written with `bash -c`, `sed -i`, `perl -pi -e` or `tee`. The gate is the command line alone and not the `Image`, because the write is performed by whatever tool the operator reached for, and on auditd execve the recorded binary is the interpreter rather than the wrapper. Note two limits, both of which belong to the telemetry rather than to the logic: `trap` and `echo` are shell builtins, so a handler typed at an interactive prompt and redirected into a dotfile produces no execve at all and cannot be seen here; and AN1038's second half — correlating the insertion with a child process spawned when SIGINT later fires — is a join across two events that Sigma has no operator for, so only the insertion is covered. auditd does not record execve out of the box, so this rule is blind until an audit rule such as `-a always,exit -F arch=b64 -S execve` is loaded; zero matches without it means unmonitored, not clean. macOS (AN1039) is out of scope: its unified-log fields are not standardised in Sigma. UNVERIFIED AS AUTHORED — derived from MITRE ATT&CK DET0369, not hand-written and not tested by its author. Any lab result is on this rule's own page.Full descriptionShow less
The detection
The 4 SIEM queries below are previews produced by Siemphony’s own translator, not pySigma, and none has been executed against a real backend — review before you deploy.
detection.yml
Sentinel · KQL
Run this as a search.
DeviceProcessEvents| where (ProcessCommandLine contains "trap " and (ProcessCommandLine contains ".bashrc" or ProcessCommandLine contains ".bash_profile" or ProcessCommandLine contains ".bash_login" or ProcessCommandLine contains ".profile" or ProcessCommandLine contains ".zshrc" or ProcessCommandLine contains ".zprofile" or ProcessCommandLine contains ".zlogin" or ProcessCommandLine contains "/etc/profile" or ProcessCommandLine contains "/etc/bash.bashrc"))
Splunk · SPL
Run this as a search.
index=* (CommandLine="*trap *" AND (CommandLine="*.bashrc*" OR CommandLine="*.bash_profile*" OR CommandLine="*.bash_login*" OR CommandLine="*.profile*" OR CommandLine="*.zshrc*" OR CommandLine="*.zprofile*" OR CommandLine="*.zlogin*" OR CommandLine="*/etc/profile*" OR CommandLine="*/etc/bash.bashrc*"))Elastic · ES|QL
Run this as a search.
FROM logs-*| WHERE (TO_LOWER(process.command_line) LIKE "*trap *" AND (TO_LOWER(process.command_line) LIKE "*.bashrc*" OR TO_LOWER(process.command_line) LIKE "*.bash_profile*" OR TO_LOWER(process.command_line) LIKE "*.bash_login*" OR TO_LOWER(process.command_line) LIKE "*.profile*" OR TO_LOWER(process.command_line) LIKE "*.zshrc*" OR TO_LOWER(process.command_line) LIKE "*.zprofile*" OR TO_LOWER(process.command_line) LIKE "*.zlogin*" OR TO_LOWER(process.command_line) LIKE "*/etc/profile*" OR TO_LOWER(process.command_line) LIKE "*/etc/bash.bashrc*"))
Wazuh · XML rule
Deploy to your manager — this is a rule, not a search.
<group name="sigma,linux,process_creation,"> <!-- Rule ids must be unique on your manager; 100000+ is the user range. --> <rule id="100000" level="5"> <!-- Set <if_sid> to the decoder/base rule for linux so this only evaluates relevant events. --> <field name="CommandLine" type="pcre2">(?i)trap </field> <field name="CommandLine" type="pcre2">(?i)(\.bashrc|\.bash_profile|\.bash_login|\.profile|\.zshrc|\.zprofile|\.zlogin|/etc/profile|/etc/bash\.bashrc)</field> <description>Trap command written into a shell startup file</description> <mitre> <id>T1546.005</id> </mitre> </rule></group>
Verdicts · reactions · comments
Community
Verdicts from engineers who actually deployed it, and the conversation around it.
Nobody has run this in a real environment and said what happened.
Verdicts from engineers who deployed it
0 castNo verdicts reported yet. The first one is worth more than the tenth — say what you ran it against.
Log in to report a verdict.
Log in to join the discussion.
No comments yet. Someone who deploys this will have something to say about it.