Skip to content

Commit

Permalink
Merge branch 'main' into rule-tuning-aws-december-2024
Browse files Browse the repository at this point in the history
  • Loading branch information
terrancedejesus authored Jan 29, 2025
2 parents c25b23e + 18dd9cb commit 46b4ead
Show file tree
Hide file tree
Showing 14 changed files with 162 additions and 27 deletions.
7 changes: 5 additions & 2 deletions rules/linux/defense_evasion_dynamic_linker_file_creation.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
creation_date = "2024/08/08"
integration = ["endpoint"]
maturity = "production"
updated_date = "2025/01/15"
updated_date = "2025/01/24"

[rule]
author = ["Elastic"]
Expand Down Expand Up @@ -76,7 +76,10 @@ not (
"/nix/store/*", "/var/lib/dpkg/*", "/snap/*", "/dev/fd/*", "/usr/lib/virtualbox/*", "/opt/dynatrace/oneagent/*"
) or
process.executable == null or
process.name == "java" or
process.name in (
"java", "executor", "ssm-agent-worker", "packagekitd", "crio", "dockerd-entrypoint.sh",
"docker-init", "BootTimeChecker"
) or
(process.name == "sed" and file.name : "sed*") or
(process.name == "perl" and file.name : "e2scrub_all.tmp*")
)
Expand Down
6 changes: 4 additions & 2 deletions rules/linux/defense_evasion_file_mod_writable_dir.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
creation_date = "2020/04/21"
integration = ["endpoint"]
maturity = "production"
updated_date = "2025/01/15"
updated_date = "2025/01/24"

[rule]
author = ["Elastic"]
Expand Down Expand Up @@ -75,7 +75,9 @@ type = "new_terms"
query = '''
host.os.type:linux and event.category:process and event.type:start and
process.name:(chattr or chgrp or chmod or chown) and process.working_directory:(/dev/shm or /tmp or /var/tmp) and
not process.parent.name:(apt-key or update-motd-updates-available or apt-get)
not process.parent.name:(
apt-key or update-motd-updates-available or apt-get or java or pilot or PassengerAgent or nginx
)
'''
note = """## Triage and analysis
Expand Down
5 changes: 3 additions & 2 deletions rules/linux/defense_evasion_hidden_directory_creation.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ integration = ["endpoint", "sentinel_one_cloud_funnel"]
maturity = "production"
min_stack_version = "8.13.0"
min_stack_comments = "Breaking change at 8.13.0 for SentinelOne Integration."
updated_date = "2025/01/15"
updated_date = "2025/01/24"

[rule]
author = ["Elastic"]
Expand Down Expand Up @@ -72,8 +72,9 @@ process.name == "mkdir" and process.parent.executable like (
) and process.args like (".*", "/*/.*") and process.args_count <= 3 and not (
process.parent.executable like ("/tmp/newroot/*", "/run/containerd/*") or
process.command_line like ("mkdir -p .", "mkdir ./*") or
process.args == "/root/.ssh" or
process.parent.executable like (
"/tmp/pear/temp/*", "/var/tmp/buildah*", "/tmp/python-build.*", "/tmp/cliphist-wofi-img"
"/tmp/pear/temp/*", "/var/tmp/buildah*", "/tmp/python-build.*", "/tmp/cliphist-wofi-img", "/tmp/snap.rootfs_*"
)
)
'''
Expand Down
4 changes: 2 additions & 2 deletions rules/linux/defense_evasion_hidden_file_dir_tmp.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
creation_date = "2020/04/29"
integration = ["endpoint"]
maturity = "production"
updated_date = "2025/01/15"
updated_date = "2025/01/24"

[rule]
author = ["Elastic"]
Expand Down Expand Up @@ -82,7 +82,7 @@ process.working_directory in ("/tmp", "/var/tmp", "/dev/shm") and
process.args regex~ """\.[a-z0-9_\-][a-z0-9_\-\.]{1,254}""" and
not process.name in (
"ls", "find", "grep", "git", "jq", "basename", "check_snmp", "snmpget", "snmpwalk", "cc1plus", "snap",
"command-not-found"
"command-not-found", "sqlite", "apk", "fgrep", "locate", "objdump"
)
'''
note = """## Triage and analysis
Expand Down
4 changes: 2 additions & 2 deletions rules/linux/defense_evasion_hidden_shared_object.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ integration = ["endpoint", "sentinel_one_cloud_funnel"]
maturity = "production"
min_stack_comments = "Breaking change at 8.13.0 for SentinelOne Integration."
min_stack_version = "8.13.0"
updated_date = "2025/01/15"
updated_date = "2025/01/24"

[rule]
author = ["Elastic"]
Expand Down Expand Up @@ -77,7 +77,7 @@ type = "eql"

