Skip to content

Commit 71dcc43

Browse files
Aegrahgithub-actions[bot]
authored andcommitted
[Rule Tuning] Q2 Linux DR Tuning - Part 6 (#4167)
(cherry picked from commit ac6a49e)
1 parent 2ec2b44 commit 71dcc43

6 files changed

+51
-38
lines changed

rules/linux/privilege_escalation_dac_permissions.toml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ integration = ["endpoint"]
44
maturity = "production"
55
min_stack_comments = "Linux effective and permitted process capability data sources were added in version 8.11.0"
66
min_stack_version = "8.11.0"
7-
updated_date = "2024/02/21"
7+
updated_date = "2024/10/17"
88

99
[rule]
1010
author = ["Elastic"]
@@ -60,7 +60,17 @@ type = "new_terms"
6060
query = '''
6161
event.category:process and host.os.type:linux and event.type:start and event.action:exec and
6262
(process.thread.capabilities.permitted:CAP_DAC_* or process.thread.capabilities.effective: CAP_DAC_*) and
63-
process.command_line:(*sudoers* or *passwd* or *shadow* or */root/*) and not user.id:"0"
63+
process.command_line:(*sudoers* or *passwd* or *shadow* or */root/*) and not (
64+
user.id : "0" or
65+
process.name : (
66+
"tar" or "getent" or "su" or "stat" or "dirname" or "chown" or "sudo" or "dpkg-split" or "dpkg-deb" or "dpkg" or
67+
"podman" or "awk" or "passwd" or "dpkg-maintscript-helper" or "mutt_dotlock" or "nscd" or "logger" or "gpasswd"
68+
) or
69+
process.executable : /usr/lib/*/lxc/rootfs/* or
70+
process.parent.name : (
71+
"dpkg" or "java" or *postinst or "dpkg-preconfigure" or "gnome-shell"
72+
)
73+
)
6474
'''
6575

6676
[[rule.threat]]
@@ -78,7 +88,7 @@ reference = "https://attack.mitre.org/tactics/TA0004/"
7888

7989
[rule.new_terms]
8090
field = "new_terms_fields"
81-
value = ["host.id", "process.command_line", "process.executable"]
91+
value = ["process.executable"]
8292

8393
[[rule.new_terms.history_window_start]]
8494
field = "history_window_start"

rules/linux/privilege_escalation_load_and_unload_of_kernel_via_kexec.toml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
creation_date = "2023/06/09"
33
integration = ["endpoint", "auditd_manager"]
44
maturity = "production"
5-
updated_date = "2024/05/21"
5+
updated_date = "2024/10/17"
66

77
[rule]
88
author = ["Elastic"]
@@ -64,57 +64,57 @@ tags = [
6464
]
6565
timestamp_override = "event.ingested"
6666
type = "eql"
67-
6867
query = '''
6968
process where host.os.type == "linux" and event.type == "start" and event.action in ("exec", "exec_event", "executed", "process_started")
70-
and process.name == "kexec" and process.args in ("--exec", "-e", "--load", "-l", "--unload", "-u")
69+
and process.name == "kexec" and process.args in ("--exec", "-e", "--load", "-l", "--unload", "-u") and not
70+
process.parent.name in ("kdumpctl", "unload.sh")
7171
'''
7272

73-
7473
[[rule.threat]]
7574
framework = "MITRE ATT&CK"
75+
7676
[[rule.threat.technique]]
7777
id = "T1611"
7878
name = "Escape to Host"
7979
reference = "https://attack.mitre.org/techniques/T1611/"
8080

81-
8281
[rule.threat.tactic]
8382
id = "TA0004"
8483
name = "Privilege Escalation"
8584
reference = "https://attack.mitre.org/tactics/TA0004/"
85+
8686
[[rule.threat]]
8787
framework = "MITRE ATT&CK"
88+
8889
[[rule.threat.technique]]
8990
id = "T1547"
9091
name = "Boot or Logon Autostart Execution"
9192
reference = "https://attack.mitre.org/techniques/T1547/"
93+
9294
[[rule.threat.technique.subtechnique]]
9395
id = "T1547.006"
9496
name = "Kernel Modules and Extensions"
9597
reference = "https://attack.mitre.org/techniques/T1547/006/"
9698

97-
98-
9999
[rule.threat.tactic]
100100
id = "TA0003"
101101
name = "Persistence"
102102
reference = "https://attack.mitre.org/tactics/TA0003/"
103+
103104
[[rule.threat]]
104105
framework = "MITRE ATT&CK"
106+
105107
[[rule.threat.technique]]
106108
id = "T1601"
107109
name = "Modify System Image"
108110
reference = "https://attack.mitre.org/techniques/T1601/"
111+
109112
[[rule.threat.technique.subtechnique]]
110113
id = "T1601.001"
111114
name = "Patch System Image"
112115
reference = "https://attack.mitre.org/techniques/T1601/001/"
113116

114-
115-
116117
[rule.threat.tactic]
117118
id = "TA0005"
118119
name = "Defense Evasion"
119120
reference = "https://attack.mitre.org/tactics/TA0005/"
120-

rules/linux/privilege_escalation_potential_suid_sgid_exploitation.toml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
creation_date = "2024/06/17"
33
integration = ["endpoint"]
44
maturity = "production"
5-
updated_date = "2024/09/23"
5+
updated_date = "2024/10/17"
66

77
[rule]
88
author = ["Elastic"]
@@ -59,7 +59,6 @@ tags = [
5959
]
6060
timestamp_override = "event.ingested"
6161
type = "eql"
62-
6362
query = '''
6463
process where host.os.type == "linux" and event.type == "start" and event.action == "exec" and (
6564
(process.user.id == "0" and process.real_user.id != "0") or
@@ -92,12 +91,12 @@ process where host.os.type == "linux" and event.type == "start" and event.action
9291
process.name == "ip" and (
9392
(process.args == "-force" and process.args in ("-batch", "-b")) or (process.args == "exec")
9493
)
95-
)
94+
) and not process.parent.name == "spine"
9695
'''
9796

98-
9997
[[rule.threat]]
10098
framework = "MITRE ATT&CK"
99+
101100
[[rule.threat.technique]]
102101
id = "T1068"
103102
name = "Exploitation for Privilege Escalation"
@@ -107,22 +106,21 @@ reference = "https://attack.mitre.org/techniques/T1068/"
107106
id = "T1548"
108107
name = "Abuse Elevation Control Mechanism"
109108
reference = "https://attack.mitre.org/techniques/T1548/"
109+
110110
[[rule.threat.technique.subtechnique]]
111111
id = "T1548.001"
112112
name = "Setuid and Setgid"
113113
reference = "https://attack.mitre.org/techniques/T1548/001/"
114114

115-
116-
117115
[rule.threat.tactic]
118116
id = "TA0004"
119117
name = "Privilege Escalation"
120118
reference = "https://attack.mitre.org/tactics/TA0004/"
119+
121120
[[rule.threat]]
122121
framework = "MITRE ATT&CK"
123122

124123
[rule.threat.tactic]
125124
id = "TA0003"
126125
name = "Persistence"
127126
reference = "https://attack.mitre.org/tactics/TA0003/"
128-

rules/linux/privilege_escalation_shadow_file_read.toml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
creation_date = "2022/09/01"
33
integration = ["endpoint"]
44
maturity = "production"
5-
updated_date = "2024/05/21"
5+
updated_date = "2024/10/17"
66

77
[rule]
88
author = ["Elastic"]
@@ -56,50 +56,50 @@ tags = [
5656
]
5757
timestamp_override = "event.ingested"
5858
type = "new_terms"
59-
6059
query = '''
6160
host.os.type : "linux" and event.category : "process" and event.action : ("exec" or "exec_event") and
62-
(process.args : "/etc/shadow" or (process.working_directory: "/etc" and process.args: "shadow")) and not
63-
(process.executable : ("/bin/chown" or "/usr/bin/chown") and process.args : "root:shadow") and not
64-
(process.executable : ("/bin/chmod" or "/usr/bin/chmod") and process.args : "640")
61+
(process.args : "/etc/shadow" or (process.working_directory: "/etc" and process.args: "shadow")) and not (
62+
(process.executable : ("/bin/chown" or "/usr/bin/chown") and process.args : "root:shadow") or
63+
(process.executable : ("/bin/chmod" or "/usr/bin/chmod") and process.args : "640") or
64+
process.executable:(/vz/* or /var/lib/docker/* or /run/containerd/* or /tmp/.criu* or /tmp/newroot/*) or
65+
process.parent.name:(gen_passwd_sets or scc_* or wazuh-modulesd)
66+
)
6567
'''
6668

67-
6869
[[rule.threat]]
6970
framework = "MITRE ATT&CK"
71+
7072
[[rule.threat.technique]]
7173
id = "T1068"
7274
name = "Exploitation for Privilege Escalation"
7375
reference = "https://attack.mitre.org/techniques/T1068/"
7476

75-
7677
[rule.threat.tactic]
7778
id = "TA0004"
7879
name = "Privilege Escalation"
7980
reference = "https://attack.mitre.org/tactics/TA0004/"
8081
[[rule.threat]]
8182
framework = "MITRE ATT&CK"
83+
8284
[[rule.threat.technique]]
8385
id = "T1003"
8486
name = "OS Credential Dumping"
8587
reference = "https://attack.mitre.org/techniques/T1003/"
88+
8689
[[rule.threat.technique.subtechnique]]
8790
id = "T1003.008"
8891
name = "/etc/passwd and /etc/shadow"
8992
reference = "https://attack.mitre.org/techniques/T1003/008/"
9093

91-
92-
9394
[rule.threat.tactic]
9495
id = "TA0006"
9596
name = "Credential Access"
9697
reference = "https://attack.mitre.org/tactics/TA0006/"
9798

9899
[rule.new_terms]
99100
field = "new_terms_fields"
100-
value = ["process.command_line", "host.id", "process.executable"]
101+
value = ["process.executable"]
102+
101103
[[rule.new_terms.history_window_start]]
102104
field = "history_window_start"
103105
value = "now-10d"
104-
105-

rules/linux/privilege_escalation_suspicious_uid_guid_elevation.toml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ integration = ["endpoint"]
44
maturity = "production"
55
min_stack_comments = "Linux effective and permitted process capability data sources were added in version 8.11.0"
66
min_stack_version = "8.11.0"
7-
updated_date = "2024/07/18"
7+
updated_date = "2024/10/17"
88

99
[rule]
1010
author = ["Elastic"]
@@ -64,12 +64,17 @@ sequence by host.id, process.entity_id with maxspan=1s
6464
process.parent.executable : ("/tmp/newroot/*", "/opt/carbonblack*") or
6565
process.parent.executable in (
6666
"/opt/SolarWinds/Agent/bin/Plugins/JobEngine/SolarWinds.Agent.JobEngine.Plugin", "/usr/bin/vmware-toolbox-cmd",
67-
"/usr/bin/dbus-daemon", "/usr/bin/update-notifier", "/usr/share/language-tools/language-options"
67+
"/usr/bin/dbus-daemon", "/usr/bin/update-notifier", "/usr/share/language-tools/language-options",
68+
"/opt/SolarWinds/Agent/*", "/usr/local/sbin/lynis.sh"
6869
) or
69-
process.executable : ("/opt/dynatrace/*", "/tmp/newroot/*") or
70+
process.executable : ("/opt/dynatrace/*", "/tmp/newroot/*", "/opt/SolarWinds/Agent/*") or
7071
process.executable in (
7172
"/bin/fgrep", "/usr/bin/sudo", "/usr/bin/pkexec", "/usr/lib/cockpit/cockpit-session", "/usr/sbin/suexec"
72-
)
73+
) or
74+
process.parent.name in ("update-notifier", "language-options", "osqueryd", "saposcol", "dbus-daemon", "osqueryi", "sdbrun") or
75+
process.command_line like ("sudo*BECOME-SUCCESS*", "/bin/sh*sapsysinfo.sh*", "sudo su", "sudo su -") or
76+
process.name == "sudo" or
77+
process.parent.command_line like "/usr/bin/python*ansible*"
7378
)]
7479
[process where host.os.type == "linux" and event.action == "uid_change" and event.type == "change" and
7580
(process.thread.capabilities.effective : "CAP_SET?ID" or process.thread.capabilities.permitted : "CAP_SET?ID")

rules/linux/privilege_escalation_uid_elevation_from_unknown_executable.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
creation_date = "2023/10/26"
33
integration = ["endpoint"]
44
maturity = "production"
5-
updated_date = "2024/07/18"
5+
updated_date = "2024/10/17"
66

77
[rule]
88
author = ["Elastic"]
@@ -64,7 +64,7 @@ and process.parent.name:("bash" or "dash" or "sh" or "tcsh" or "csh" or "zsh" or
6464
/opt/psa/admin/* or /usr/lib/snapd/snap-confine or /opt/dynatrace/* or /opt/microsoft/* or
6565
/var/lib/snapd/snap/bin/node or /opt/gitlab/embedded/sbin/logrotate or /etc/apt/universal-hooks/* or
6666
/opt/puppetlabs/puppet/bin/puppet or /opt/cisco/* or /run/k3s/containerd/* or /usr/lib/postfix/sbin/master or
67-
/usr/libexec/postfix/local
67+
/usr/libexec/postfix/local or /var/lib/snapd/snap/bin/postgresql* or /opt/puppetlabs/puppet/bin/ruby
6868
) or
6969
process.name:(
7070
"bash" or "dash" or "sh" or "tcsh" or "csh" or "zsh" or "ksh" or "fish" or "sudo" or "su" or "apt" or "apt-get" or

0 commit comments

Comments
 (0)