Skip to content

global buffer overflow in getsid (parsettf.c) #3088

Closed
@fatal0

Description

@fatal0
# fontforge -lang=ff -c 'Open($1)' ./poc/getsid-in-parsettf.c-global-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
Warning: Mac and Windows entries in the 'name' table differ for the
 SubFamily string in the language English (US)
 Mac String: Medium
Windows String: Regular
Warning: Mac and Windows entries in the 'name' table differ for the
 Fullname string in the language English (US)
 Mac String: CFF_Type-1_0x0d_expl Medium
Windows String: CFF_Type-1_0x0d_expl
No argument to operator
Bad CFF name INDEX
Bad subroutine INDEX in cff font.
Bad subroutine INDEX in cff font.
No argument to operator 14 in private dict
No argument to operator 14 in private dict
No argument to operator 14 in private dict
No argument to operator 14 in private dict
No argument to operator 14 in private dict
No argument to operator 14 in private dict
No argument to operator 14 in private dict
No argument to operator 11 in private dict
Unexpected charset format in cff: 120
=================================================================
==21297==ERROR: AddressSanitizer: global-buffer-overflow on address 0x000001473ce0 at pc 0x00000052b05c bp 0x7ffdc8ba1160 sp 0x7ffdc8ba1150
READ of size 8 at 0x000001473ce0 thread T0
    #0 0x52b05b in getsid /root/afl_fuzz/project/test/fontforge/fontforge/parsettf.c:3339
    #1 0x52fc2f in cffinfofillup /root/afl_fuzz/project/test/fontforge/fontforge/parsettf.c:3728
    #2 0x5307f4 in cfffigure /root/afl_fuzz/project/test/fontforge/fontforge/parsettf.c:3777
    #3 0x53327e in readcffglyphs /root/afl_fuzz/project/test/fontforge/fontforge/parsettf.c:3948
    #4 0x54687c in readttf /root/afl_fuzz/project/test/fontforge/fontforge/parsettf.c:5527
    #5 0x552652 in _SFReadTTF /root/afl_fuzz/project/test/fontforge/fontforge/parsettf.c:6266
    #6 0x7e8756 in _ReadSplineFont /root/afl_fuzz/project/test/fontforge/fontforge/splinefont.c:1114
    #7 0x7ea217 in ReadSplineFont /root/afl_fuzz/project/test/fontforge/fontforge/splinefont.c:1285
    #8 0x7ea675 in LoadSplineFont /root/afl_fuzz/project/test/fontforge/fontforge/splinefont.c:1343
    #9 0x660df3 in bOpen /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:1854
    #10 0x6b967e in docall /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:9352
    #11 0x6b9f99 in handlename /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:9463
    #12 0x6be15f in term /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:9707
    #13 0x6bf96f in mul /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:9852
    #14 0x6bffcf in add /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:9897
    #15 0x6c0b1b in comp /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:9972
    #16 0x6c1338 in _and /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:10015
    #17 0x6c1871 in _or /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:10046
    #18 0x6c1e41 in assign /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:10078
    #19 0x6c2ff9 in expr /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:10156
    #20 0x6c4ab3 in ff_statement /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:10365
    #21 0x6c5b4f in ProcessNativeScript /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:10513
    #22 0x6c6536 in _CheckIsScript /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:10605
    #23 0x6c675b in CheckIsScript /root/afl_fuzz/project/test/fontforge/fontforge/scripting.c:10642
    #24 0x41fa8f in fontforge_main /root/afl_fuzz/project/test/fontforge/fontforgeexe/startnoui.c:113
    #25 0x41f705 in main /root/afl_fuzz/project/test/fontforge/fontforgeexe/main.c:39
    #26 0x7f169979582f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
    #27 0x41f618 in _start (/root/afl_fuzz/project/test/fontforge/fontforgeexe/fontforge+0x41f618)

0x000001473ce0 is located 0 bytes to the right of global variable 'stdtables' defined in 'parsettf.c:923:60' (0x1473880) of size 1120
0x000001473ce0 is located 32 bytes to the left of global variable 'cffnames' defined in 'parsettf.c:2330:13' (0x1473d00) of size 3136
SUMMARY: AddressSanitizer: global-buffer-overflow /root/afl_fuzz/project/test/fontforge/fontforge/parsettf.c:3339 getsid
Shadow bytes around the buggy address:
  0x000080286740: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x000080286750: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x000080286760: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x000080286770: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x000080286780: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x000080286790: 00 00 00 00 00 00 00 00 00 00 00 00[f9]f9 f9 f9
  0x0000802867a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0000802867b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0000802867c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0000802867d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0000802867e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
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
==21297==ABORTING

Testcase:
https://github.com/gnehsoah/poc/blob/master/fontforge/getsid-in-parsettf.c-global-buffer-overflow.otf

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions