Detection rules › Elastic

Potential Memory File Descriptor Process Execution

Source
github.com/elastic/protections-artifacts

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.

MITRE ATT&CK coverage

Rule body

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

Stages and Predicates

Stage 1: process

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-*")
)

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
process.executableeqmemfd:/sbin/ldconfig.realexcludes:process.executable field:"process.executable" value:"memfd:/sbin/ldconfig.real"
process.parent.executableeq/usr/bin/nvidia-container-cliexcludes:process.parent.executable field:"process.parent.executable" value:"/usr/bin/nvidia-container-cli"
process.executableeqmemfd:fdexeexcludes:process.executable field:"process.executable" value:"memfd:fdexe"
process.parent.executableeq/usr/bin/nordlayer-trayexcludes:process.parent.executable field:"process.parent.executable" value:"/usr/bin/nordlayer-tray"
process.executableeqmemfd:spawn_worker_trampolineexcludes:process.executable field:"process.executable" value:"memfd:spawn_worker_trampoline"
process.parent.executableeq/usr/local/bin/phpexcludes:process.parent.executable field:"process.parent.executable" value:"/usr/local/bin/php"
process.executableeqmemfd:teleport-sessionhelperexcludes:process.executable field:"process.executable" value:"memfd:teleport-sessionhelper"
process.parent.executablewildcard/opt/teleport/default/versions/*/bin/teleportexcludes:process.parent.executable field:"process.parent.executable" value:"/opt/teleport/default/versions/*/bin/teleport"
process.executablestarts_withmemfd:/capsule8-sensor-excludes:process.executable field:"process.executable" value:"memfd:/capsule8-sensor-"
process.parent.executableeq/opt/fireeye/bin/rte-sensorexcludes:process.parent.executable field:"process.parent.executable" value:"/opt/fireeye/bin/rte-sensor"
process.parent.command_lineeq/usr/sbin/nordlayerd -config /etc/nordlayer/config.hclexcludes:process.parent.command_line field:"process.parent.command_line" value:"/usr/sbin/nordlayerd -config /etc/nordlayer/config.hcl"
process.parent.executableeq/usr/sbin/nordlayerdexcludes:process.parent.executable field:"process.parent.executable" value:"/usr/sbin/nordlayerd"
process.parent.command_lineeqrunc initexcludes:process.parent.command_line field:"process.parent.command_line" value:"runc init"
process.parent.executableeqmemfd:runc_cloned:/proc/self/exeexcludes:process.parent.executable field:"process.parent.executable" value:"memfd:runc_cloned:/proc/self/exe"
process.parent.command_linein/dev/fd/4 -config /etc/nordlayer/config.hcl, /proc/self/fd/4 -config /etc/nordlayer/config.hclexcludes:process.parent.command_line field:"process.parent.command_line" value:"/dev/fd/4 -config /etc/nordlayer/config.hcl" field:"process.parent.command_line" value:"/proc/self/fd/4 -config /etc/nordlayer/config.hcl"
process.working_directoryeq/run/nordlayerexcludes:process.working_directory field:"process.working_directory" value:"/run/nordlayer"
process.executablein/usr/bin/fusermount, /usr/bin/fusermount3, /usr/sbin/logrotate, memfd:buildah-chroot-exec, memfd:buildah-chroot-runtime, memfd:lxc-attach, memfd:runc_cloned:/proc/self/exeexcludes:process.executable
process.executablestarts_withmemfd:runc_cloned:/run/nvidia-ctk-hook/excludes:process.executable field:"process.executable" value:"memfd:runc_cloned:/run/nvidia-ctk-hook/"
process.parent.executablewildcard/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/nordlayerexcludes:process.parent.executable

Indicators

These rows show field, operator, and value matches.