Twenty Year Anniversary

Apple updateRateSetAsyncCallback Heap Overflow

Apple updateRateSetAsyncCallback Heap Overflow
Posted Sep 22, 2017
Authored by Google Security Research, laginimaineb

A heap overflow vulnerability exists in Apple's updateRateSetAsyncCallback when handling ioctl results.

tags | advisory, overflow
systems | apple
advisories | CVE-2017-7108
MD5 | 1e92daae67494ac51cfa3e9e9cd67bce

Apple updateRateSetAsyncCallback Heap Overflow

Change Mirror Download
Apple: Heap overflow in "updateRateSetAsyncCallback" when handling ioctl results 

CVE-2017-7108


Broadcom produces Wi-Fi HardMAC SoCs which are used to handle the PHY and MAC layer processing. These chips are present in both mobile devices and Wi-Fi routers, and are capable of handling many Wi-Fi related events without delegating to the host OS. On iOS, the "AppleBCMWLANBusInterfacePCIe" driver is used in order to handle the PCIe interface and low-level communication protocols with the Wi-Fi SoC (also referred to as "dongle"). Similarly, the "AppleBCMWLANCore" driver handles the high-level protocols and the Wi-Fi configuration.

Along with the regular flow of frames transferred between the host and the dongle, the two communicate with one another via a set of "ioctls" which can be issued to read or write dongle configuration from the host. This information is exchanged using the "Control Completion" ring, rather than the regular "RX" ring.

When handling certain events, such as link status changes (indicated by the firmware-originated "WLC_E_LINK" event frame), the "AppleBCMWLANCore" driver updates the rate-set. This is done by issuing an asynchronous ioctl to the firwmare using the WLC_GET_CURR_RATESET (114) command code. Upon completion, this ioctl is handled by the "updateRateSetAsyncCallback" function, which performs the following high-level logic:

int64_t updateRateSetAsyncCallback(void* this, ..., uint64_t error_code, void **ptr_to_result_struct) {

void* result_buf = *ptr_to_result_struct;
uint8_t results[0x14];

if (error_code) {
//Handle error...
}

else if (result_buf) {
memmove(results, results_buf, 0x14);
save_rate_set((uint8_t*)this + 2196, results);
...
}

...
}

void save_rate_set(void* this, uint8_t* rate_set_buffer)
{
uint32_t num_entries = *((uint32_t*)rate_set_buffer);
*((uint16_t*)this + 2) = (uint16_t)num_entries;

if (!num_entries)
return;

uint32_t* save_ptr = (uint32_t*)((uint8_t*)this + 16);
uint8_t* rates_array = rate_set_buffer + sizeof(uint32_t);

for (uint32_t i=0; i<num_entries; i++, save_ptr += 3) {
save_ptr[-1] = rates_array[i] & 0x3F;
save_ptr[0] = rates_array[i] >> 7;
}
}

As can be seen above, both "updateRateSetAsyncCallback" and the helper function (named "save_rate_set" in the snippet above) make no attempts to validate the length field returned from the firmware in the ioctl response. As a result, an attacker controlling the firmware may choose an arbitrarily large value. Doing so will cause the copy loop in "save_rate_set" to copy data out-of-bounds into the buffer at (this + 2196). Note that the buffer's length is only 0xBC, but the attacker can cause arbitrarily many bytes to by copied. Since the data is copied from the stack buffer to which the ioctl's results were originally transferred, the OOB bytes will contain information from the stack, removing some degree of control over the copied contents.

This bug is subject to a 90 day disclosure deadline. After 90 days elapse
or a patch has been made broadly available, the bug report will become
visible to the public.




Found by: laginimaineb

Comments

RSS Feed Subscribe to this comment feed

No comments yet, be the first!

Login or Register to post a comment

File Archive:

September 2018

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Sep 1st
    1 Files
  • 2
    Sep 2nd
    3 Files
  • 3
    Sep 3rd
    15 Files
  • 4
    Sep 4th
    15 Files
  • 5
    Sep 5th
    18 Files
  • 6
    Sep 6th
    18 Files
  • 7
    Sep 7th
    15 Files
  • 8
    Sep 8th
    2 Files
  • 9
    Sep 9th
    2 Files
  • 10
    Sep 10th
    16 Files
  • 11
    Sep 11th
    17 Files
  • 12
    Sep 12th
    15 Files
  • 13
    Sep 13th
    29 Files
  • 14
    Sep 14th
    21 Files
  • 15
    Sep 15th
    3 Files
  • 16
    Sep 16th
    1 Files
  • 17
    Sep 17th
    15 Files
  • 18
    Sep 18th
    16 Files
  • 19
    Sep 19th
    29 Files
  • 20
    Sep 20th
    18 Files
  • 21
    Sep 21st
    5 Files
  • 22
    Sep 22nd
    2 Files
  • 23
    Sep 23rd
    2 Files
  • 24
    Sep 24th
    15 Files
  • 25
    Sep 25th
    22 Files
  • 26
    Sep 26th
    0 Files
  • 27
    Sep 27th
    0 Files
  • 28
    Sep 28th
    0 Files
  • 29
    Sep 29th
    0 Files
  • 30
    Sep 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2018 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close