-
Notifications
You must be signed in to change notification settings - Fork 696
[New Rule] Potential Fileless Execution via O_TMPFILE #6743
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ea11e8e
[New Rule] Potential Fileless Execution via O_TMPFILE
Aegrah 285d78a
++
Aegrah ff96ed8
++
Aegrah 96046f3
Fix pattern for logs-endpoint.events.process
Aegrah dd6bf1b
Clarify rule for fileless ELF execution detection
Aegrah 56c601e
Modify defense evasion rule for fileless execution
Aegrah 0ea934f
Add platform and rule type tags to TOML file
Aegrah 634bc21
Refine rule description for fileless ELF execution
Aegrah 9d6ae91
Merge branch 'main' into new-rule-detect-o-temp-file-execution
Aegrah File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
128 changes: 128 additions & 0 deletions
128
rules/linux/defense_evasion_fileless_execution_via_o_tempfile.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| [metadata] | ||
| creation_date = "2026/09/07" | ||
| integration = ["auditd_manager", "crowdstrike", "endpoint", "sentinel_one_cloud_funnel"] | ||
| maturity = "production" | ||
| updated_date = "2026/09/07" | ||
|
|
||
| [rule] | ||
| author = ["Elastic"] | ||
| description = """ | ||
| This rule identifies potential fileless ELF execution where a process is launched from an anonymous | ||
| temporary executable path that appears as "/#<id>" in "process.executable". This pattern may be | ||
| associated with "O_TMPFILE" and "execveat" with "AT_EMPTY_PATH", which can allow execution without | ||
| a normal filesystem pathname. | ||
| """ | ||
|
Copilot marked this conversation as resolved.
|
||
| from = "now-9m" | ||
| index = [ | ||
| "auditbeat-*", | ||
| "endgame-*", | ||
| "logs-crowdstrike.fdr*", | ||
| "logs-endpoint.events.process-*", | ||
| "logs-sentinel_one_cloud_funnel.*", | ||
| "logs-auditd_manager.auditd-*", | ||
| ] | ||
| language = "eql" | ||
| license = "Elastic License v2" | ||
| name = "Potential Fileless Execution via O_TMPFILE" | ||
| note = """## Triage and analysis | ||
|
|
||
| > **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 Potential Fileless Execution via O_TMPFILE | ||
|
|
||
| This rule detects Linux processes launched from anonymous temporary files created with O_TMPFILE, a pattern associated with execveat and AT_EMPTY_PATH execution that leaves no normal filesystem pathname. An attacker can write a malicious ELF payload into an unnamed file descriptor and execute it directly, reducing disk artifacts and making the payload harder to discover through routine file inspection. | ||
|
|
||
| ### Possible investigation steps | ||
|
|
||
| - Preserve volatile evidence from the live process by collecting its `/proc/<pid>/exe`, file descriptors, memory maps, command line, environment, namespaces, and a hash or copy of the anonymous executable where policy permits. | ||
| - Reconstruct the full process ancestry and execution context, focusing on the initiating user, parent binary, container or service identity, privilege changes, and whether the chain originated from a shell, web service, or remote session. | ||
| - Correlate audit telemetry for the preceding `openat` or `openat2` call using `O_TMPFILE`, subsequent writes and permission changes, and the final `execveat` call using `AT_EMPTY_PATH`. | ||
| - Review nearby network, authentication, and endpoint activity for payload delivery, command-and-control connections, credential access, persistence creation, lateral movement, or additional spawned processes. | ||
| - Determine prevalence across hosts and compare hashes, ancestry, and execution context with approved software, escalating isolated or unsigned occurrences and containing affected systems when malicious behavior is confirmed. | ||
|
|
||
| ### False positive analysis | ||
|
|
||
| - Legitimate system or application software may use O_TMPFILE for secure temporary execution, so verify the process ancestry, executable hash, package ownership, and consistency with approved activity. | ||
| - Authorized software installation, update, or testing workflows may execute an anonymous ELF binary, so confirm the timing against approved changes and validate the initiating user, service, and expected recurrence across comparable hosts. | ||
|
|
||
| ### Response and remediation | ||
|
|
||
| - Isolate the affected Linux host or container from the network while preserving `/proc/<pid>/exe`, open file descriptors, memory, and relevant audit logs for forensic analysis. | ||
| - Terminate the malicious process tree, revoke exposed credentials and active sessions, and block identified executable hashes, command-and-control destinations, and payload sources across the environment. | ||
| - Remove attacker persistence from systemd units, cron jobs, shell profiles, SSH `authorized_keys`, startup scripts, modified containers, and unauthorized accounts or packages. | ||
| - Escalate immediately to incident response if privileged execution, credential theft, command-and-control traffic, persistence, or activity on additional hosts is identified. | ||
| - Reimage compromised systems from known-good media, restore validated data, rotate affected secrets, patch the initial access vector, and verify that no anonymous executable or related attacker activity remains. | ||
| - Harden Linux endpoints by restricting unnecessary O_TMPFILE and `execveat` behavior through application allowlisting, SELinux or AppArmor policies, container controls, and enhanced auditing of anonymous-file execution. | ||
| """ | ||
| references = [ | ||
| "https://github.com/MatheuZSecurity/Dntry", | ||
| "https://matheuzsecurity.github.io/hacking/fileless-loader-bypassing-elastic-memfd/", | ||
| ] | ||
|
Copilot marked this conversation as resolved.
|
||
| risk_score = 73 | ||
| rule_id = "6fdd522d-421c-49f5-884e-0f278c388276" | ||
| setup = """## 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](https://www.elastic.co/guide/en/fleet/current/fleet-server.html). | ||
|
|
||
| #### 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](https://www.elastic.co/guide/en/security/current/configure-endpoint-integration-policy.html). | ||
| - We suggest selecting "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](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html). | ||
| - 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](https://www.elastic.co/guide/en/security/current/install-endpoint.html). | ||
| """ | ||
| severity = "high" | ||
| tags = [ | ||
| "Domain: Endpoint", | ||
| "OS: Linux", | ||
| "Platform: Linux", | ||
| "Use Case: Threat Detection", | ||
| "Tactic: Defense Evasion", | ||
| "Rule Type: Event Correlation (EQL)", | ||
| "Data Source: Auditd Manager", | ||
| "Data Source: Elastic Defend", | ||
| "Data Source: Elastic Endgame", | ||
| "Data Source: Crowdstrike", | ||
| "Data Source: SentinelOne", | ||
| "Resources: Investigation Guide", | ||
| ] | ||
|
Copilot marked this conversation as resolved.
|
||
| timestamp_override = "event.ingested" | ||
| type = "eql" | ||
| query = ''' | ||
| process where host.os.type == "linux" and event.type == "start" and | ||
| event.action in ("exec", "exec_event", "start", "ProcessRollup2", "executed", "process_started") and | ||
| process.executable regex """.*/\#[0-9]+.*""" | ||
| ''' | ||
|
|
||
| [[rule.threat]] | ||
| framework = "MITRE ATT&CK" | ||
|
|
||
| [[rule.threat.technique]] | ||
| id = "T1036" | ||
| name = "Masquerading" | ||
| reference = "https://attack.mitre.org/techniques/T1036/" | ||
|
|
||
| [[rule.threat.technique.subtechnique]] | ||
| id = "T1036.005" | ||
| name = "Match Legitimate Resource Name or Location" | ||
| reference = "https://attack.mitre.org/techniques/T1036/005/" | ||
|
|
||
| [rule.threat.tactic] | ||
| id = "TA0005" | ||
| name = "Defense Evasion" | ||
| reference = "https://attack.mitre.org/tactics/TA0005/" | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.