Execution of Memory File Descriptor via Interactive Session
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.
Query · eql
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", "/tmp/newroot/home/*/.codex/*/codex-linux-sandbox",
"/tmp/home/*/.codex/*/codex-linux-sandbox", "/home/*/.npm-global/lib/node_modules/@openai/codex/node_modules/@openai/*/bin/codex"
) 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")
)