Talos Vulnerability Report

TALOS-2018-0564

Computerinsel Photoline PCX Bits Per Pixel Code Execution Vulnerability

April 11, 2018
CVE Number

CVE-2018-3889

Summary

A memory corruption vulnerability exists in the PCX-parsing functionality of Computerinsel Photoline 20.53. A specially crafted PCX image processed via the application can lead to an out-of-bounds write, overwriting arbitrary data. An attacker can deliver a PCX image to trigger this vulnerability and gain code execution.

Tested Versions

Computerinsel Photoline 20.53 for OS X

Product URLs

https://www.pl32.com/

CVSSv3 Score

8.8 - CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H

CWE

CWE-787: Out-of-bounds Write

Details

Photoline is an image processing tool used to modify and edit images, as well as other graphic-editing functions. This product has a large user base, and is popular in its specific field. The vulnerable component is in the handling of PCX images. PCX was a popular image format with early computers, and although has been replaced by more sophisticated formats, it is still in use and fully supported inside of Canvas Draw.

The vulnerability arises in parsing the PCX image, specifically dealing with the decompression of the color map of the image. The compression scheme is determined via the file header and by choosing "run length encoding" as the compression, the program writes out of bounds using user-controlled data. The error comes due to incorrectly calculating the size of the compressed data. In the main parsing loop, there is a function selector based on the value below.

selector = a1->planes * a1->bits_per_pixel;

Both values represented are taken directly from the image header itself. If passed in a crafted image, a vulnerable function can be called. The code from the vulnerable function is shown below.

      run_length = packet_byte & 0x3F;       [0]       
      count = 0LL;
      do
        image_buf[count++] = *data_byte;     [1]
      while ( count < run_length );
      image_buf += count;

The run_length value [0] is read in from the image itself and is used as a loop counter without validation. By passing in successively large run_length values, this buffer can be taken out of bounds. Subsequently, [1] an out-of-bounds write is created and an exploitable condition arises. This then could be used to gain code execution.

Crash Information

 Crashed thread log = 
: Dispatch queue: com.apple.main-thread
0   de.pl32.photoline               0x000000010dc9468c 0x10d263000 + 10688140
1   de.pl32.photoline               0x000000010dc953b3 0x10d263000 + 10691507
2   de.pl32.photoline               0x000000010d3a3481 0x10d263000 + 1311873
3   de.pl32.photoline               0x000000010d3a3302 0x10d263000 + 1311490
4   de.pl32.photoline               0x000000010d3a2ff4 0x10d263000 + 1310708
5   de.pl32.photoline               0x000000010d7d8d42 0x10d263000 + 5725506
6   de.pl32.photoline               0x000000010d415688 0x10d263000 + 1779336
7   de.pl32.photoline               0x000000010d4153db 0x10d263000 + 1778651
8   de.pl32.photoline               0x000000010d4727c2 0x10d263000 + 2160578
9   de.pl32.photoline               0x000000010dc8ec0a 0x10d263000 + 10664970
10  de.pl32.photoline               0x000000010dc8efb2 0x10d263000 + 10665906
11  com.apple.AppKit                0x00007fffafccfdd7 -[NSDocument _initWithContentsOfURL:ofType:error:] + 172
12  com.apple.AppKit                0x00007fffafccfcbc -[NSDocument initWithContentsOfURL:ofType:error:] + 231
13  com.apple.AppKit                0x00007fffafdad2b0 -[NSDocumentController makeDocumentWithContentsOfURL:ofType:error:] + 644
14  com.apple.AppKit                0x00007fffb0000470 __97-[NSDocumentController makeDocumentWithContentsOfURL:alternateContents:ofType:completionHandler:]_block_invoke + 83
15  com.apple.AppKit                0x00007fffb0000412 -[NSDocumentController makeDocumentWithContentsOfURL:alternateContents:ofType:completionHandler:] + 176
16  com.apple.AppKit                0x00007fffafdac2e6 __80-[NSDocumentController openDocumentWithContentsOfURL:display:completionHandler:]_block_invoke + 613
17  com.apple.AppKit                0x00007fffaffff48b __144-[NSDocumentController _coordinateReadingAndGetAlternateContentsForOpeningDocumentAtURL:resolvingSymlinks:thenContinueOnMainThreadWithAccessor:]_block_invoke_2.922 + 180
18  com.apple.AppKit                0x00007fffaffff3a7 __144-[NSDocumentController _coordinateReadingAndGetAlternateContentsForOpeningDocumentAtURL:resolvingSymlinks:thenContinueOnMainThreadWithAccessor:]_block_invoke.921 + 138
19  com.apple.AppKit                0x00007fffaffff269 __144-[NSDocumentController _coordinateReadingAndGetAlternateContentsForOpeningDocumentAtURL:resolvingSymlinks:thenContinueOnMainThreadWithAccessor:]_block_invoke_4 + 267
20  com.apple.CoreFoundation        0x00007fffb1fd717c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
21  com.apple.CoreFoundation        0x00007fffb1fb7f84 __CFRunLoopDoBlocks + 356
22  com.apple.CoreFoundation        0x00007fffb1fb7705 __CFRunLoopRun + 917
23  com.apple.CoreFoundation        0x00007fffb1fb7114 CFRunLoopRunSpecific + 420
24  com.apple.HIToolbox             0x00007fffb1517ebc RunCurrentEventLoopInMode + 240
25  com.apple.HIToolbox             0x00007fffb1517bf9 ReceiveNextEventCommon + 184
26  com.apple.HIToolbox             0x00007fffb1517b26 _BlockUntilNextEventMatchingListInModeWithFilter + 71
27  com.apple.AppKit                0x00007fffafaaea54 _DPSNextEvent + 1120
28  com.apple.AppKit                0x00007fffb022a7ee -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 2796
29  com.apple.AppKit                0x00007fffafaa33db -[NSApplication run] + 926
30  de.pl32.photoline               0x000000010dc8ba19 0x10d263000 + 10652185
31  com.apple.AppKit                0x00007fffafa6de0e NSApplicationMain + 1237
32  de.pl32.photoline               0x000000010d264d14 0x10d263000 + 7444

log name is: ./crashlogs/1.crashlog.txt
---
exception=EXC_BAD_ACCESS:signal=11:is_exploitable=yes:instruction_disassembly=movb  %dl,(%rcx,%rsi):instruction_address=0x000000010dc9468c:access_type=write:access_address=0x00000001a743a000:
Crash accessing invalid address.

Timeline

2018-04-09 - Vendor Disclosure
2018-04-11 - Public Release

Credit

Discovered by Tyler Bohan of Cisco Talos.