Suspicious Passwd File Event Action

Monitors for the generation of a passwd password entry via openssl, followed by a file write activity on the "/etc/passwd" file. The "/etc/passwd" file in Linux stores user account information, including usernames, user IDs, group IDs, home directories, and default shell paths. Attackers may exploit a misconfiguration in the "/etc/passwd" file permissions or other privileges to add a new entry to the "/etc/passwd" file with root permissions, and leverage this new user account to login as root.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2024/01/22"
  3integration = ["endpoint", "auditd_manager"]
  4maturity = "production"
  5min_stack_comments = "New fields added: required_fields, related_integrations, setup"
  6min_stack_version = "8.3.0"
  7updated_date = "2024/02/19"
  8
  9[rule]
 10author = ["Elastic"]
 11description = """
 12Monitors for the generation of a passwd password entry via openssl, followed by a file write activity on the
 13"/etc/passwd" file. The "/etc/passwd" file in Linux stores user account information, including usernames, user IDs,
 14group IDs, home directories, and default shell paths. Attackers may exploit a misconfiguration in the "/etc/passwd" file
 15permissions or other privileges to add a new entry to the "/etc/passwd" file with root permissions, and leverage this
 16new user account to login as root.
 17"""
 18from = "now-9m"
 19index = ["logs-endpoint.events.*", "logs-auditd_manager.auditd-*"]
 20language = "eql"
 21license = "Elastic License v2"
 22name = "Suspicious Passwd File Event Action"
 23risk_score = 47
 24rule_id = "71d6a53d-abbd-40df-afee-c21fff6aafb0"
 25setup = """## Setup
 26
 27
 28This rule requires data coming in from Elastic Defend and Auditd Manager.
 29
 30### Elastic Defend Integration Setup
 31Elastic Defend is integrated into the Elastic Agent using Fleet. Upon configuration, the integration allows
 32the Elastic Agent to monitor events on your host and send data to the Elastic Security app.
 33
 34#### Prerequisite Requirements:
 35- Fleet is required for Elastic Defend.
 36- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
 37
 38#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
 39- Go to the Kibana home page and click "Add integrations".
 40- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
 41- Click "Add Elastic Defend".
 42- Configure the integration name and optionally add a description.
 43- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
 44- Select a configuration preset. Each preset comes with different default settings for Elastic Agent, you can further customize these later by configuring the Elastic Defend integration policy. [Helper guide](https://www.elastic.co/guide/en/security/current/configure-endpoint-integration-policy.html).
 45- We suggest to select "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
 46- Enter a name for the agent policy in "New agent policy name". If other agent policies already exist, you can click the "Existing hosts" tab and select an existing policy instead.
 47For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
 48- Click "Save and Continue".
 49- To complete the integration, select "Add Elastic Agent to your hosts" and continue to the next section to install the Elastic Agent on your hosts.
 50For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
 51
 52### Auditd Manager Integration Setup
 53The Auditd Manager Integration receives audit events from the Linux Audit Framework which is a part of the Linux kernel.
 54Auditd 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.
 55
 56#### The following steps should be executed in order to add the Elastic Agent System integration "auditd_manager" on a Linux System:
 57- Go to the Kibana home page and click “Add integrations”.
 58- In the query bar, search for “Auditd Manager” and select the integration to see more details about it.
 59- Click “Add Auditd Manager”.
 60- Configure the integration name and optionally add a description.
 61- Review optional and advanced settings accordingly.
 62- 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.
 63- Click “Save and Continue”.
 64- For more details on the integration refer to the [helper guide](https://docs.elastic.co/integrations/auditd_manager).
 65
 66#### Rule Specific Setup Note
 67Auditd Manager subscribes to the kernel and receives events as they occur without any additional configuration.
 68However, 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.
 69- For this detection rule the following additional audit rules are required to be added to the integration:
 70  -- "-w /etc/passwd -p wa -k etcpasswd"
 71"""
 72severity = "medium"
 73tags = [
 74        "Data Source: Auditd Manager",
 75        "Domain: Endpoint",
 76        "OS: Linux",
 77        "Use Case: Threat Detection",
 78        "Tactic: Privilege Escalation",
 79        "Data Source: Elastic Defend"
 80        ]
 81type = "eql"
 82query = '''
 83sequence by host.id, process.parent.pid with maxspan=1m
 84  [process where host.os.type == "linux" and event.type == "start" and event.action == "exec" and
 85   process.name == "openssl" and process.args == "passwd" and user.id != "0"]
 86  [file where host.os.type == "linux" and file.path == "/etc/passwd" and process.parent.pid != 1 and
 87   not auditd.data.a2 == "80000" and event.outcome == "success" and user.id != "0"]
 88'''
 89
 90[[rule.threat]]
 91framework = "MITRE ATT&CK"
 92
 93[[rule.threat.technique]]
 94id = "T1068"
 95name = "Exploitation for Privilege Escalation"
 96reference = "https://attack.mitre.org/techniques/T1068/"
 97
 98[rule.threat.tactic]
 99id = "TA0004"
100name = "Privilege Escalation"
101reference = "https://attack.mitre.org/tactics/TA0004/"

Related rules

to-top