Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

heap buffer overflow in PSCharStringToSplines (psread.c) #3089

Closed
fatal0 opened this issue Jun 14, 2017 · 1 comment
Closed

heap buffer overflow in PSCharStringToSplines (psread.c) #3089

fatal0 opened this issue Jun 14, 2017 · 1 comment

Comments

@fatal0
Copy link

fatal0 commented Jun 14, 2017

# fontforge -lang=ff -c 'Open($1)' ./poc/PSCharStringToSplines-in-psread.c-heap-buffer-overflow.otf
Copyright (c) 2000-2014 by George Williams. See AUTHORS for Contributors.
 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
 with many parts BSD <http://fontforge.org/license.html>. Please read LICENSE.
 Based on sources from 09:14 UTC 13-Jun-2017-D.
 Based on source from git with hash: b8e5ff8f24955f4d7d59ac73c903cc088b21bdb6
Table 'hmtx' extends beyond end of file and must be ignored.
Bad subroutine INDEX in cff font.
Stack underflow on hstem in I
return when not in subroutine in S
return when not in subroutine in U
=================================================================
==21326==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6030000518c1 at pc 0x0000005aa45b bp 0x7fff03ffa280 sp 0x7fff03ffa270
READ of size 1 at 0x6030000518c1 thread T0
    #0 0x5aa45a in PSCharStringToSplines /root/afl_fuzz/project/test/fontforge/fontforge/psread.c:3668
    #1 0x530cba in cfffigure /root/afl_fuzz/project/test/fontforge/fontforge/parsettf.c:3796
    #2 0x53327e in readcffglyphs /root/afl_fuzz/project/test/fontforge/fontforge/parsettf.c:3948
    #3 0x54687c in readttf /root/afl_fuzz/project/test/fontforge/fontforge/parsettf.c:5527
    #4 0x552652 in _SFReadTTF /root/afl_fuzz/project/test/fontforge/fontforge/parsettf.c:6266
    #5 0x7e8756 in _ReadSplineFont /root/afl_fuzz/project/test/fontforge/fontforge/splinefont.c:1114
    #6 0x7ea217 in ReadSplineFont /root/afl_fuzz/project/test/fontforge/fontforge/splinefont.c:1285
    #7 0x7ea675 in LoadSplineFont /root/afl_fuzz/project/test/fontforge/fontforge/splinefont.c:1343
    #8 0x660df3 in bOpen /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:1854
    #9 0x6b967e in docall /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:9352
    #10 0x6b9f99 in handlename /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:9463
    #11 0x6be15f in term /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:9707
    #12 0x6bf96f in mul /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:9852
    #13 0x6bffcf in add /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:9897
    #14 0x6c0b1b in comp /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:9972
    #15 0x6c1338 in _and /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:10015
    #16 0x6c1871 in _or /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:10046
    #17 0x6c1e41 in assign /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:10078
    #18 0x6c2ff9 in expr /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:10156
    #19 0x6c4ab3 in ff_statement /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:10365
    #20 0x6c5b4f in ProcessNativeScript /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:10513
    #21 0x6c6536 in _CheckIsScript /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:10605
    #22 0x6c675b in CheckIsScript /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:10642
    #23 0x41fa8f in fontforge_main /root/afl_fuzz/project/test/fontforge/fontforgeexe/startnoui.c:113
    #24 0x41f705 in main /root/afl_fuzz/project/test/fontforge/fontforgeexe/main.c:39
    #25 0x7fab0441e82f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
    #26 0x41f618 in _start (/root/afl_fuzz/project/test/fontforge/fontforgeexe/fontforge+0x41f618)

0x6030000518c1 is located 0 bytes to the right of 17-byte region [0x6030000518b0,0x6030000518c1)
allocated by thread T0 here:
    #0 0x7fab0740c602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602)
    #1 0x526445 in readcffsubrs /root/afl_fuzz/project/test/fontforge/fontforge/parsettf.c:2979
    #2 0x532ff7 in readcffglyphs /root/afl_fuzz/project/test/fontforge/fontforge/parsettf.c:3941
    #3 0x54687c in readttf /root/afl_fuzz/project/test/fontforge/fontforge/parsettf.c:5527
    #4 0x552652 in _SFReadTTF /root/afl_fuzz/project/test/fontforge/fontforge/parsettf.c:6266
    #5 0x7e8756 in _ReadSplineFont /root/afl_fuzz/project/test/fontforge/fontforge/splinefont.c:1114
    #6 0x7ea217 in ReadSplineFont /root/afl_fuzz/project/test/fontforge/fontforge/splinefont.c:1285
    #7 0x7ea675 in LoadSplineFont /root/afl_fuzz/project/test/fontforge/fontforge/splinefont.c:1343
    #8 0x660df3 in bOpen /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:1854
    #9 0x6b967e in docall /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:9352
    #10 0x6b9f99 in handlename /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:9463
    #11 0x6be15f in term /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:9707
    #12 0x6bf96f in mul /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:9852
    #13 0x6bffcf in add /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:9897
    #14 0x6c0b1b in comp /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:9972
    #15 0x6c1338 in _and /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:10015
    #16 0x6c1871 in _or /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:10046
    #17 0x6c1e41 in assign /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:10078
    #18 0x6c2ff9 in expr /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:10156
    #19 0x6c4ab3 in ff_statement /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:10365
    #20 0x6c5b4f in ProcessNativeScript /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:10513
    #21 0x6c6536 in _CheckIsScript /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:10605
    #22 0x6c675b in CheckIsScript /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:10642
    #23 0x41fa8f in fontforge_main /root/afl_fuzz/project/test/fontforge/fontforgeexe/startnoui.c:113
    #24 0x41f705 in main /root/afl_fuzz/project/test/fontforge/fontforgeexe/main.c:39
    #25 0x7fab0441e82f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)

SUMMARY: AddressSanitizer: heap-buffer-overflow /root/afl_fuzz/project/test/fontforge/fontforge/psread.c:3668 PSCharStringToSplines
Shadow bytes around the buggy address:
  0x0c06800022c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c06800022d0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c06800022e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c06800022f0: fa fa fd fd fd fd fa fa 00 00 00 fa fa fa 00 00
  0x0c0680002300: 05 fa fa fa 00 00 00 04 fa fa 00 00 05 fa fa fa
=>0x0c0680002310: 00 00 00 03 fa fa 00 00[01]fa fa fa 00 00 05 fa
  0x0c0680002320: fa fa 00 00 00 04 fa fa 00 00 05 fa fa fa 00 00
  0x0c0680002330: 00 00 fa fa 00 00 00 00 fa fa 00 00 00 00 fa fa
  0x0c0680002340: 00 00 00 fa fa fa 00 00 00 00 fa fa 00 00 00 00
  0x0c0680002350: fa fa 00 00 00 00 fa fa 00 00 00 00 fa fa 00 00
  0x0c0680002360: 03 fa fa fa 00 00 00 fa fa fa 00 00 00 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
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
==21326==ABORTING

Testcase:
https://github.com/gnehsoah/poc/blob/master/fontforge/PSCharStringToSplines-in-psread.c-heap-buffer-overflow.otf

@jtanx
Copy link
Contributor

jtanx commented Jul 30, 2017

Closed by #3124

@jtanx jtanx closed this as completed Jul 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants