Privilege Escalation via CAP_CHOWN/CAP_FOWNER Capabilities

Identifies instances where a processes (granted CAP_CHOWN and/or CAP_FOWNER capabilities) is executed, after which the ownership of a suspicious file or binary is changed. In Linux, the CAP_CHOWN capability allows a process to change the owner of a file, while CAP_FOWNER permits it to bypass permission checks on operations that require file ownership (like reading, writing, and executing). Attackers may abuse these capabilities to obtain unauthorized access to files.

Elastic rule (View on GitHub)

 1[metadata]
 2creation_date = "2024/01/08"
 3integration = ["endpoint", "auditd_manager"]
 4maturity = "production"
 5updated_date = "2024/11/07"
 6
 7[rule]
 8author = ["Elastic"]
 9description = """
10Identifies instances where a processes (granted CAP_CHOWN and/or CAP_FOWNER capabilities) is executed, after which the
11ownership of a suspicious file or binary is changed. In Linux, the CAP_CHOWN capability allows a process to change the
12owner of a file, while CAP_FOWNER permits it to bypass permission checks on operations that require file ownership (like
13reading, writing, and executing). Attackers may abuse these capabilities to obtain unauthorized access to files.
14"""
15from = "now-9m"
16index = ["logs-endpoint.events.*", "auditbeat-*", "logs-auditd_manager.auditd-*"]
17language = "eql"
18license = "Elastic License v2"
19name = "Privilege Escalation via CAP_CHOWN/CAP_FOWNER Capabilities"
20risk_score = 47
21rule_id = "d55abdfb-5384-402b-add4-6c401501b0c3"
22setup = """## Setup
23
24
25This rule requires data coming in from Auditd Manager.
26
27### Auditd Manager Integration Setup
28The Auditd Manager Integration receives audit events from the Linux Audit Framework which is a part of the Linux kernel.
29Auditd Manager 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.
30
31#### The following steps should be executed in order to add the Elastic Agent System integration "auditd_manager" on a Linux System:
32- Go to the Kibana home page and click “Add integrations”.
33- In the query bar, search for “Auditd Manager” and select the integration to see more details about it.
34- Click “Add Auditd Manager”.
35- Configure the integration name and optionally add a description.
36- Review optional and advanced settings accordingly.
37- Add the newly installed “auditd manager” to an existing or a new agent policy, and deploy the agent on a Linux system from which auditd log files are desirable.
38- Click “Save and Continue”.
39- For more details on the integration refer to the [helper guide](https://docs.elastic.co/integrations/auditd_manager).
40
41#### Rule Specific Setup Note
42Auditd Manager subscribes to the kernel and receives events as they occur without any additional configuration.
43However, 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.
44- For this detection rule the following additional audit rules are required to be added to the integration:
45  -- "-w /etc/ -p rwxa -k audit_recursive_etc"
46  -- "-w /root/ -p rwxa -k audit_root"
47"""
48severity = "medium"
49tags = [
50    "Data Source: Auditd Manager",
51    "Domain: Endpoint",
52    "OS: Linux",
53    "Use Case: Threat Detection",
54    "Tactic: Privilege Escalation",
55    "Data Source: Elastic Defend",
56]
57type = "eql"
58
59query = '''
60sequence by host.id, process.pid with maxspan=1s
61  [process where host.os.type == "linux" and event.type == "start" and event.action == "exec" and
62   process.name != null and process.thread.capabilities.effective : ("CAP_CHOWN", "CAP_FOWNER") and
63   process.command_line : ("*sudoers*", "*passwd*", "*shadow*", "*/root/*") and user.id != "0"]
64  [file where host.os.type == "linux" and event.action == "changed-file-ownership-of" and event.type == "change" and
65   event.outcome == "success" and file.path in (
66     "/etc/passwd",
67     "/etc/shadow",
68     "/etc/sudoers",
69     "/root/.ssh/*"
70   ) and user.id != "0"
71  ]
72'''
73
74
75[[rule.threat]]
76framework = "MITRE ATT&CK"
77[[rule.threat.technique]]
78id = "T1068"
79name = "Exploitation for Privilege Escalation"
80reference = "https://attack.mitre.org/techniques/T1068/"
81
82
83[rule.threat.tactic]
84id = "TA0004"
85name = "Privilege Escalation"
86reference = "https://attack.mitre.org/tactics/TA0004/"

Related rules

to-top