lovesuae / google-security-research

Automatically exported from code.google.com/p/google-security-research
0 stars 0 forks source link

FreeType 2.5.3 Type42 parsing out-of-bounds read in "ps_table_add" #183

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The following heap-based out-of-bounds memory read has been encountered in 
FreeType while fuzzing Type42 fonts. It has been reproduced with the current 
version of freetype2 from master git branch, with a 64-bit build of the ftbench 
utility compiled with AddressSanitizer:

$ ftbench <file>

Attached are three POC files which trigger the condition.

=================================================================
==5849==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x63000000e3bf 
at pc 0xa9c3ec bp 0x7fff3b0c6570 sp 0x7fff3b0c6568
READ of size 2 at 0x63000000e3bf thread T0
    #0 0xa9c3eb in ps_table_add freetype2/src/psaux/psobjs.c:216
    #1 0x7d4b41 in t42_parse_charstrings freetype2/src/type42/t42parse.c:871
    #2 0x7cc130 in t42_load_keyword freetype2/src/type42/t42parse.c:1007
    #3 0x7ca971 in t42_parse_dict freetype2/src/type42/t42parse.c:1154
    #4 0x7c4df8 in T42_Open_Face freetype2/src/type42/t42objs.c:57
    #5 0x7ba9ab in T42_Face_Init freetype2/src/type42/t42objs.c:196
    #6 0x4cc13e in open_face freetype2/src/base/ftobjs.c:1191
    #7 0x4c794b in FT_Open_Face freetype2/src/base/ftobjs.c:2123
    #8 0x4c5b58 in FT_New_Face freetype2/src/base/ftobjs.c:1254
    #9 0x491533 in get_face ft2demos-2.5.3/src/ftbench.c:705
    #10 0x48d748 in main ft2demos-2.5.3/src/ftbench.c:924

0x63000000e3bf is located 0 bytes to the right of 57279-byte region 
[0x630000000400,0x63000000e3bf)
allocated by thread T0 here:
    #0 0x472081 in __interceptor_malloc (ft2demos-2.5.3/bin/ftbench+0x472081)
    #1 0xaf265f in ft_alloc freetype2/src/base/ftsystem.c:74
    #2 0x526b21 in ft_mem_qalloc freetype2/src/base/ftutil.c:76
    #3 0x4aee0f in ft_mem_alloc freetype2/src/base/ftutil.c:55
    #4 0x7c7f51 in t42_parser_init freetype2/src/type42/t42parse.c:206
    #5 0x7c4c30 in T42_Open_Face freetype2/src/type42/t42objs.c:50
    #6 0x7ba9ab in T42_Face_Init freetype2/src/type42/t42objs.c:196
    #7 0x4cc13e in open_face freetype2/src/base/ftobjs.c:1191
    #8 0x4c794b in FT_Open_Face freetype2/src/base/ftobjs.c:2123
    #9 0x4c5b58 in FT_New_Face freetype2/src/base/ftobjs.c:1254
    #10 0x491533 in get_face ft2demos-2.5.3/src/ftbench.c:705
    #11 0x48d748 in main ft2demos-2.5.3/src/ftbench.c:924

SUMMARY: AddressSanitizer: heap-buffer-overflow 
freetype2/src/psaux/psobjs.c:216 ps_table_add
Shadow bytes around the buggy address:
  0x0c607fff9c20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c607fff9c30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c607fff9c40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c607fff9c50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c607fff9c60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c607fff9c70: 00 00 00 00 00 00 00[07]fa fa fa fa fa fa fa fa
  0x0c607fff9c80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c607fff9c90: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c607fff9ca0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c607fff9cb0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c607fff9cc0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Heap right redzone:      fb
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack partial redzone:   f4
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Contiguous container OOB:fc
  ASan internal:           fe
==5849==ABORTING

Original issue reported on code.google.com by mjurc...@google.com on 21 Nov 2014 at 10:19

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by mjurc...@google.com on 21 Nov 2014 at 10:23

GoogleCodeExporter commented 9 years ago
Reported in https://savannah.nongnu.org/bugs/?43655.

Original comment by mjurc...@google.com on 21 Nov 2014 at 11:29

GoogleCodeExporter commented 9 years ago
Fixed in 
http://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=dd89710f0f643
eb0f99a3830e0712d26c7642acd.

Original comment by mjurc...@google.com on 23 Nov 2014 at 11:14

GoogleCodeExporter commented 9 years ago
Reopening, as the same crash still appears to reproduce (with a different set 
of POC samples).

Original comment by mjurc...@google.com on 23 Nov 2014 at 1:10

GoogleCodeExporter commented 9 years ago
Finally fixed in 
http://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=73be9f9ab6784
2cfbec36ee99e8d2301434c84ca.

Original comment by mjurc...@google.com on 24 Nov 2014 at 8:08

GoogleCodeExporter commented 9 years ago
All fixed by upstream:

FreeType 2.5.5

2014-12-30
FreeType 2.5.5 has been released. This is a minor bug fix release: All users of 
PCF fonts should update, since version 2.5.4 introduced a bug that prevented 
reading of such font files if not compressed.

FreeType 2.5.4

2014-12-06
FreeType 2.5.4 has been released. All users should upgrade due to another fix 
for vulnerability CVE-2014-2240 in the CFF driver. The library also contains a 
new round of patches for better protection against malformed fonts.

The main new feature, which is also one of the targets mentioned in the pledgie 
roadmap below, is auto-hinting support for Devanagari and Telugu, two widely 
used Indic scripts. A more detailed description of the remaining changes and 
fixes can be found here.

Original comment by cev...@google.com on 26 Jan 2015 at 5:27

GoogleCodeExporter commented 9 years ago

Original comment by mjurc...@google.com on 25 Feb 2015 at 2:03

GoogleCodeExporter commented 9 years ago

Original comment by mjurc...@google.com on 20 Apr 2015 at 2:09