Unknown Execution of Binary with RWX Memory Region

Monitors for the execution of a previously unknown unix binary with read, write and execute memory region permissions. The mprotect() system call is used to change the access protections on a region of memory that has already been allocated. This syscall allows a process to modify the permissions of pages in its virtual address space, enabling or disabling permissions such as read, write, and execute for those pages. RWX permissions on memory is in many cases overly permissive, and should be analyzed thoroughly.

Elastic rule (View on GitHub)

 1[metadata]
 2creation_date = "2024/03/13"
 3integration = ["auditd_manager"]
 4maturity = "production"
 5updated_date = "2024/07/18"
 6
 7[rule]
 8author = ["Elastic"]
 9description = """
10Monitors for the execution of a previously unknown unix binary with read, write and execute memory region permissions.
11The mprotect() system call is used to change the access protections on a region of memory that has already been
12allocated. This syscall allows a process to modify the permissions of pages in its virtual address space, enabling or
13disabling permissions such as read, write, and execute for those pages. RWX permissions on memory is in many cases
14overly permissive, and should be analyzed thoroughly.
15"""
16from = "now-9m"
17index = ["auditbeat-*", "logs-auditd_manager.auditd-*"]
18language = "kuery"
19license = "Elastic License v2"
20name = "Unknown Execution of Binary with RWX Memory Region"
21references = ["https://man7.org/linux/man-pages/man2/mprotect.2.html"]
22risk_score = 47
23rule_id = "23bcd283-2bc0-4db2-81d4-273fc051e5c0"
24setup = """## Setup
25
26This rule requires the use of the `auditd_manager` integration. `Auditd_manager` is a tool designed to simplify and enhance the management of the audit subsystem in Linux systems. It provides a user-friendly interface and automation capabilities for configuring and monitoring system auditing through the auditd daemon. With `auditd_manager`, administrators can easily define audit rules, track system events, and generate comprehensive audit reports, improving overall security and compliance in the system. The following steps should be executed in order to install and deploy `auditd_manager` on a Linux system.

Kibana --> Management --> Integrations --> Auditd Manager --> Add Auditd Manager

1`Auditd_manager` subscribes to the kernel and receives events as they occur without any additional configuration. However, if more advanced configuration is required to detect specific behavior, audit rules can be added to the integration in either the "audit rules" configuration box or the "auditd rule files" box by specifying a file to read the audit rules from.
2For this detection rule to trigger, the following additional audit rules are required to be added to the integration:

-a always,exit -F arch=b64 -S mprotect

 1Add the newly installed `auditd manager` to an agent policy, and deploy the agent on a Linux system from which auditd log files are desirable.
 2"""
 3severity = "medium"
 4tags = [
 5    "Domain: Endpoint",
 6    "OS: Linux",
 7    "Use Case: Threat Detection",
 8    "Tactic: Execution",
 9    "Data Source: Auditd Manager",
10]
11timestamp_override = "event.ingested"
12type = "new_terms"
13
14query = '''
15event.category:process and host.os.type:linux and auditd.data.syscall:mprotect and auditd.data.a2:7 and not (
16  process.executable:(
17    "/usr/share/kibana/node/bin/node" or "/usr/share/elasticsearch/jdk/bin/java" or "/usr/sbin/apache2"
18  ) or
19  process.name:httpd
20)
21'''
22
23[[rule.threat]]
24framework = "MITRE ATT&CK"
25
26[[rule.threat.technique]]
27id = "T1059"
28name = "Command and Scripting Interpreter"
29reference = "https://attack.mitre.org/techniques/T1059/"
30
31[[rule.threat.technique.subtechnique]]
32id = "T1059.004"
33name = "Unix Shell"
34reference = "https://attack.mitre.org/techniques/T1059/004/"
35
36[rule.threat.tactic]
37id = "TA0002"
38name = "Execution"
39reference = "https://attack.mitre.org/tactics/TA0002/"
40
41[rule.new_terms]
42field = "new_terms_fields"
43value = ["process.executable"]
44
45[[rule.new_terms.history_window_start]]
46field = "history_window_start"
47value = "now-7d"

References

Related rules

to-top