Potential Shadow File Read via Command Line Utilities

Identifies access to the /etc/shadow file via the commandline using standard system utilities. After elevating privileges to root, threat actors may attempt to read or dump this file in order to gain valid credentials. They may utilize these to move laterally undetected and access additional resources.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2022/09/01"
  3integration = ["endpoint"]
  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/02/21"
  8
  9[rule]
 10author = ["Elastic"]
 11description = """
 12Identifies access to the /etc/shadow file via the commandline using standard system utilities. After elevating
 13privileges to root, threat actors may attempt to read or dump this file in order to gain valid credentials. They may
 14utilize these to move laterally undetected and access additional resources.
 15"""
 16from = "now-9m"
 17index = ["logs-endpoint.events.*", "endgame-*"]
 18language = "kuery"
 19license = "Elastic License v2"
 20name = "Potential Shadow File Read via Command Line Utilities"
 21references = ["https://www.cyberciti.biz/faq/unix-linux-password-cracking-john-the-ripper/"]
 22risk_score = 47
 23rule_id = "9a3a3689-8ed1-4cdb-83fb-9506db54c61f"
 24setup = """## Setup
 25
 26This rule requires data coming in from Elastic Defend.
 27
 28### Elastic Defend Integration Setup
 29Elastic Defend is integrated into the Elastic Agent using Fleet. Upon configuration, the integration allows the Elastic Agent to monitor events on your host and send data to the Elastic Security app.
 30
 31#### Prerequisite Requirements:
 32- Fleet is required for Elastic Defend.
 33- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
 34
 35#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
 36- Go to the Kibana home page and click "Add integrations".
 37- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
 38- Click "Add Elastic Defend".
 39- Configure the integration name and optionally add a description.
 40- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
 41- 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).
 42- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
 43- 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.
 44For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
 45- Click "Save and Continue".
 46- 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.
 47For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
 48"""
 49severity = "medium"
 50tags = [
 51        "Domain: Endpoint",
 52        "OS: Linux",
 53        "Use Case: Threat Detection",
 54        "Tactic: Privilege Escalation",
 55        "Tactic: Credential Access",
 56        "Data Source: Elastic Endgame",
 57        "Data Source: Elastic Defend"
 58        ]
 59timestamp_override = "event.ingested"
 60type = "new_terms"
 61
 62query = '''
 63host.os.type : "linux" and event.category : "process" and event.action : ("exec" or "exec_event") and
 64(process.args : "/etc/shadow" or (process.working_directory: "/etc" and process.args: "shadow")) and not 
 65(process.executable : ("/bin/chown" or "/usr/bin/chown") and process.args : "root:shadow") and not 
 66(process.executable : ("/bin/chmod" or "/usr/bin/chmod") and process.args : "640")
 67'''
 68
 69[[rule.threat]]
 70framework = "MITRE ATT&CK"
 71
 72[[rule.threat.technique]]
 73id = "T1068"
 74name = "Exploitation for Privilege Escalation"
 75reference = "https://attack.mitre.org/techniques/T1068/"
 76
 77[rule.threat.tactic]
 78id = "TA0004"
 79name = "Privilege Escalation"
 80reference = "https://attack.mitre.org/tactics/TA0004/"
 81
 82[[rule.threat]]
 83framework = "MITRE ATT&CK"
 84
 85[[rule.threat.technique]]
 86id = "T1003"
 87name = "OS Credential Dumping"
 88reference = "https://attack.mitre.org/techniques/T1003/"
 89
 90[[rule.threat.technique.subtechnique]]
 91id = "T1003.008"
 92name = "/etc/passwd and /etc/shadow"
 93reference = "https://attack.mitre.org/techniques/T1003/008/"
 94
 95[rule.threat.tactic]
 96id = "TA0006"
 97name = "Credential Access"
 98reference = "https://attack.mitre.org/tactics/TA0006/"
 99
100[rule.new_terms]
101field = "new_terms_fields"
102value = ["process.command_line", "host.id", "process.executable"]
103
104[[rule.new_terms.history_window_start]]
105field = "history_window_start"
106value = "now-10d"

References

Related rules

to-top