Deprecated - Potential Process Injection via LD_PRELOAD Environment Variable

This rule detects the execution of a process where the LD_PRELOAD environment variable is set. LD_PRELOAD can be used to inject a shared library into a binary at or prior to execution. A threat actor may do this in order to load a malicious shared library for the purposes of persistence, privilege escalation, and defense evasion. This activity is not common and will potentially indicate malicious or suspicious behavior.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2023/06/26"
  3deprecation_date = "2023/09/25"
  4integration = ["endpoint"]
  5maturity = "deprecated"
  6min_stack_comments = "The linux.advanced.capture_env_vars option for Elastic Defend has been introduced in 8.6.0"
  7min_stack_version = "8.6.0"
  8updated_date = "2023/09/25"
  9
 10[rule]
 11author = ["Elastic"]
 12description = """
 13This rule detects the execution of a process where the LD_PRELOAD environment variable is set. LD_PRELOAD can be used to
 14inject a shared library into a binary at or prior to execution. A threat actor may do this in order to load a malicious
 15shared library for the purposes of persistence, privilege escalation, and defense evasion. This activity is not common
 16and will potentially indicate malicious or suspicious behavior.
 17"""
 18from = "now-9m"
 19index = ["logs-endpoint.events.*"]
 20language = "eql"
 21license = "Elastic License v2"
 22name = "Deprecated - Potential Process Injection via LD_PRELOAD Environment Variable"
 23note = """ This rule was deprecated due to the large amount of false positives and the lack of true positives generated by the rule.
 24## 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
 30the Elastic Agent to monitor events on your host and send data to the Elastic Security app.
 31
 32#### Prerequisite Requirements:
 33- Fleet is required for Elastic Defend.
 34- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
 35
 36#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
 37- Go to the Kibana home page and click Add integrations.
 38- In the query bar, search for Elastic Defend and select the integration to see more details about it.
 39- Click Add Elastic Defend.
 40- Configure the integration name and optionally add a description.
 41- Select the type of environment you want to protect, either Traditional Endpoints or Cloud Workloads.
 42- 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).
 43- We suggest to select "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
 44- 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.
 45For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
 46- Click Save and Continue.
 47- 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.
 48For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
 49
 50Elastic Defend integration does not collect environment variable logging by default.
 51In order to capture this behavior, this rule requires a specific configuration option set within the advanced settings of the Elastic Defend integration.
 52 #### To set up environment variable capture for an Elastic Agent policy:
 53- Go to Security → Manage → Policies.
 54- Select an Elastic Agent policy.
 55- Click Show advanced settings.
 56- Scroll down or search for linux.advanced.capture_env_vars.
 57- Enter the names of env vars you want to capture, separated by commas.
 58- For this rule the linux.advanced.capture_env_vars variable should be set to "LD_PRELOAD,LD_LIBRARY_PATH".
 59- Click Save.
 60After saving the integration change, the Elastic Agents running this policy will be updated and
 61the rule will function properly.
 62For more information on capturing environment variables refer the [helper guide](https://www.elastic.co/guide/en/security/current/environment-variable-capture.html).
 63
 64"""
 65references = ["https://www.getambassador.io/resources/code-injection-on-linux-and-macos"]
 66risk_score = 21
 67rule_id = "4973e46b-a663-41b8-a875-ced16dda2bb0"
 68severity = "low"
 69tags = [
 70    "Domain: Endpoint",
 71    "OS: Linux",
 72    "Use Case: Threat Detection",
 73    "Tactic: Defense Evasion",
 74    "Tactic: Persistence",
 75    "Tactic: Privilege Escalation",
 76    "Data Source: Elastic Defend",
 77]
 78timestamp_override = "event.ingested"
 79type = "eql"
 80
 81query = '''
 82process where host.os.type == "linux" and event.action == "exec" and process.env_vars : ("LD_PRELOAD=?*", "LD_LIBRARY_PATH=?*")
 83'''
 84
 85
 86[[rule.threat]]
 87framework = "MITRE ATT&CK"
 88[[rule.threat.technique]]
 89id = "T1574"
 90name = "Hijack Execution Flow"
 91reference = "https://attack.mitre.org/techniques/T1574/"
 92[[rule.threat.technique.subtechnique]]
 93id = "T1574.006"
 94name = "Dynamic Linker Hijacking"
 95reference = "https://attack.mitre.org/techniques/T1574/006/"
 96
 97
 98
 99[rule.threat.tactic]
100id = "TA0005"
101name = "Defense Evasion"
102reference = "https://attack.mitre.org/tactics/TA0005/"
103[[rule.threat]]
104framework = "MITRE ATT&CK"
105[[rule.threat.technique]]
106id = "T1574"
107name = "Hijack Execution Flow"
108reference = "https://attack.mitre.org/techniques/T1574/"
109[[rule.threat.technique.subtechnique]]
110id = "T1574.006"
111name = "Dynamic Linker Hijacking"
112reference = "https://attack.mitre.org/techniques/T1574/006/"
113
114
115
116[rule.threat.tactic]
117id = "TA0003"
118name = "Persistence"
119reference = "https://attack.mitre.org/tactics/TA0003/"
120[[rule.threat]]
121framework = "MITRE ATT&CK"
122[[rule.threat.technique]]
123id = "T1574"
124name = "Hijack Execution Flow"
125reference = "https://attack.mitre.org/techniques/T1574/"
126[[rule.threat.technique.subtechnique]]
127id = "T1574.006"
128name = "Dynamic Linker Hijacking"
129reference = "https://attack.mitre.org/techniques/T1574/006/"
130
131
132
133[rule.threat.tactic]
134id = "TA0004"
135name = "Privilege Escalation"
136reference = "https://attack.mitre.org/tactics/TA0004/"

This rule was deprecated due to the large amount of false positives and the lack of true positives generated by the rule.

Setup

This rule requires data coming in from Elastic Defend.

Elastic Defend Integration Setup

Elastic 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.

Prerequisite Requirements:

  • Fleet is required for Elastic Defend.
  • To configure Fleet Server refer to the documentation.

The following steps should be executed in order to add the Elastic Defend integration on a Linux System:

  • Go to the Kibana home page and click Add integrations.
  • In the query bar, search for Elastic Defend and select the integration to see more details about it.
  • Click Add Elastic Defend.
  • Configure the integration name and optionally add a description.
  • Select the type of environment you want to protect, either Traditional Endpoints or Cloud Workloads.
  • 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.
  • We suggest to select "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
  • 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. For more details on Elastic Agent configuration settings, refer to the helper guide.
  • Click Save and Continue.
  • 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. For more details on Elastic Defend refer to the helper guide.

Elastic Defend integration does not collect environment variable logging by default. In order to capture this behavior, this rule requires a specific configuration option set within the advanced settings of the Elastic Defend integration.

To set up environment variable capture for an Elastic Agent policy:

  • Go to Security → Manage → Policies.
  • Select an Elastic Agent policy.
  • Click Show advanced settings.
  • Scroll down or search for linux.advanced.capture_env_vars.
  • Enter the names of env vars you want to capture, separated by commas.
  • For this rule the linux.advanced.capture_env_vars variable should be set to "LD_PRELOAD,LD_LIBRARY_PATH".
  • Click Save. After saving the integration change, the Elastic Agents running this policy will be updated and the rule will function properly. For more information on capturing environment variables refer the helper guide.

References

Related rules

to-top