[2019-08-02] - Found with Honggfuzz - CVE-2019-14541 Stack-based buffer overflow in the cb_encode_program_id() function, in cobc/typeck.c. Issue can be reproduced by running: ``` cobc test04.cob ``` ``` ================================================================= ==4485==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fff6b7f3400 at pc 0x0000006440f3 bp 0x7fff6b7f32d0 sp 0x7fff6b7f32c8 WRITE of size 1 at 0x7fff6b7f3400 thread T0 #0 0x6440f2 in cb_encode_program_id /home/fcambus/gnucobol/cobc/typeck.c:1573:9 #1 0x644c3c in cb_build_program_id /home/fcambus/gnucobol/cobc/typeck.c:1614:6 #2 0x5a5a06 in setup_program /home/fcambus/gnucobol/cobc/parser.y:1198:5 #3 0x551c13 in yyparse /home/fcambus/gnucobol/cobc/parser.y:3286:6 #4 0x51d901 in process_translate /home/fcambus/gnucobol/cobc/cobc.c:6937:8 #5 0x5014d7 in process_file /home/fcambus/gnucobol/cobc/cobc.c:8037:19 #6 0x4faaaf in main /home/fcambus/gnucobol/cobc/cobc.c:8219:12 #7 0x7f2f7f8a6b6a in __libc_start_main /build/glibc-KRRWSm/glibc-2.29/csu/../csu/libc-start.c:308:16 #8 0x41c539 in _start (/usr/local/bin/cobc+0x41c539) Address 0x7fff6b7f3400 is located in stack of thread T0 at offset 288 in frame #0 0x643acf in cb_encode_program_id /home/fcambus/gnucobol/cobc/typeck.c:1549 This frame has 1 object(s): [32, 288) 'buff' (line 1553) <== Memory access at offset 288 overflows this variable HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork (longjmp and C++ exceptions *are* supported) SUMMARY: AddressSanitizer: stack-buffer-overflow /home/fcambus/gnucobol/cobc/typeck.c:1573:9 in cb_encode_program_id Shadow bytes around the buggy address: 0x10006d6f6630: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x10006d6f6640: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x10006d6f6650: 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1 0x10006d6f6660: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x10006d6f6670: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 =>0x10006d6f6680:[f3]f3 f3 f3 f3 f3 f3 f3 00 00 00 00 00 00 00 00 0x10006d6f6690: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x10006d6f66a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x10006d6f66b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x10006d6f66c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x10006d6f66d0: 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 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 Shadow gap: cc ==4485==ABORTING ```