Detection rules › Elastic
Execution of Memory File Descriptor via Interactive Session
Detects when a file descriptor in the proc (temporary) file system is executed via an interactive session. This activity indicates an active attempt to execute an in-memory file and should be considered highly abnormal or suspicious. This activity can occur when the memfd syscall is utilized to create a memory resident file, like a payload, and then execute it via command and control.
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Execution | |
| Stealth |
Rule body
[rule]
description = """
Detects when a file descriptor in the proc (temporary) file system is executed via an interactive session. This activity
indicates an active attempt to execute an in-memory file and should be considered highly abnormal or suspicious. This
activity can occur when the memfd syscall is utilized to create a memory resident file, like a payload, and then execute
it via command and control.
"""
id = "fbc224a0-5469-4c0c-953d-fc57e0293197"
license = "Elastic License v2"
name = "Execution of Memory File Descriptor via Interactive Session"
os_list = ["linux"]
reference = [
"https://github.com/MythicAgents/merlin/blob/main/Payload_Type/merlin/container/commands/memfd.go",
"https://x-c3ll.github.io/posts/fileless-memfd_create/",
]
version = "1.0.22"
query = '''
process where event.type == "start" and event.action == "exec" and process.parent.executable != null and
process.executable regex """/proc/(self|[0-9]{1,7})/fd/[0-9]{1,7}""" and process.interactive == true and
not (
process.command_line in ("runc init", "/var/gdn/assets/linux/bin/runc init", "/usr/sbin/pfman", "lxc-attach -n rdsd.lv") or
process.args == "datadog-ipc-helper" or
process.parent.command_line == "/sbin/init" or
process.parent.executable in (
"/usr/sbin/runc", "/usr/libexec/snapd/snap-confine", "/var/lib/snapd/snap/bin/direnv", "/usr/lib/systemd/systemd",
"/usr/bin/runc", "/usr/bin/login", "/usr/bin/nvidia-cdi-hook", "/usr/bin/buildkit-runc", "/usr/bin/nordlayer",
"/usr/sbin/nordlayer", "/usr/libexec/nordlayer/nordlayer-setcap", "/sbin/apk", "/opt/sophos-spl/plugins/runtimedetections/bin/runtimedetections"
) or
process.parent.executable like (
"/proc/self/fd/*/*", "/home/*/.local/share/JetBrains/Toolbox/apps/rider/bin/rider", "/usr/bin/tini",
"/home/*/.codex/*/codex-linux-sandbox"
) or
(process.parent.name == "init" and process.args == "/usr/lib/systemd/systemd-executor") or
(process.parent.name like "python*" and process.args == "-m" and process.args == "test.regrtest" and process.args == "--pgo")
)
'''
min_endpoint_version = "8.3.0"
optional_actions = []
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 0
[[actions]]
action = "kill_process"
field = "process.parent.entity_id"
state = 0
[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1106"
name = "Native API"
reference = "https://attack.mitre.org/techniques/T1106/"
[threat.tactic]
id = "TA0002"
name = "Execution"
reference = "https://attack.mitre.org/tactics/TA0002/"
[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1620"
name = "Reflective Code Loading"
reference = "https://attack.mitre.org/techniques/T1620/"
[threat.tactic]
id = "TA0005"
name = "Defense Evasion"
reference = "https://attack.mitre.org/tactics/TA0005/"
[internal]
min_endpoint_version = "8.3.0"
Stages and Predicates
Stage 1: process
process where event.type == "start" and event.action == "exec" and process.parent.executable != null and
process.executable regex """/proc/(self|[0-9]{1,7})/fd/[0-9]{1,7}""" and process.interactive == true and
not (
process.command_line in ("runc init", "/var/gdn/assets/linux/bin/runc init", "/usr/sbin/pfman", "lxc-attach -n rdsd.lv") or
process.args == "datadog-ipc-helper" or
process.parent.command_line == "/sbin/init" or
process.parent.executable in (
"/usr/sbin/runc", "/usr/libexec/snapd/snap-confine", "/var/lib/snapd/snap/bin/direnv", "/usr/lib/systemd/systemd",
"/usr/bin/runc", "/usr/bin/login", "/usr/bin/nvidia-cdi-hook", "/usr/bin/buildkit-runc", "/usr/bin/nordlayer",
"/usr/sbin/nordlayer", "/usr/libexec/nordlayer/nordlayer-setcap", "/sbin/apk", "/opt/sophos-spl/plugins/runtimedetections/bin/runtimedetections"
) or
process.parent.executable like (
"/proc/self/fd/*/*", "/home/*/.local/share/JetBrains/Toolbox/apps/rider/bin/rider", "/usr/bin/tini",
"/home/*/.codex/*/codex-linux-sandbox"
) or
(process.parent.name == "init" and process.args == "/usr/lib/systemd/systemd-executor") or
(process.parent.name like "python*" and process.args == "-m" and process.args == "test.regrtest" and process.args == "--pgo")
)
Exclusions
The rule actively suppresses these predicates.
| Field | Kind | Excluded values | Search |
|---|---|---|---|
process.args | eq | --pgo | excludes:process.args field:"process.args" value:"--pgo" |
process.args | eq | -m | excludes:process.args field:"process.args" value:"-m" |
process.args | eq | test.regrtest | excludes:process.args field:"process.args" value:"test.regrtest" |
process.parent.name | starts_with | python | excludes:process.parent.name field:"process.parent.name" value:"python" |
process.args | eq | /usr/lib/systemd/systemd-executor | excludes:process.args field:"process.args" value:"/usr/lib/systemd/systemd-executor" |
process.parent.name | eq | init | excludes:process.parent.name field:"process.parent.name" value:"init" |
process.args | eq | datadog-ipc-helper | excludes:process.args field:"process.args" value:"datadog-ipc-helper" |
process.command_line | in | /usr/sbin/pfman, /var/gdn/assets/linux/bin/runc init, lxc-attach -n rdsd.lv, runc init | excludes:process.command_line |
process.parent.command_line | eq | /sbin/init | excludes:process.parent.command_line field:"process.parent.command_line" value:"/sbin/init" |
process.parent.executable | in | /opt/sophos-spl/plugins/runtimedetections/bin/runtimedetections, /sbin/apk, /usr/bin/buildkit-runc, /usr/bin/login, /usr/bin/nordlayer, /usr/bin/nvidia-cdi-hook, /usr/bin/runc, /usr/lib/systemd/systemd, /usr/libexec/nordlayer/nordlayer-setcap, /usr/libexec/snapd/snap-confine, /usr/sbin/nordlayer, /usr/sbin/runc, /var/lib/snapd/snap/bin/direnv | excludes:process.parent.executable |
process.parent.executable | wildcard | /proc/self/fd/*/*, /home/*/.local/share/JetBrains/Toolbox/apps/rider/bin/rider, /usr/bin/tini, /home/*/.codex/*/codex-linux-sandbox | excludes:process.parent.executable |
Indicators
These rows show field, operator, and value matches.
| Field | Kind | Values | Search |
|---|---|---|---|
event.action | eq |
| field:"EventType" kind:eq value:"exec" |
event.type | eq |
| field:"event.type" kind:eq value:"start" |
process.executable | regex_match |
| field:"Image" kind:regex_match value:"/proc/(self|[0-9]{1,7})/fd/[0-9]{1,7}" |
process.interactive | eq |
| field:"process.interactive" kind:eq value:"true" |
process.parent.executable | is_not_null | field:"ParentImage" kind:is_not_null |