Potential Privilege Escalation via unshare and UID Change
This rule detects potential privilege escalation attempts on Linux systems by monitoring the use of `unshare` with user namespace-related arguments followed by a UID change to root, indicating a transition to root and a potential local privilege escalation.
This detection rule identifies potentially suspicious use of the unshare command, a utility used to create new namespaces, followed by a UID change to root (UID 0) on Linux systems. Adversaries may leverage unshare-based primitives as part of local privilege escalation chains. The rule specifically looks for scenarios where a non-root user executes unshare with user namespace related arguments (such as -r, -rm, -m, -U, or --user) and a subsequent uid_change event indicating the user has transitioned to root. This pattern can indicate a successful local privilege escalation attempt. This rule is intentionally generic to surface multiple local privilege escalation patterns beyond a single CVE.
Attack Chain
- A non-root user executes the
unsharecommand. - The
unsharecommand is executed with arguments indicating the creation of a user namespace (e.g.,-r,-rm,-m,-U,--user). - The system creates a new user namespace as requested by the
unsharecommand. - Within the new user namespace, the attacker attempts to change the user ID (UID).
- The UID is successfully changed to 0, indicating root privileges within the namespace.
- The process attempts to perform privileged actions within the new user namespace.
- The attacker exploits the elevated privileges to potentially access sensitive data or execute arbitrary code.
Impact
Successful exploitation can lead to complete system compromise, allowing attackers to install malware, modify system configurations, access sensitive data, or move laterally within the network. The potential impact ranges from data breaches and service disruption to complete system takeover, impacting confidentiality, integrity, and availability.
Recommendation
- Deploy the Sigma rule “Potential Privilege Escalation via unshare and UID Change” to your SIEM and tune for your environment to detect the described behavior.
- Enable Elastic Defend integration for endpoint data collection to ensure the required logs are available for the Sigma rule.
- Review the process tree of processes triggering the detection, specifically the parent process of
unshare, to identify the origin of the command execution as described in the “Triage and Analysis” section. - Investigate other host signals around the same time as the
unshareanduid_changeevents for any other suspicious activity, such as suspicious downloads or execution of unusual binaries as described in the “Triage and Analysis” section.
Detection coverage 2
Potential Privilege Escalation via unshare and UID Change
highDetects suspicious use of unshare to create a user namespace context followed by a UID change event indicating a transition to root.
Potential Privilege Escalation via unshare with specific arguments
mediumDetects suspicious use of unshare command with specific arguments often used in privilege escalation exploits.
Detection queries are available on the platform. Get full rules →