query = '''
file where host.os.type == "linux" and event.type == "creation" and file.extension == "so" and file.name : ".*.so" and
not process.name == "dockerd"
not process.name in ("dockerd", "azcopy", "podman")
'''
note = """## Triage and analysis
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
creation_date = "2024/11/04"
integration = ["endpoint"]
maturity = "production"
updated_date = "2025/01/15"
updated_date = "2025/01/24"

[rule]
author = ["Elastic"]
Expand Down Expand Up @@ -67,6 +67,8 @@ event.category:process and host.os.type:linux and event.type:start and event.act
) or
process.args:(/etc/apt/trusted.gpg.d/* or /tmp/apt-key-gpg*) or
process.name:(awk or apt-config or dpkg or grep or gpgv or sed) or
(user.name:_apt and process.name:(sqv or apt-key or gpgconf or sort or mktemp or find or cmp or gpg-connect-agent)) or
(user.name:man and process.name:mandb) or
(user.name:daemon and process.name:at)
)
'''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ integration = ["endpoint", "sentinel_one_cloud_funnel"]
maturity = "production"
min_stack_version = "8.13.0"
min_stack_comments = "Breaking change at 8.13.0 for SentinelOne Integration."
updated_date = "2025/01/15"
updated_date = "2025/01/24"

[rule]
author = ["Elastic"]
Expand Down Expand Up @@ -65,7 +65,7 @@ process where host.os.type == "linux" and event.type == "start" and event.action
process.name in ("update-ca-trust", "update-ca-certificates") and not (
process.parent.name like (
"ca-certificates.postinst", "ca-certificates-*.trigger", "pacman", "pamac-daemon", "autofirma.postinst",
"ipa-client-install", "su", "platform-python", "python*", "kesl", "execd"
"ipa-client-install", "su", "platform-python", "python*", "kesl", "execd", "systemd", "flock"
) or
process.parent.args like "/var/tmp/rpm*" or
(process.parent.name in ("sh", "bash", "zsh") and process.args == "-e")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ integration = ["endpoint", "sentinel_one_cloud_funnel"]
maturity = "production"
min_stack_comments = "Breaking change at 8.16.2 for the SentinelOne Integration."
min_stack_version = "8.16.2"
updated_date = "2025/01/15"
updated_date = "2025/01/24"

[rule]
author = ["Elastic"]
Expand Down Expand Up @@ -61,7 +61,7 @@ timestamp_override = "event.ingested"
type = "eql"
query = '''
file where host.os.type == "linux" and event.action in ("creation", "file_create_event", "rename", "file_rename_event")
and file.path : "/etc/selinux/config"
and file.path : "/etc/selinux/config" and not process.name in ("dockerd", "platform-python")
'''
note = """## Triage and analysis
Expand Down
7 changes: 4 additions & 3 deletions rules/linux/discovery_kernel_module_enumeration.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
creation_date = "2020/04/23"
integration = ["endpoint"]
maturity = "production"
updated_date = "2025/01/15"
updated_date = "2025/01/24"

