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"
 5min_stack_comments = "Multiple field support in the New Terms rule type was added in Elastic 8.6"
 6min_stack_version = "8.6.0"
 7updated_date = "2024/03/13"
 8
 9[rule]
10author = ["Elastic"]
11description = """
12Monitors for the execution of a previously unknown unix binary with read, write and execute memory region permissions.
13The mprotect() system call is used to change the access protections on a region of memory that has already been
14allocated. This syscall allows a process to modify the permissions of pages in its virtual address space, enabling or
15disabling permissions such as read, write, and execute for those pages. RWX permissions on memory is in many cases
16overly permissive, and should be analyzed thoroughly. 
17"""
18from = "now-9m"
19index = ["auditbeat-*", "logs-auditd_manager.auditd-*"]
20language = "kuery"
21license = "Elastic License v2"
22name = "Unknown Execution of Binary with RWX Memory Region"
23references = [
24    "https://man7.org/linux/man-pages/man2/mprotect.2.html"
25]
26risk_score = 47
27rule_id = "23bcd283-2bc0-4db2-81d4-273fc051e5c0"
28setup = """## Setup
29
30This 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"
13query = '''
14event.category:process and host.os.type:linux and auditd.data.syscall:mprotect and auditd.data.a2:7
15'''
16
17[[rule.threat]]
18framework = "MITRE ATT&CK"
19
20[rule.threat.tactic]
21name = "Execution"
22id = "TA0002"
23reference = "https://attack.mitre.org/tactics/TA0002/"
24
25[[rule.threat.technique]]
26id = "T1059"
27name = "Command and Scripting Interpreter"
28reference = "https://attack.mitre.org/techniques/T1059/"
29
30[[rule.threat.technique.subtechnique]]
31id = "T1059.004"
32name = "Unix Shell"
33reference = "https://attack.mitre.org/techniques/T1059/004/"
34
35[rule.new_terms]
36field = "new_terms_fields"
37value = ["host.id", "process.executable"]
38
39[[rule.new_terms.history_window_start]]
40field = "history_window_start"
41value = "now-7d"

References

Related rules

to-top