Exploit the possiblities

Broadcom dhd_pno_process_anqpo_result Memory Corruption

Broadcom dhd_pno_process_anqpo_result Memory Corruption
Posted Apr 9, 2017
Authored by Google Security Research, laginimaineb

Broadcom suffers from multiple memory corruption vulnerabilities in dhd_pno_process_anqpo_result.

tags | advisory, vulnerability
advisories | CVE-2017-0572
MD5 | 2dc3d8eea3cfa751933b4df35161ec6f

Broadcom dhd_pno_process_anqpo_result Memory Corruption

Change Mirror Download
 Broadcom: Multiple memory corruptions in "dhd_pno_process_anqpo_result" 

CVE-2017-0572


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 Android devices, the "bcmdhd" driver is used in order to communicate with the Wi-Fi SoC (also referred to as "dongle").

When the dongle wishes to notify the host OS of an event, it does so by encoding a special "packet" and transmitting it to the host. These packets have an ether type of 0x886C (referred to as ETHER_TYPE_BRCM), and do not contain actual packet data, but rather encapsulate information about events which must be handled by the driver.

After reading packets from the SDIO interface, the "bcmdhd" driver calls the function "dhd_rx_frame" to handle each of the received frames. If a frame has the special Broadcom ether type, it is passed on to an internal handling function, "dhd_wl_host_event". This function inspects the event code, and passes it onto the registered handlers for the given event type.

The function "wl_notify_gscan_event" is the registered handler for events of the following types:
-WLC_E_PFN_BEST_BATCHING
-WLC_E_PFN_SCAN_COMPLETE
-WLC_E_PFN_GSCAN_FULL_RESULT
-WLC_E_PFN_SWC
-WLC_E_PFN_BSSID_NET_FOUND
-WLC_E_PFN_BSSID_NET_LOST
-WLC_E_PFN_SSID_EXT
-WLC_E_GAS_FRAGMENT_RX
(for reference, see "wl_init_event_handler")

Specifically, when the event code "WLC_E_PFN_BSSID_NET_FOUND" is received, the gscan handler function calls "dhd_pno_process_anqpo_result" in order to process the event's data, like so:

1. dhd_pno_process_anqpo_result(dhd_pub_t *dhd, const void *data, uint32 event, int *size)
2. {
3. wl_bss_info_t *bi = (wl_bss_info_t *)data;
4. wifi_gscan_full_result_t *result = NULL;
5. wl_event_gas_t *gas_data = (wl_event_gas_t *)((uint8 *)data +
6. bi->ie_offset +
7. bi->ie_length);
8. ...
9. uint32 mem_needed = OFFSETOF(wifi_gscan_full_result_t, ie_data) +
10. bi->ie_length +
11. OFFSETOF(wl_event_gas_t, data) + gas_data->data_len +
12. sizeof(int);
13. result = (wifi_gscan_full_result_t *) kmalloc(mem_needed, GFP_KERNEL);
14. if (result == NULL) {
15. DHD_ERROR(("%s Cannot Malloc %d bytes!!\n", __FUNCTION__, mem_needed));
16. return NULL;
17. }
18. memcpy(result->fixed.ssid, bi->SSID, bi->SSID_len);
19. result->fixed.ssid[bi->SSID_len] = '\0';
20. ...
21. memcpy(result->ie_data, ((uint8 *)bi + bi->ie_offset), bi->ie_length);
22. return result;
23. }

(where "data" is the arbitrary data encapsulated in the event passed in from the dongle)

First, in line 18 the function uses the "bi->SSID_len" argument in order to copy the SSID from the event to the destination buffer ("result"), but fails to verify that it does not exceed the maximal SSID length (32). Assuming an attacker has arbitrary control over the dongle, they would be able to overflow the allocated buffer by setting:
- bi->ie_length = 0
- bi->SSID_len = 255

Since OFFSETOF(wifi_gscan_full_result_t, ie_data) == 86 and OFFSETOF(wl_event_gas_t, data) + gas_data->data_len == 8, the size of the allocated buffer will only be 86 + 8 + 4 = 98, causing the memcpy call above to overflow it.

Alternately, an attacker controlling the dongle could supply an abnormally large value in "bi->ie_length" (which is a uint32_t). This would cause the calculation of "mem_needed" (lines 9-12) to overflow, resulting in a small value. However, later in the function an additional memcpy operation is performed using the value of "bi->ie_length", thus overflowing the allocated buffer.

I've been able to statically verify these issues on the "bcmdhd-3.10" driver, and in the corresponding "bcmdhd" driver on the Nexus 6P's kernel (angler).

This bug is subject to a 90 day disclosure deadline. If 90 days elapse
without a broadly available patch, then the bug report will automatically
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

Want To Donate?


Bitcoin: 18PFeCVLwpmaBuQqd5xAYZ8bZdvbyEWMmU

File Archive:

January 2018

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Jan 1st
    2 Files
  • 2
    Jan 2nd
    13 Files
  • 3
    Jan 3rd
    16 Files
  • 4
    Jan 4th
    39 Files
  • 5
    Jan 5th
    26 Files
  • 6
    Jan 6th
    40 Files
  • 7
    Jan 7th
    2 Files
  • 8
    Jan 8th
    16 Files
  • 9
    Jan 9th
    25 Files
  • 10
    Jan 10th
    28 Files
  • 11
    Jan 11th
    44 Files
  • 12
    Jan 12th
    32 Files
  • 13
    Jan 13th
    2 Files
  • 14
    Jan 14th
    4 Files
  • 15
    Jan 15th
    31 Files
  • 16
    Jan 16th
    15 Files
  • 17
    Jan 17th
    16 Files
  • 18
    Jan 18th
    24 Files
  • 19
    Jan 19th
    15 Files
  • 20
    Jan 20th
    5 Files
  • 21
    Jan 21st
    1 Files
  • 22
    Jan 22nd
    15 Files
  • 23
    Jan 23rd
    12 Files
  • 24
    Jan 24th
    0 Files
  • 25
    Jan 25th
    0 Files
  • 26
    Jan 26th
    0 Files
  • 27
    Jan 27th
    0 Files
  • 28
    Jan 28th
    0 Files
  • 29
    Jan 29th
    0 Files
  • 30
    Jan 30th
    0 Files
  • 31
    Jan 31st
    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