Exploit-DB #42235
Description: Microsoft Windows - 'USP10!ttoGetTableData' Uniscribe Font Processing Out-of-Bounds Memory Read
Type: dos
Platform: windows
Date: 2017-06-23
Author: Google Security Research

Exploit:
Source: https://bugs.chromium.org/p/project-zero/issues/detail?id=1199

We have encountered a crash in the Windows Uniscribe user-mode library, in the USP10!ttoGetTableData function, while trying to display text using a corrupted TTF font file:

---
(210.274): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
eax=000002f6 ebx=000000d0 ecx=0361c003 edx=0000d0d0 esi=0361c000 edi=016101e4
eip=774d3d43 esp=0046f1e0 ebp=0046f1f0 iopl=0         nv up ei pl nz na pe nc
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00010206
USP10!ttoGetTableData+0x1aa3:
774d3d43 660fb606        movzx   ax,byte ptr [esi]          ds:0023:0361c000=??

0:000> kb
 # ChildEBP RetAddr  Args to Child              
00 0046f1f0 774d2e10 [PII_REDACTED] 0361b734 USP10!ttoGetTableData+0x1aa3
01 0046f230 774d2d68 0361b73c 036255f8 0046f250 USP10!ttoGetTableData+0xb70
02 0046f258 774d22f1 036255f8 036255f8 0361b734 USP10!ttoGetTableData+0xac8
03 0046f26c 774c75b8 03619fd0 036199d0 0046f308 USP10!ttoGetTableData+0x51
04 0046f2cc 774c7[PII_REDACTED]a 035b3d88 035c1fa8 USP10!LoadTTOArabicShapeTables+0x3e8
05 0046f2e0 774cc734 9a010536 035b3d88 035a6124 USP10!LoadArabicShapeTables+0xd4
06 0046f2fc 774ba5a0 9a[PII_REDACTED]97d0 0000001a USP10!ArabicLoadTbl+0xd4
07 0046f324 774ba692 035a6124 9a[PII_REDACTED]001a USP10!UpdateCache+0xb0
08 0046f338 774c15fd 9a010536 035a6000 774c16ab USP10!ScriptCheckCache+0x62
09 0046f344 774c16ab [PII_REDACTED] 00000000 USP10!GetShapeFunction+0xd
0a 0046f37c 774c2bd4 [PII_REDACTED] 0046f3fc USP10!RenderItemNoFallback+0x5b
0b 0046f3a8 774c2e62 [PII_REDACTED] 0046f3fc USP10!RenderItemWithFallback+0x104
0c 0046f3cc 774c43f9 00[PII_REDACTED]f3fc 035a6124 USP10!RenderItem+0x22
0d 0046f410 774b7a04 000004a0 00000400 9a010536 USP10!ScriptStringAnalyzeGlyphs+0x1e9
0e 0046f428 760a1736 9a010536 035a6[PII_REDACTED]a USP10!ScriptStringAnalyse+0x284
0f 0046f474 760a18c1 9a[PII_REDACTED]f8f8 0000000a LPK!LpkStringAnalyse+0xe5
10 0046f570 760a17b4 9a010536 [PII_REDACTED] LPK!LpkCharsetDraw+0x332
11 0046f5a4 77df56a9 9a010536 [PII_REDACTED] LPK!LpkDrawTextEx+0x40
12 0046f5e4 77df5a64 9a010536 [PII_REDACTED] USER32!DT_DrawStr+0x13c
13 0046f630 77df580f 9a[PII_REDACTED]f8f8 0046f90c USER32!DT_GetLineBreak+0x78
14 0046f6dc 77df5882 9a[PII_REDACTED]0[PII_REDACTED]a USER32!DrawTextExWorker+0x250
15 0046f700 77df5b68 9a[PII_REDACTED]f8f8 ffffffff USER32!DrawTextExW+0x1e
[...]

0:000> !heap -p -a esi-1
    address 0361bfff found in
    _DPH_HEAP_ROOT @ 35a1000
    in busy allocation (  DPH_HEAP_BLOCK:         UserAddr         UserSize -         VirtAddr         VirtSize)
                                 35a1780:          361b1b0              e4e -          361b000             2000
    73448e89 verifier!AVrfDebugPageHeapAllocate+0x00000229
    77d26206 ntdll!RtlDebugAllocateHeap+0x00000030
    77cea127 ntdll!RtlpAllocateHeap+0x000000c4
    77cb5950 ntdll!RtlAllocateHeap+0x0000023a
    7433ae6a vrfcore!VerifierSetAPIClassName+0x000000aa
    774c6724 USP10!UspAllocCache+0x00000054
    774c728f USP10!LoadTTOArabicShapeTables+0x000000bf
    774c7124 USP10!LoadArabicShapeTables+0x000000d4
    774cc734 USP10!ArabicLoadTbl+0x000000d4
    774ba5a0 USP10!UpdateCache+0x000000b0
    774ba692 USP10!ScriptCheckCache+0x00000062
    774c15fd USP10!GetShapeFunction+0x0000000d
    774c2bd4 USP10!RenderItemWithFallback+0x00000104
    774c2e62 USP10!RenderItem+0x00000022
    774c43f9 USP10!ScriptStringAnalyzeGlyphs+0x000001e9
    774b7a04 USP10!ScriptStringAnalyse+0x00000284
    760a1736 LPK!LpkStringAnalyse+0x000000e5
    760a18c1 LPK!LpkCharsetDraw+0x00000332
    760a17b4 LPK!LpkDrawTextEx+0x00000040
    77df56a9 USER32!DT_DrawStr+0x0000013c
    77df5a64 USER32!DT_GetLineBreak+0x00000078
    77df580f USER32!DrawTextExWorker+0x00000250
    77df5882 USER32!DrawTextExW+0x0000001e
    77df5b68 USER32!DrawTextW+0x0000004d
    [...]
---

The issue reproduces on Windows 7, and could be potentially used to disclose sensitive data from the process heap. It is easiest to reproduce with PageHeap enabled, but it is also possible to observe a crash in a default system configuration. In order to reproduce the problem with the provided samples, it might be necessary to use a custom program which displays all of the font's glyphs at various point sizes.

Attached are 3 proof of concept malformed font files which trigger the crash.


Proof of Concept:
https://gitlab.com/exploit-database/exploitdb-bin-sploits/-/raw/main/bin-sploits/42235.zip