Unusual LD_PRELOAD/LD_LIBRARY_PATH Command Line Arguments

This rule detects the use of the LD_PRELOAD and LD_LIBRARY_PATH environment variables in a command line argument. This behavior is unusual and may indicate an attempt to hijack the execution flow of a process. Threat actors may use this technique to evade defenses, escalate privileges, or maintain persistence on a system.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2025/04/30"
  3integration = ["endpoint"]
  4maturity = "production"
  5updated_date = "2025/04/30"
  6
  7[rule]
  8author = ["Elastic"]
  9description = """
 10This rule detects the use of the LD_PRELOAD and LD_LIBRARY_PATH environment variables in a command line argument.
 11This behavior is unusual and may indicate an attempt to hijack the execution flow of a process. Threat actors may use
 12this technique to evade defenses, escalate privileges, or maintain persistence on a system.
 13"""
 14from = "now-9m"
 15index = ["logs-endpoint.events.process*"]
 16language = "kuery"
 17license = "Elastic License v2"
 18name = "Unusual LD_PRELOAD/LD_LIBRARY_PATH Command Line Arguments"
 19risk_score = 21
 20rule_id = "65613f5e-0d48-4b55-ad61-2fb9567cb1ad"
 21setup = """## Setup
 22
 23This rule requires data coming in from Elastic Defend.
 24
 25### Elastic Defend Integration Setup
 26Elastic 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.
 27
 28#### Prerequisite Requirements:
 29- Fleet is required for Elastic Defend.
 30- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
 31
 32#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
 33- Go to the Kibana home page and click "Add integrations".
 34- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
 35- Click "Add Elastic Defend".
 36- Configure the integration name and optionally add a description.
 37- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
 38- 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).
 39- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
 40- 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.
 41For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
 42- Click "Save and Continue".
 43- 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.
 44For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
 45"""
 46severity = "low"
 47tags = [
 48    "Domain: Endpoint",
 49    "OS: Linux",
 50    "Use Case: Threat Detection",
 51    "Tactic: Defense Evasion",
 52    "Tactic: Persistence",
 53    "Data Source: Elastic Defend",
 54]
 55timestamp_override = "event.ingested"
 56type = "new_terms"
 57query = '''
 58host.os.type:linux and event.category:process and event.type:start and event.action:exec and
 59process.parent.name:(* and not (
 60  awk or bwrap or cylancesvc or dbus-run-session or java or julia or make or matlab_helper or ninja or noproc_sandbox or
 61  nxrunner or nxserver or perl or rear or sapcontrol or setsid or spoold or sshd or steam or su or sudo or titanagent or
 62  vls_agent or zabbix_agentd
 63)) and
 64process.name:(bash or csh or dash or fish or ksh or sh or tcsh or zsh) and
 65process.args:-c and process.command_line:(*LD_LIBRARY_PATH=* or *LD_PRELOAD=*)
 66'''
 67[[rule.threat]]
 68framework = "MITRE ATT&CK"
 69
 70  [rule.threat.tactic]
 71  name = "Defense Evasion"
 72  id = "TA0005"
 73  reference = "https://attack.mitre.org/tactics/TA0005/"
 74
 75  [[rule.threat.technique]]
 76  name = "Hijack Execution Flow"
 77  id = "T1574"
 78  reference = "https://attack.mitre.org/techniques/T1574/"
 79
 80  [[rule.threat.technique.subtechnique]]
 81  name = "Dynamic Linker Hijacking"
 82  id = "T1574.006"
 83  reference = "https://attack.mitre.org/techniques/T1574/006/"
 84
 85[[rule.threat]]
 86framework = "MITRE ATT&CK"
 87
 88  [rule.threat.tactic]
 89  name = "Persistence"
 90  id = "TA0003"
 91  reference = "https://attack.mitre.org/tactics/TA0003/"
 92
 93  [[rule.threat.technique]]
 94  name = "Hijack Execution Flow"
 95  id = "T1574"
 96  reference = "https://attack.mitre.org/techniques/T1574/"
 97
 98  [[rule.threat.technique.subtechnique]]
 99  name = "Dynamic Linker Hijacking"
100  id = "T1574.006"
101  reference = "https://attack.mitre.org/techniques/T1574/006/"
102
103[[rule.threat]]
104framework = "MITRE ATT&CK"
105
106  [rule.threat.tactic]
107  name = "Privilege Escalation"
108  id = "TA0004"
109  reference = "https://attack.mitre.org/tactics/TA0004/"
110
111  [[rule.threat.technique]]
112  name = "Hijack Execution Flow"
113  id = "T1574"
114  reference = "https://attack.mitre.org/techniques/T1574/"
115
116  [[rule.threat.technique.subtechnique]]
117  name = "Dynamic Linker Hijacking"
118  id = "T1574.006"
119  reference = "https://attack.mitre.org/techniques/T1574/006/"
120
121[rule.new_terms]
122field = "new_terms_fields"
123value = ["process.parent.name", "process.command_line", "host.id"]
124
125[[rule.new_terms.history_window_start]]
126field = "history_window_start"
127value = "now-7d"

Related rules

to-top