Potential Fileless Execution via Exec Followed by Memory File Descriptor
Description
This rule detects when a process executes a file followed by creating an in-memory file using the memfd_create syscall. 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, resulting in an exec event.
Query · eql
sequence by process.entity_id with maxspan=5s
[process where event.type == "start" and event.action == "exec" and process.parent.executable != null and
process.interactive == true and process.executable like (
"memfd:*", "?memfd:*", "/tmp/*", "/var/tmp/*", "/dev/shm/*", "/run/user/*", "/var/run/user/*", "/boot/*",
"/sys/*", "/lost+found/*", "/proc/*", "/var/mail/*", "*(deleted)*"
) and
not (
process.parent.command_line like ("buildah-chroot-runtime", "*/home/*/.claude/shell-snapshots/snapshot-*") or
process.command_line == "buildah-chroot-runtime" or
process.args == "/usr/bin/crun" or
process.executable like (
"/tmp/.*/.vscode-server/cli/servers/*/server/node_modules/@vscode/vsce-sign/bin/vsce-sign", "/tmp/.mount_*", "/tmp/go-build*",
"/tmp/.tmp*/.vscode-server/bin/*/node_modules/@vscode/vsce-sign/bin/vsce-sign", "/var/tmp/portage/*",
"/tmp/.cache/ms-playwright/chromium_headless_shell-*/chrome-headless-shell-linux64/chrome-headless-shell",
"/tmp/appimage_extracted_*/usr/bin/PDW_GCS", "/tmp/radarr_update/Radarr.Update", "/tmp/prowlarr_update/Prowlarr.Update",
"/tmp/buildpacks/*_buildpack-nodejs/lib/vendor/yq-*-linux", "memfd:lxc-attach", "/tmp/claude-*/*",
"/tmp/*-vscode/.vscode-server/bin/*/node_modules/@vscode/vsce-sign/bin/vsce-sign", "/tmp/clearpass-onguard-*",
"/tmp/*/vibex", "/tmp/dotnet-sdk/dotnet", "/tmp/dotnet-tools/sqlpackage", "/tmp/pub-plain/LabPlatform.Api",
"/tmp/j9/bin/Release/*/j9", "/tmp/clean-head/q/bin/*/q", "/tmp/tools/ilspycmd", "/tmp/ilspy/ilspycmd"
) or
process.parent.executable in (
"/usr/libexec/nordlayer/nordlayer-resolvconf", "/usr/bin/gnome-shell", "./runc", "/usr/bin/make", "/usr/bin/sudo",
"/usr/bin/timeout", "/usr/local/bin/ctest", "/usr/lib64/dotnet/dotnet", "/tmp/dotnet-sdk/dotnet"
) or
process.parent.executable like (
"/tmp/.tmp*/.vscode-server/bin/*/node", "/usr/bin/nordlayer", "/root/.vscode-server/cli/servers/*/server/node",
"/vscode/vscode-server/bin/*/node", "/tmp/vscode-*/server/node", "/root/.npm/_npx/*/node_modules/bun/bin/bun.exe",
"/home/*/.dotnet/dotnet", "/home/*/.*-code/bin/codex", "/home/*/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo",
"/opt/micromamba/bin/python*", "/root/.vscode/cli/servers/*/node", "/root/actions-runner/externals.*/bin/node", "/tmp/*.AppImage",
"/home/*/.codex/packages/standalone/releases/*/bin/codex"
) or
(
process.executable == "memfd:lxc-attach" and
process.parent.executable == "/usr/lib/openssh/sshd-session"
)
)]
[process where event.type == "start" and event.action == "memfd_create"]