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

Related rules

to-top