Potential Memory File Descriptor Process Execution


Description

This rule detects when a process is executed from a memory file descriptor (memfd). Attackers may use memfd to create and execute code directly in memory, bypassing traditional file-based detection mechanisms. The use of memfd for process execution is uncommon and may indicate an attempt to evade security controls.

Query · eql

process where event.type == "start" and event.action == "exec" and (
  process.executable like ("?memfd:*", "memfd:*") or
  process.parent.executable like ("?memfd:*", "memfd:*")
) and
not (
  process.executable in (
    "/usr/bin/fusermount", "/usr/bin/fusermount3",  "memfd:runc_cloned:/proc/self/exe",
    "memfd:buildah-chroot-runtime", "memfd:buildah-chroot-exec", "memfd:lxc-attach", "/usr/sbin/logrotate"
  ) or
  process.executable like "memfd:runc_cloned:/run/nvidia-ctk-hook/*" or
  process.parent.executable like (
    "/usr/libexec/nordlayer/nordlayer-resolvconf", "/nix/store/*/bin/buildah",
    "/opt/teleport/system/bin/teleport", "memfd:teleport-sessionhelper",
    "memfd:buildah-chroot-exec", "/usr/lib/openssh/sshd-session", "memfd:lxc-attach",
    "/usr/bin/nvidia-cdi-hook", "/opt/sophos-spl/plugins/runtimedetections/bin/runtimedetections.*",
    "/opt/appimagelauncher.AppDir/usr/lib/x86_64-linux-gnu/appimagelauncher/binfmt-bypass",
    "/usr/bin/nordlayer"
  ) or
  (
    process.working_directory == "/run/nordlayer" and
    process.parent.command_line in (
      "/proc/self/fd/4 -config /etc/nordlayer/config.hcl",
      "/dev/fd/4 -config /etc/nordlayer/config.hcl"
    )
  ) or
  (process.parent.executable == "/usr/local/bin/php" and process.executable == "memfd:spawn_worker_trampoline") or
  (process.parent.executable like "/opt/teleport/default/versions/*/bin/teleport" and process.executable == "memfd:teleport-sessionhelper") or
  (process.parent.command_line == "runc init" and process.parent.executable == "memfd:runc_cloned:/proc/self/exe") or
  (process.parent.executable == "/usr/bin/nvidia-container-cli" and process.executable == "memfd:/sbin/ldconfig.real") or
  (process.parent.executable == "/usr/sbin/nordlayerd" and process.parent.command_line == "/usr/sbin/nordlayerd -config /etc/nordlayer/config.hcl") or
  (process.parent.executable == "/usr/bin/nordlayer-tray" and process.executable == "memfd:fdexe") or
  (process.parent.executable == "/opt/fireeye/bin/rte-sensor" and process.executable like "memfd:/capsule8-sensor-*")
)
Raw source Potential Memory File Descriptor Process Execution · Elastic TOML
Esc
Published by elastic/protections-artifacts ↗, licensed under Elastic License 2.0 ↗. Reproduced here unmodified.
[rule]
description = """
This rule detects when a process is executed from a memory file descriptor (memfd). Attackers may use memfd to create
and execute code directly in memory, bypassing traditional file-based detection mechanisms. The use of memfd for process
execution is uncommon and may indicate an attempt to evade security controls.
"""
id = "b2bd6ad2-7954-4eb5-863f-fc8318ed15d7"
license = "Elastic License v2"
name = "Potential Memory File Descriptor Process Execution"
os_list = ["linux"]
reference = ["https://man7.org/linux/man-pages/man2/memfd_create.2.html"]
version = "1.0.4"

query = '''
process where event.type == "start" and event.action == "exec" and (
  process.executable like ("?memfd:*", "memfd:*") or
  process.parent.executable like ("?memfd:*", "memfd:*")
) and
not (
  process.executable in (
    "/usr/bin/fusermount", "/usr/bin/fusermount3",  "memfd:runc_cloned:/proc/self/exe",
    "memfd:buildah-chroot-runtime", "memfd:buildah-chroot-exec", "memfd:lxc-attach", "/usr/sbin/logrotate"
  ) or
  process.executable like "memfd:runc_cloned:/run/nvidia-ctk-hook/*" or
  process.parent.executable like (
    "/usr/libexec/nordlayer/nordlayer-resolvconf", "/nix/store/*/bin/buildah",
    "/opt/teleport/system/bin/teleport", "memfd:teleport-sessionhelper",
    "memfd:buildah-chroot-exec", "/usr/lib/openssh/sshd-session", "memfd:lxc-attach",
    "/usr/bin/nvidia-cdi-hook", "/opt/sophos-spl/plugins/runtimedetections/bin/runtimedetections.*",
    "/opt/appimagelauncher.AppDir/usr/lib/x86_64-linux-gnu/appimagelauncher/binfmt-bypass",
    "/usr/bin/nordlayer"
  ) or
  (
    process.working_directory == "/run/nordlayer" and
    process.parent.command_line in (
      "/proc/self/fd/4 -config /etc/nordlayer/config.hcl",
      "/dev/fd/4 -config /etc/nordlayer/config.hcl"
    )
  ) or
  (process.parent.executable == "/usr/local/bin/php" and process.executable == "memfd:spawn_worker_trampoline") or
  (process.parent.executable like "/opt/teleport/default/versions/*/bin/teleport" and process.executable == "memfd:teleport-sessionhelper") or
  (process.parent.command_line == "runc init" and process.parent.executable == "memfd:runc_cloned:/proc/self/exe") or
  (process.parent.executable == "/usr/bin/nvidia-container-cli" and process.executable == "memfd:/sbin/ldconfig.real") or
  (process.parent.executable == "/usr/sbin/nordlayerd" and process.parent.command_line == "/usr/sbin/nordlayerd -config /etc/nordlayer/config.hcl") or
  (process.parent.executable == "/usr/bin/nordlayer-tray" and process.executable == "memfd:fdexe") or
  (process.parent.executable == "/opt/fireeye/bin/rte-sensor" and process.executable like "memfd:/capsule8-sensor-*")
)
'''

min_endpoint_version = "7.15.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 = "T1055"
name = "Process Injection"
reference = "https://attack.mitre.org/techniques/T1055/"
[[threat.technique.subtechnique]]
id = "T1055.009"
name = "Proc Memory"
reference = "https://attack.mitre.org/techniques/T1055/009/"


[[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 = "7.15.0"

Detection rules belong to the projects that publish them and remain under their own licenses. This site indexes and links to them; it claims no rights in them.