[rule]
author = ["Elastic"]
Expand Down Expand Up @@ -72,8 +72,9 @@ not (
process.parent.name:(
mkinitramfs or cryptroot or framebuffer or dracut or jem or thin-provisioning-tools or readykernel or lvm2 or
vz-start or iscsi or mdadm or ovalprobes or bcache or plymouth or dkms or overlayroot or weak-modules or zfs or
systemd or whoopsie-upload-all or kdumpctl or apport-gtk or casper or rear or kernel-install
)
systemd or whoopsie-upload-all or kdumpctl or apport-gtk or casper or rear or kernel-install or newrelic-infra
) or
process.parent.executable:/var/lib/dpkg/info/linux-modules*-generic.post*
)
'''
note = """## Triage and analysis
Expand Down
7 changes: 4 additions & 3 deletions rules/linux/discovery_pam_version_discovery.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ integration = ["endpoint", "crowdstrike", "sentinel_one_cloud_funnel"]
maturity = "production"
min_stack_version = "8.13.0"
min_stack_comments = "Breaking change at 8.13.0 for SentinelOne Integration."
updated_date = "2025/01/15"
updated_date = "2025/01/24"

[rule]
author = ["Elastic"]
Expand Down Expand Up @@ -66,11 +66,12 @@ timestamp_override = "event.ingested"
type = "eql"
query = '''
process where host.os.type == "linux" and event.type == "start" and
event.action in ("exec", "exec_event", "start", "ProcessRollup2") and
event.action in ("exec", "exec_event", "start", "ProcessRollup2") and process.parent.name != null and
(
(process.name in ("dpkg", "dpkg-query") and process.args == "libpam-modules") or
(process.name == "rpm" and process.args == "pam")
)
) and
not process.parent.name in ("dcservice", "inspectorssmplugin")
'''
note = """## Triage and analysis
Expand Down
4 changes: 2 additions & 2 deletions rules/linux/discovery_pspy_process_monitoring_detected.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
creation_date = "2023/07/20"
integration = ["auditd_manager"]
maturity = "production"
updated_date = "2025/01/15"
updated_date = "2025/01/24"

[rule]
author = ["Elastic"]
Expand Down Expand Up @@ -58,7 +58,7 @@ query = '''
sequence by process.pid, host.id with maxspan=5s
[file where host.os.type == "linux" and auditd.data.syscall == "openat" and file.path == "/proc" and
auditd.data.a0 : ("ffffffffffffff9c", "ffffff9c") and auditd.data.a2 : ("80000", "88000") and
not process.name == "agentbeat"
not process.name in ("agentbeat", "packetbeat")
] with runs=10
'''
note = """## Triage and analysis
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ integration = ["endpoint", "crowdstrike", "sentinel_one_cloud_funnel"]
maturity = "production"
min_stack_version = "8.13.0"
min_stack_comments = "Breaking change at 8.13.0 for SentinelOne Integration."
updated_date = "2025/01/15"
updated_date = "2025/01/24"

[rule]
author = ["Elastic"]
Expand Down Expand Up @@ -68,7 +68,8 @@ process where host.os.type == "linux" and event.type == "start" and
"/home/*/.aws/credentials", "/home/*/.aws/config", "/home/*/.config/gcloud/*credentials.json",
"/home/*/.config/gcloud/configurations/config_default", "/home/*/.azure/accessTokens.json",
"/home/*/.azure/azureProfile.json"
)
) and
not process.parent.name in ("wazuh-modulesd", "lynis")
'''
note = """## Triage and analysis
Expand Down
7 changes: 5 additions & 2 deletions rules/linux/discovery_unusual_user_enumeration_via_id.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
creation_date = "2023/08/29"
integration = ["endpoint"]
maturity = "production"
updated_date = "2025/01/15"
updated_date = "2025/01/24"

[rule]
author = ["Elastic"]
Expand Down Expand Up @@ -58,7 +58,10 @@ query = '''
sequence by host.id, process.parent.entity_id with maxspan=1s
[process where host.os.type == "linux" and event.type == "start" and event.action == "exec" and
process.name == "id" and process.args_count == 2 and
not (process.parent.name == "rpm" or process.parent.args : "/var/tmp/rpm-tmp*")] with runs=20
not (
process.parent.name in ("rpm", "snarftmp", "quota_copy", "java") or
process.parent.args : "/var/tmp/rpm-tmp*"
)] with runs=20
'''
note = """## Triage and analysis
Expand Down
121 changes: 121 additions & 0 deletions rules/linux/persistence_bpf_probe_write_user.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
[metadata]
creation_date = "2025/01/28"
integration = ["system"]
maturity = "production"
updated_date = "2025/01/28"

