Shell Privileged Mode from Non-Standard Path with Root Effective User
Description
Detects a process execution with the privileged mode flag where the effective user is root but the real user name is not root, and the executable is outside common system binary directories. This pattern is often used after exploiting a setuid shell or similar to drop restrictions while keeping an elevated effective identity.
Query · eql
process where event.action == "exec" and user.name == "root" and user.Ext.real.name != "root" and
user.Ext.real.name != null and process.args == "-p" and
process.executable != null and process.parent.executable != null and
process.executable like ("/var/tmp/*", "/tmp/*", "/dev/shm/*", "/run/*", "/var/run/*") and
not (process.executable like "/tmp/newroot/usr/bin/*" and process.parent.executable like "/tmp/newroot/bin/*") and
not (process.executable like "/run/k3s/containerd/*" and process.parent.executable like "/run/k3s/containerd/*") and
not process.executable in ("/tmp/newroot/usr/sbin/sudo", "/tmp/newroot/usr/bin/sudo")