Privilege Escalation (TA0004)(external, opens in a new tab or window)
text code block:sequence by host.id, process.parent.pid with maxspan=30s [process where host.os.type == "linux" and ( (auditd.data.syscall == "unshare" and auditd.data.class == "namespace" and auditd.data.a0 in ("10000000", "50000000", "70000000", "10020000", "50020000", "70020000")) or (process.name == "unshare" and (process.args in ("--user", "--map-root-user", "--map-current-user") or process.args like ("-*U*", "-*r*"))) ) and user.id != "0" and user.id != null] [process where host.os.type == "linux" and user.id == "0" and user.id != null and ( process.name in ("su", "sudo", "pkexec", "passwd", "chsh", "newgrp", "doas", "run0", "sg", "dash", "sh", "bash", "zsh", "fish", "ksh", "csh", "tcsh", "ash", "mksh", "busybox", "rbash", "rzsh", "rksh", "tmux", "screen", "node") or process.name like ("python*", "perl*", "ruby*", "php*", "lua*") )]
Install detection rules in Elastic Security
Detect Potential Privilege Escalation via unshare Followed by Root Process in the Elastic Security detection engine by installing this rule into your Elastic Stack.
To setup this rule, check out the installation guide for Prebuilt Security Detection Rules(external, opens in a new tab or window).