[rule]
author = ["Elastic"]
description = """
This rule monitors the syslog log file for messages related to instances of a program using the `bpf_probe_write_user` helper.
The `bpf_probe_write_user` helper is used to write data to user space from a BPF program. Unauthorized use of this helper can
be indicative of an eBPF rootkit or other malicious activity.
"""
from = "now-9m"
index = ["logs-system.syslog-*"]
language = "kuery"
license = "Elastic License v2"
name = "Suspicious Usage of bpf_probe_write_user Helper"
note = """## Triage and analysis
> **Disclaimer**:
> This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs.
### Investigating Suspicious Usage of bpf_probe_write_user Helper
The `bpf_probe_write_user` helper is a function within the eBPF (extended Berkeley Packet Filter) framework, allowing BPF programs to write data to user space. While useful for legitimate monitoring and debugging, adversaries can exploit it to manipulate user space memory, potentially deploying rootkits or evading defenses. The detection rule monitors syslog entries for kernel processes invoking this helper, flagging potential unauthorized use indicative of malicious activity.
### Possible investigation steps
- Review the syslog entries for the specific message "bpf_probe_write_user" to identify the exact time and context of the event.
- Correlate the timestamp of the alert with other logs and system activities to identify any unusual behavior or patterns around the same time.
- Investigate the process details associated with the kernel at the time of the alert to determine if there are any anomalies or unauthorized modifications.
- Check for any recent changes or installations on the system that could have introduced unauthorized BPF programs.
- Assess the system for signs of persistence mechanisms or defense evasion tactics, as indicated by the MITRE ATT&CK framework references.
- Conduct a thorough review of user accounts and permissions to ensure no unauthorized access or privilege escalation has occurred.
- If suspicious activity is confirmed, isolate the affected system and perform a comprehensive forensic analysis to understand the scope and impact of the potential compromise.
### False positive analysis
- Legitimate monitoring tools may use the bpf_probe_write_user helper for debugging purposes. Identify and whitelist these tools by verifying their source and ensuring they are part of authorized software packages.
- Kernel developers and system administrators might use this helper during system diagnostics or performance tuning. Establish a baseline of expected usage patterns and create exceptions for known maintenance activities.
- Automated scripts or system processes that perform regular system checks could trigger this rule. Review the scripts and processes to confirm their legitimacy and exclude them from alerts if they are verified as safe.
- Security software or intrusion detection systems might utilize this helper as part of their normal operations. Coordinate with your security team to recognize these activities and adjust the rule to prevent unnecessary alerts.
### Response and remediation
- Immediately isolate the affected system from the network to prevent further unauthorized access or data manipulation.
- Terminate any suspicious processes associated with the `bpf_probe_write_user` helper to halt potential malicious activity.
- Conduct a thorough review of recent system changes and installed software to identify unauthorized modifications or installations.
- Restore affected systems from a known good backup to ensure the integrity of user space memory and system files.
- Implement stricter access controls and monitoring on systems with eBPF capabilities to prevent unauthorized use of the `bpf_probe_write_user` helper.
- Escalate the incident to the security operations team for further analysis and to determine if additional systems are affected.
- Update detection mechanisms to include additional indicators of compromise related to eBPF rootkits and similar threats, enhancing future threat detection capabilities.
"""
risk_score = 21
rule_id = "c37ffc64-da75-447e-ad1c-cbc64727b3b8"
setup = """## Setup
This rule requires data coming in from one of the following integrations:
- Filebeat
### Filebeat Setup
Filebeat is a lightweight shipper for forwarding and centralizing log data. Installed as an agent on your servers, Filebeat monitors the log files or locations that you specify, collects log events, and forwards them either to Elasticsearch or Logstash for indexing.
#### The following steps should be executed in order to add the Filebeat for the Linux System:
- Elastic provides repositories available for APT and YUM-based distributions. Note that we provide binary packages, but no source packages.
- To install the APT and YUM repositories follow the setup instructions in this [helper guide](https://www.elastic.co/guide/en/beats/filebeat/current/setup-repositories.html).
- To run Filebeat on Docker follow the setup instructions in the [helper guide](https://www.elastic.co/guide/en/beats/filebeat/current/running-on-docker.html).
- To run Filebeat on Kubernetes follow the setup instructions in the [helper guide](https://www.elastic.co/guide/en/beats/filebeat/current/running-on-kubernetes.html).
- For quick start information for Filebeat refer to the [helper guide](https://www.elastic.co/guide/en/beats/filebeat/8.11/filebeat-installation-configuration.html).
- For complete Setup and Run Filebeat information refer to the [helper guide](https://www.elastic.co/guide/en/beats/filebeat/current/setting-up-and-running.html).
#### Rule Specific Setup Note
- This rule requires the Filebeat System Module to be enabled.
- The system module collects and parses logs created by the system logging service of common Unix/Linux based distributions.
- To run the system module of Filebeat on Linux follow the setup instructions in the [helper guide](https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-module-system.html).
"""
severity = "low"
tags = [
"Domain: Endpoint",
"OS: Linux",
"Use Case: Threat Detection",
"Tactic: Persistence",
"Tactic: Defense Evasion",
"Resources: Investigation Guide",
]
timestamp_override = "event.ingested"
type = "query"
query = '''
host.os.type:linux and event.dataset:"system.syslog" and process.name:kernel and message:"bpf_probe_write_user"
'''

[[rule.threat]]
framework = "MITRE ATT&CK"

[[rule.threat.technique]]
id = "T1547"
name = "Boot or Logon Autostart Execution"
reference = "https://attack.mitre.org/techniques/T1547/"

[[rule.threat.technique.subtechnique]]
id = "T1547.006"
name = "Kernel Modules and Extensions"
reference = "https://attack.mitre.org/techniques/T1547/006/"

[rule.threat.tactic]
id = "TA0003"
name = "Persistence"
reference = "https://attack.mitre.org/tactics/TA0003/"

[[rule.threat]]
framework = "MITRE ATT&CK"
[[rule.threat.technique]]
id = "T1014"
name = "Rootkit"
reference = "https://attack.mitre.org/techniques/T1014/"

[rule.threat.tactic]
id = "TA0005"
name = "Defense Evasion"
reference = "https://attack.mitre.org/tactics/TA0005/"

0 comments on commit 46b4ead

Please sign in to comment.