New issue
Advanced search Search tips
Starred by 2 users
Status: Fixed
Owner:
Closed: Mar 2017
Cc:



Sign in to add a comment
macOS/IOS: mach_msg doesn't copy memory in a certain case
Project Member Reported by lokihardt@google.com, Jan 17 2017 Back to list
When sending ool memory via |mach_msg| with |deallocate| flag or |MACH_MSG_VIRTUAL_COPY| flag, |mach_msg| performs moving the memory to the destination process instead of copying it. But it doesn't consider the memory entry object that could resurrect the moved memory. As a result, it could lead to a shared memory race condition.

Exploitation:
We need specific code that references the memory twice from |mach_msg|.
Here's a snippet of such a function |xpc_dictionary_insert|.

v14 = strlen(shared_memory);  <<-- 1st
v15 = _xpc_malloc(v14 + 41);
...
strcpy((char *)(v15 + 32), shared_memory);  <<-- 2nd

If we change the string's length bigger before |strcpy| is called, it will result in a heap overflow.

This bug is triggerable from a sandboxed process.

The attached PoC will crash diagnosticd(running as root). It requires more than 512MB memory to run.

Tested on macOS Sierra 10.12.2(16C67).

clang++ -o poc poc.cc -std=c++11


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.

 
poc.cc
14.3 KB View Download
Project Member Comment 1 by lokihardt@google.com, Jan 20 2017
Apple product security report ID: 657281024
Project Member Comment 2 by lokihardt@google.com, Mar 27 2017
Labels: CVE-2017-2456
Status: Fixed
Project Member Comment 3 by lokihardt@google.com, Mar 30 2017
Labels: -Restrict-View-Commit
Sign in to add a comment