Potential Privilege Escalation via unshare and UID Change
This rule detects potential privilege escalation attempts on Linux systems by identifying suspicious use of the `unshare` command to create user namespaces followed by a UID change to root, indicative of local privilege escalation.
Triage facts
Revision 2- Applicability
- Elastic Defend, Elastic Endpoint
- Evidence
- Unknown
- Severity
- High
- Sources
- 2 public sources
- Freshness
- Revision 2Jan 9, 18:23 UTC
- Detection
- 2 rules
Revision history 1 entry · Revision 2
- Revision 2
Repaired a legacy canonical identity collision
Changed: slug
This detection rule identifies potential privilege escalation attempts on Linux systems by monitoring the use of the unshare command and subsequent UID changes to root. The unshare command is used to create new namespaces, including user namespaces, which can be leveraged in exploit chains. Attackers may use unshare with user namespace flags as a preliminary step before escalating privileges to root. This behavior can indicate successful exploitation of vulnerabilities, such as those related to OverlayFS, or other local privilege escalation techniques. This detection is intentionally generic to surface multiple local privilege escalation patterns beyond a single CVE. The rule focuses on detecting a sequence of events where a non-root user executes unshare with user-namespace related arguments followed by a UID change event indicating the user has become root.
Attack Chain
- A non-root user executes the
unsharecommand with arguments indicating the creation of a new user namespace (e.g.,-U,--user,-r,-rm,m). - The
unsharecommand creates a new user namespace context for the process. - Within the newly created namespace, the attacker attempts to change the user ID (UID) to 0 (root).
- The system logs a
uid_changeevent, indicating that the user's UID has been changed to 0 within the namespace. - The attacker executes further commands as root within the new namespace.
- These commands may involve exploiting vulnerabilities, modifying system files, or installing malicious software.
- The attacker may attempt to escape the namespace to gain root privileges on the host system.
- The final objective is to gain persistent root access to the system, allowing for complete control and potential data exfiltration or system compromise.
Impact
Successful exploitation can lead to complete system compromise, allowing the attacker to perform any action with root privileges. This can result in data theft, system disruption, or the installation of backdoors for persistent access. The number of victims can vary depending on the scope of the attack, but even a single successful privilege escalation can have severe consequences. Targeted sectors are broad, including any Linux-based system where unprivileged users have access to the unshare command, such as cloud workloads and traditional endpoints.
Recommendation
- Deploy the provided Sigma rule to your SIEM to detect suspicious
unshareusage followed by UID changes (Potential Privilege Escalation via unshare and UID Change). - Investigate any detected instances of
unshareusage with user namespace arguments and subsequent UID changes to root, as described in the rule description. - Review and restrict the use of
unshareand user namespaces if not required in your environment to mitigate the risk of privilege escalation. - Enable Elastic Defend integration to collect the necessary process and event data required for the Sigma rule to function effectively (Elastic Defend integration).
- Monitor process execution for commands run after the
uid_changeevent to identify potentially malicious activities.
Detection coverage 2
Detect Potential Privilege Escalation via unshare and UID Change
highDetects potential privilege escalation attempts by identifying the execution of `unshare` with user namespace arguments followed by a UID change to root.
Detect unshare Execution from Suspicious Locations
mediumDetects `unshare` execution from user-writable directories like /tmp or /dev/shm.
Detection queries are available on the platform. Get full rules →