Potential Fileless Execution via Memory File Descriptor from Interpreter
Description
Detects when an interpreter process creates a memory file descriptor and executes a command in the proc 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.
Query · eql
process where event.type == "start" and event.action == "memfd_create" and (
(process.name like "python*" and process.args == "-c") or
(process.name like ("perl*", "ruby*", "lua*", "node", "nodejs") and process.args like "-e*") or
(process.name like "php*" and process.args like "-r*") or
process.name like ("*.py", "*.pyc", "*.lua", "*.pl", "*.rb", "*.bin", "*.php", "*.js", "*.mjs") or
(
process.name like ("python*", "perl*", "php*", "ruby*", "lua*", "node", "java", "javaw") and
(
process.args like (
"/tmp/*", "/var/tmp/*", "/dev/shm/*", "/run/user/*", "/var/run/user/*", "/root/*",
"/boot/*", "/sys/*", "/lost+found/*", "/proc/*", "/var/mail/*", "/var/www/*"
) and process.args_count <= 2
)
)
) and not (
process.executable like (
"/usr/lib/libreoffice/program/soffice.bin", "/app/bin/evolution.bin", "/opt/cpanel/ea-php83/root/usr/bin/php-cgi",
"/snap/libreoffice/*/lib/libreoffice/program/soffice.bin", "/usr/NX/bin/nxrunner.bin",
"/usr/lib64/libreoffice/program/soffice.bin", "/opt/libreoffice*/program/soffice.bin", "/opt/hrt/hrtpylon-*/bin/python3*",
"/usr/NX/bin/nxplayer.bin", "/usr/bin/qgis.bin", "/opt/gitlab/embedded/bin/ruby", "/app/libreoffice/program/soffice.bin",
"/ztank/sw/eb/sw/Python/*/bin/python*", "/sw/eb/sw/Python/*/bin/python*",
"/opt/micromamba/bin/python*", "/opt/balenaEtcher/balena-etcher.bin"
) or
process.parent.command_line == "/bin/sh -e /usr/lib/php/sessionclean" or
(
process.name like "php*" and (
process.Ext.memfd.name in (
"memfd:opcache_lock", "anon_hugepage", "opcache_lock", "memfd:anon-handle",
"memfd:anon-shm-handle", "memfd:trampoline_dependencies.so", "memfd:spawn_worker_trampoline"
) or
process.command_line == "php public/index.php"
)
) or
(
process.name like "python*" and
process.Ext.memfd.name like (
"wayland-shm", "memfd:pulseaudio", "memfd:dd_inject_info", "memfd:dd_language_detected", "wayland-cursor",
"memfd:wayland-cursor", "pulseaudio", "datadog-tracer-info*", "memfd:datadog-tracer-info-*", "memfd:libffi",
"libffi", "memfd:xshmfence", "xshmfence", "JITCode*", "unknown-usage*", "JSVMStack*", "JSGCHeap*",
"OTEL_CTX", "memfd:OTEL_CTX"
)
) or
(
process.name like ("ruby*", "node", "nodejs") and
process.Ext.memfd.name like ("OTEL_CTX", "memfd:OTEL_CTX")
) or
(
process.name like "ruby*" and
process.Ext.memfd.name like ("memfd:libffi", "libffi")
) or
(
process.name like ("node", "nodejs") and
process.Ext.memfd.name like ("datadog-tracer-info*", "memfd:datadog-tracer-info-*")
) or
process.parent.executable like (
"/opt/saltstack/salt/bin/python3*", "/usr/lib/systemd/systemd", "/usr/bin/gnome-shell", "/usr/NX/bin/nxexec",
"/usr/bin/sddm", "/usr/bin/bwrap", "/usr/bin/rofi", "/usr/bin/dbus-daemon", "/tmp/.mount_*/lm-studio",
"/usr/libexec/gnome-session-binary", "/usr/local/aegis/AliSecCheckTmp/AliSecCheck", "./runc",
"/snap/claude-ai-desktop/*/app/claude-desktop.bin", "/home/*/Programy/WBEST-MNT/WBEST-MNTv1_0_Linux",
"/opt/LM-Studio/lm-studio", "/var/lib/rancher/rke2/data/*/bin/runc", "/var/lib/rancher/rke2/data/*/bin/containerd-shim-runc-v2",
"/usr/local/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl/bin/codex"
) or
process.parent.command_line in ("/bin/sh /usr/local/bin/docker-php-ext-enable xdebug", "/usr/bin/python3 /usr/bin/nobara-updater --all") or
process.parent.command_line like "*/home/*/.claude/shell-snapshots/snapshot-*" or
(
process.command_line == "buildah-chroot-runtime" and
process.Ext.memfd.name == "memfd:buildah-chroot-runtime"
) or
(
process.name like "ruby*" and
process.args == "-e" and
process.args == "sandbox"
) or
(
process.name like "ruby*" and
process.Ext.memfd.name like "memfd:datadog-tracer-info-*"
) or
(
process.executable == "/usr/bin/perl" and
process.Ext.memfd.name in ("memfd:dd_inject_info", "memfd:dd_language_detected")
) or
(process.name like "python3*" and process.args == "/usr/bin/supervisord") or
(process.name == "node" and process.args == "appCron.js")
)