Potential Fileless Execution Sequence
Description
This rule detects when a process creates an in-memory file using the memfd_create syscall followed by executing a file descriptor in the proc (temporary) file system. This activity indicates an active attempt to execute a fileless payload 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 uses it to execute a process via a command and control channel via a file descriptor in the proc (temporary) file system, resulting in an exec event.
Query · eql
sequence by process.entity_id with maxspan=5s
[process where event.type == "start" and event.action == "memfd_create" and
not (
(
process.executable like ("/usr/sbin/runc", "/snap/microk8s/*/bin/runc") and
process.Ext.memfd.name == "memfd:runc_cloned:/proc/self/exe"
) or
(
process.executable like "/nix/store/*/bin/buildah" and
process.Ext.memfd.name == "memfd:buildah-in-a-user-namespace"
) or
process.executable like ("/usr/bin/lxc-attach", "memfd:buildah-chroot-runtime", "./usr/bin/nvidia-cdi-hook") or
process.command_line == "buildah-chroot-runtime"
)]
[process where event.type == "start" and event.action == "exec" and (
process.args regex """/proc/(self|[0-9]{1,7})/fd/[0-9]{1,7}""" or
process.executable like ("memfd:*", "?memfd:*")
) and
not (
process.executable in ("memfd:runc_cloned:/proc/self/exe", "/usr/bin/nvidia-ctk") or
(
process.parent.executable == "/usr/bin/nvidia-ctk" and
process.command_line like "ldconfig*"
)
)]