DISCOUNT through version 2.2.3a is vulnerable to a Heap-based buffer-overflow in in the markdown.c:isfootnote() function. An attacker could exploit this to cause a denial of service. Upstream issue: https://github.com/Orc/discount/issues/189#issuecomment-392247798
Created discount tracking bugs for this issue: Affects: epel-7 [bug 1583002] Affects: fedora-all [bug 1583003]
Reproduced on F27: # rpm -q discount discount-2.2.2-4.fc27.x86_64 sh-4.4# discount-mkd2html issue2_testcase ================================================================= ==73==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000000012 at pc 0x7f02f778fc42 bp 0x7ffc8afeb700 sp 0x7ffc8afeb6f0 READ of size 1 at 0x602000000012 thread T0 #0 0x7f02f778fc41 in mkd_compile (/lib64/libmarkdown.so.2+0x14c41) #1 0x40127f (/usr/bin/discount-mkd2html+0x40127f) #2 0x7f02f73e5f29 in __libc_start_main (/lib64/libc.so.6+0x20f29) #3 0x401799 (/usr/bin/discount-mkd2html+0x401799) 0x602000000012 is located 1 bytes to the right of 1-byte region [0x602000000010,0x602000000011) allocated by thread T0 here: #0 0x7f02f7a8f850 in malloc (/lib64/libasan.so.4+0xde850) #1 0x7f02f778fb18 in mkd_compile (/lib64/libmarkdown.so.2+0x14b18) SUMMARY: AddressSanitizer: heap-buffer-overflow (/lib64/libmarkdown.so.2+0x14c41) in mkd_compile Shadow bytes around the buggy address: 0x0c047fff7fb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0c047fff7fc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0c047fff7fd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0c047fff7fe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0c047fff7ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 =>0x0c047fff8000: fa fa[01]fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c047fff8010: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c047fff8020: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c047fff8030: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c047fff8040: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c047fff8050: 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 Freed heap region: fd Stack left redzone: f1 Stack mid redzone: f2 Stack right redzone: f3 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 Left alloca redzone: ca Right alloca redzone: cb ==73==ABORTING