new(rules): detect security tool impairment in containers (T1562.001) - #367
new(rules): detect security tool impairment in containers (T1562.001)#367JayKnowSo wants to merge 3 commits into
Conversation
Signed-off-by: DevNow <worklife0524@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: JayKnowSo The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
leogr
left a comment
There was a problem hiding this comment.
Hey @JayKnowSo
Thanks for tackling this!
The bulk of my feedback is around substring-matching precision and a couple of output-template alignments, see inline 👇
Otherwise, SGMT.
🙏
| (proc.name = systemctl and proc.args contains "stop" and | ||
| (proc.args contains "falco" or proc.args contains "auditd" or | ||
| proc.args contains "sysdig" or proc.args contains "osquery")) | ||
| or | ||
| (proc.name = service and proc.args contains "stop" and | ||
| (proc.args contains "falco" or proc.args contains "auditd")) |
There was a problem hiding this comment.
| (proc.name = systemctl and proc.args contains "stop" and | |
| (proc.args contains "falco" or proc.args contains "auditd" or | |
| proc.args contains "sysdig" or proc.args contains "osquery")) | |
| or | |
| (proc.name = service and proc.args contains "stop" and | |
| (proc.args contains "falco" or proc.args contains "auditd")) | |
| (proc.name = systemctl and | |
| (proc.args startswith "stop " or proc.args contains " stop ") and | |
| (proc.args contains " falco" or proc.args contains " auditd" or | |
| proc.args contains " sysdig" or proc.args contains " osquery")) | |
| or | |
| (proc.name = service and | |
| (proc.args startswith "falco " or proc.args startswith "auditd ") and | |
| (proc.args endswith " stop" or proc.args contains " stop ")) |
The current proc.args contains "stop" and (proc.args contains "falco" or ...) is an unanchored substring search on the full joined args. Both substrings just have to appear anywhere in the string, so the rule can fire on:
systemctl status mystop.service(if"falco"happens to appear elsewhere, e.g., in an env var path the args carry)systemctl reload falco-helper-stopwatch.service(verb isreload, but bothstopandfalcosubstrings match)
Our convention for short-token matching is whitespace anchoring, see the netcat rule at falco_rules.yaml:849-851 (proc.args contains "-e ", etc.). The suggestion above anchors both the verb and the daemon name with leading/trailing whitespace, matching realistic usage like systemctl stop falco, systemctl --no-block stop falco, service falco stop while rejecting the substring-noise cases.
| (proc.name in (iptables, ip6tables) and | ||
| (proc.args contains "-F" or proc.args contains "--flush" or | ||
| proc.args contains "-X" or proc.args contains "--delete-chain")) |
There was a problem hiding this comment.
| (proc.name in (iptables, ip6tables) and | |
| (proc.args contains "-F" or proc.args contains "--flush" or | |
| proc.args contains "-X" or proc.args contains "--delete-chain")) | |
| (proc.name in (iptables, ip6tables) and | |
| (proc.args startswith "-F" or proc.args startswith "--flush" or | |
| proc.args startswith "-X" or proc.args startswith "--delete-chain" or | |
| proc.args contains " -F" or proc.args contains " --flush" or | |
| proc.args contains " -X" or proc.args contains " --delete-chain")) |
Same precision concern as the systemctl block. proc.args contains "-F" matches the substring -F anywhere in the args, including inside chain names or comment text. Combining startswith for first-position flags with contains " -F" (leading space) for later positions covers both placements while staying anchored to whitespace boundaries - same pattern as falco_rules.yaml:849-851 and falco-incubating_rules.yaml:1162-1165.
Co-authored-by: Leonardo Grasso <me@leonardograsso.com> Signed-off-by: JayKnowSo <self_realized_god@proton.me>
Co-authored-by: Leonardo Grasso <me@leonardograsso.com> Signed-off-by: JayKnowSo <self_realized_god@proton.me>
|
Addressed the yamllint The remaining CI failures are pre-existing violations in |
| (proc.name in (iptables, ip6tables) and | ||
| (proc.args contains "-F" or proc.args contains "--flush" or | ||
| proc.args contains "-X" or proc.args contains "--delete-chain")) |
There was a problem hiding this comment.
| (proc.name in (iptables, ip6tables) and | |
| (proc.args contains "-F" or proc.args contains "--flush" or | |
| proc.args contains "-X" or proc.args contains "--delete-chain")) | |
| (proc.name in (iptables, ip6tables) and | |
| (proc.args startswith "-F" or proc.args contains " -F" or | |
| proc.args startswith "-X" or proc.args contains " -X" or | |
| proc.args contains "--flush" or proc.args contains "--delete-chain")) |
I have dug a bit more into this since my previous round, and it is worse than I described back then.
proc.args contains "-F" is an unanchored substring search, so it also matches any chain name containing -F. Those are everywhere in container networking:
iptables -A KUBE-FORWARD ...(kube-proxy) 👉KUBE-FORWARDcontains-Fiptables -N KUBE-FIREWALL(kubelet) 👉KUBE-FIREWALLcontains-Fiptables -A cali-FORWARD ...(Calico) 👉 same story
-X has the same problem with the KUBE-SVC-<hash> / KUBE-SEP-<hash> chains, since the base32 hash can start with X.
So, as written, the rule fires on routine CNI and kube-proxy activity in pretty much any Kubernetes cluster.
The suggestion anchors the short flags on a whitespace boundary (startswith for the first position, contains " -F" for the later ones). That is the convention we already use elsewhere, see Netcat Remote Code Execution in Container in falco_rules.yaml (proc.cmdline contains " -e") and the curl_download macro further down in this same file. --flush and --delete-chain are long enough to be unambiguous, so plain contains is fine for them.
| (proc.name = systemctl and proc.args contains "stop" and | ||
| (proc.args contains "falco" or proc.args contains "auditd" or | ||
| proc.args contains "sysdig" or proc.args contains "osquery")) | ||
| or | ||
| (proc.name = service and proc.args contains "stop" and | ||
| (proc.args contains "falco" or proc.args contains "auditd")) |
There was a problem hiding this comment.
| (proc.name = systemctl and proc.args contains "stop" and | |
| (proc.args contains "falco" or proc.args contains "auditd" or | |
| proc.args contains "sysdig" or proc.args contains "osquery")) | |
| or | |
| (proc.name = service and proc.args contains "stop" and | |
| (proc.args contains "falco" or proc.args contains "auditd")) | |
| (proc.name = systemctl and | |
| (proc.args startswith "stop " or proc.args contains " stop ") and | |
| (proc.args contains "falco" or proc.args contains "auditd" or | |
| proc.args contains "sysdig" or proc.args contains "osquery")) | |
| or | |
| (proc.name = service and | |
| (proc.args endswith " stop" or proc.args contains " stop ") and | |
| (proc.args startswith "falco" or proc.args startswith "auditd")) |
Same anchoring concern as above, milder here since both substrings have to match.
proc.args contains "stop" matches the verb anywhere in the args, so read-only queries like systemctl list-units --state=stopped 'falco*' fire too, since stopped contains stop. Anchoring on whitespace keeps systemctl stop falco and systemctl --no-block stop falco while dropping that class.
For service, the SysV syntax is service <unit> <verb> (i.e., service falco stop), so endswith " stop" is the natural anchor there.
Btw, systemctl disable and systemctl mask are arguably stronger signals than stop, since they survive a reboot. Not asking for it in this PR, just something we may want to add later 😇
| # when more than one event type is involved because some event will populate | ||
| # the filtercheck and others will always return <NA>. It would be better to use | ||
| # a more generic filter like `fs.path.*` | ||
| - macro: user_known_security_tool_disable_activities |
There was a problem hiding this comment.
May you move the new macro and rule below the Delete or rename shell history rule?
The # todo!: block right above belongs to that rule - it is about avoiding evt.arg* in the output when a rule spans more than one event type. Inserting here re-parents the comment to your macro, which is quite confusing, since your rule is spawned_process-only and exe_flags=%evt.arg.flags is exactly the right thing to have there.
| priority: | ||
| WARNING |
There was a problem hiding this comment.
| priority: | |
| WARNING | |
| priority: WARNING |
Nit. 27 of the 31 existing rules in this file keep priority inline. The rule right below happens to be one of the 4 exceptions, so it is an easy one to pick up by accident.
Summary
Adds a detection rule for MITRE ATT&CK T1562.001 (Impair Defenses: Disable or Modify Tools) scoped to container workloads.
What this detects
iptables/ip6tablesflush or delete-chain commands inside a containersystemctl stoptargeting security daemons (falco, auditd, sysdig, osquery)service stoptargeting falco or auditdWhy this matters
T1562 was the most prevalent defense evasion technique in malware campaigns in 2025. After achieving initial execution in a container (T1059), adversaries commonly disable runtime security tooling before lateral movement. No existing rule in stable, incubating, or sandbox tiers covers this technique for container workloads.
MITRE ATT&CK
https://attack.mitre.org/techniques/T1562/001/
False positives
Tunable via
user_known_security_tool_disable_activitiesmacro. Legitimate iptables usage in containers is rare and should be explicitly allowlisted.Testing
Rule fires on:
iptables -F,systemctl stop falco,service stop auditdexecuted inside a running container.