MacOS: Out-of-bounds write in RawCamera
There is an out-of-bounds write vulnerability when decoding a certain flavor of RAW image files on macOS. The vulnerability has been confirmed on macOS 12.3.1.
A zipped proof of concept file is attached. The easiest way to demonstrate the vulnerability is doubleclick the crash.raw file to open it in Preview, after which Preview will crash with the call stack provided below.
Process 2146 stopped
* thread #4, queue = 'ProviderImageSurfaceCacheQueue', stop reason = EXC_BAD_ACCESS (code=1, address=0x123971000)
frame #0: 0x00007ff91009f0a5 RawCamera`___lldb_unnamed_symbol2861$$RawCamera + 8643
RawCamera`___lldb_unnamed_symbol2861$$RawCamera:
-> 0x7ff91009f0a5 <+8643>: movw %ax, (%rcx)
0x7ff91009f0a8 <+8646>: movzbl -0x2(%rbx,%r14), %eax
0x7ff91009f0ae <+8652>: movzbl -0x2(%rbx,%r12), %ecx
0x7ff91009f0b4 <+8658>: shlq $0x8, %rax
Target 0: (Preview) stopped.
(lldb) bt
* thread #4, queue = 'ProviderImageSurfaceCacheQueue', stop reason = EXC_BAD_ACCESS (code=1, address=0x123971000)
* frame #0: 0x00007ff91009f0a5 RawCamera`___lldb_unnamed_symbol2861$$RawCamera + 8643
frame #1: 0x00007ff9100a0047 RawCamera`___lldb_unnamed_symbol2866$$RawCamera + 563
frame #2: 0x00007ff90ffda53b RawCamera`___lldb_unnamed_symbol441$$RawCamera + 361
frame #3: 0x00007ff91006b69e RawCamera`___lldb_unnamed_symbol2032$$RawCamera + 109
frame #4: 0x00007ff80c733dfd CoreImage`__103-[CIImage(CIImageProvider) _initWithImageProvider:width:height:format:colorSpace:surfaceCache:options:]_block_invoke + 47
frame #5: 0x00007ff80c955f67 CoreImage`invocation function for block in CI::ProviderNode::surfaceForROI(CI::Context const*, CGRect const&) const + 197
frame #6: 0x00007ff80c6f2d80 CoreImage`SurfaceApplyPlaneBlock + 381
frame #7: 0x00007ff80c955e9c CoreImage`invocation function for block in CI::ProviderNode::surfaceForROI(CI::Context const*, CGRect const&) const + 87
frame #8: 0x00007ff80c725e89 CoreImage`invocation function for block in CI::SurfaceCacheEntry::fillAsync() + 114
frame #9: 0x00007ff8032920cc libdispatch.dylib`_dispatch_call_block_and_release + 12
frame #10: 0x00007ff803293317 libdispatch.dylib`_dispatch_client_callout + 8
frame #11: 0x00007ff803299317 libdispatch.dylib`_dispatch_lane_serial_drain + 672
frame #12: 0x00007ff803299e30 libdispatch.dylib`_dispatch_lane_invoke + 417
frame #13: 0x00007ff8032a3eee libdispatch.dylib`_dispatch_workloop_worker_thread + 753
frame #14: 0x00007ff80344afd0 libsystem_pthread.dylib`_pthread_wqthread + 326
frame #15: 0x00007ff803449f57 libsystem_pthread.dylib`start_wqthread + 15
This bug is subject to a 90-day disclosure deadline. If a fix for this
issue is made available to users before the end of the 90-day deadline,
this bug report will become public 30 days after the fix was made
available. Otherwise, this bug report will become public at the deadline.
The scheduled deadline is 2022-07-27.
Related CVE Numbers: CVE-2022-32802.
Found by: ifratric@google.com