ELF Binary Created in System Directory by Suspicious Process
Description
Identifies an executable from a suspicious or writable location creating an ELF binary in a system binary, configuration, or library directory. This may indicate an adversary attempting to install or masquerade a malicious executable in a trusted system location.
Query · eql
file where host.os.type == "linux" and event.action in ("rename", "creation") and file.Ext.header_bytes like "7f454c46*" and
process.executable like (
"/tmp/*", "/var/tmp/*", "/dev/shm/*", "/run/*", "/var/run/*", "/boot/*", "/sys/*", "*/www/html/*",
"/lost+found/*", "/proc/*", "/var/mail/*", "/var/www/*", "/mnt/*", "/media/*", "*/wp-content/*",
"*/wp-includes/*", "*/wp-admin/*", "?memfd:*", "memfd:*"
) and
file.path like (
"/bin/*", "/usr/bin/*", "/usr/local/bin/*", "/sbin/*", "/usr/sbin/*", "/usr/local/sbin/*", "/etc/*",
"/lib/*", "/lib32/*", "/lib64/*", "/libx32/*", "/usr/lib/*", "/usr/lib32/*", "/usr/lib64/*",
"/usr/libx32/*", "/usr/local/lib/*", "/usr/local/lib32/*", "/usr/local/lib64/*", "/usr/local/libx32/*",
"/libexec/*", "/usr/libexec/*", "/usr/local/libexec/*", "/var/lib/*"
)
Implementation guide
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, which can be customized by configuring the Elastic Defend integration policy. Select "Complete EDR (Endpoint Detection and Response)" to collect all events and preventions.
- Enter a name for the agent policy, or select an existing agent policy.
- Click "Save and Continue".
- To complete the integration, select "Add Elastic Agent" and follow the instructions to install the Elastic Agent on your hosts.
Elastic Defend does not collect advanced file information (such as the different file.Ext.* fields) by default. To capture this behavior, this rule requires a specific advanced setting in the Elastic Defend integration.
Enable advanced file information:
- Go to "Security -> Manage -> Policies".
- Select an Elastic Agent policy.
- Click "Show advanced settings".
- Search for "linux.advanced.events.populate_file_data".
- Set "linux.advanced.events.populate_file_data" to "true".
- Click "Save".
After saving the integration change, the Elastic Agents running this policy will be updated and the rule will function properly.
Analyst notes
Disclaimer: This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs.
Investigating ELF Binary Created in System Directory by Suspicious Process
Attackers may execute payloads from temporary, shared-memory, web, or memory-backed locations and use them to install additional binaries in trusted system directories. Placing an ELF file in a system binary or library path can help a malicious payload blend in with legitimate software, survive cleanup of its staging directory, or be invoked later.
Possible investigation steps
- Review the created file's path, name, owner, permissions, timestamps, size, hash, and signing or package provenance.
- Examine the creating process, its parent and ancestor chain, command line, user, working directory, and executable hash.
- Determine how the suspicious executable reached the host by reviewing earlier file, process, and network events.
- Check whether the file was subsequently executed, loaded as a library, referenced by a service or scheduled task, or observed on other hosts.
- Preserve the ELF file and analyze its imports, strings, sections, capabilities, and network indicators in an isolated environment.
False positive analysis
- Software installers, package-management wrappers, recovery tools, and custom deployment systems may run from temporary locations while placing legitimate files in system directories. Validate the process lineage, package or change record, file hash, and expected installation path before adding an exception.
- Container image builds or immutable-system update workflows may stage tools in unusual paths. Confirm that the activity is confined to an authorized build or update workflow and that the resulting artifact is trusted.
Response and remediation
- Isolate the affected host if the creating process or ELF file is unauthorized.
- Terminate malicious processes, quarantine the created file, and remove related persistence only after preserving evidence.
- Hunt for the same process and file hashes, names, paths, and related network indicators across the environment.
- Identify and remediate the initial access vector, then rotate credentials or secrets exposed to the compromised process.
- Restore modified system files from trusted packages or a known-good image and monitor for recurrence.