YASM v1.3.0 was discovered to contain a heap overflow via the function handle_dot_label at /nasm/nasm-token.re. Note: This has been disputed by third parties who argue this is a bug and not a security issue because yasm is a standalone program not designed to run untrusted code.
cpe:2.3:a:yasm_project:yasm:1.3.0:*:*:*:*:*:*:*
AD6556F7-3880-452A-ABA9-1A8A14BA41F3
OR
yasm heap buffer overflow

I found a heap-buffer-overflow in yasm.
Please confirm.
Thanks!



Test Environment
Ubuntu 20.04, 64 bit yasm (version: v1.3.0 ;master)

How to trigger
Compile the program with AddressSanitizer
Run command $ ./yasm -s -o abc --force-strict $PoC 
Details
ASAN report
$./yasm -s -o abc --force-strict $PoC 
```
yasm: file name already has no extension: output will be in `yasm.out'
=================================================================
==972503==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000006fd3 at pc 0x000000717cbd bp 0x7ffe3f1cd1c0 sp 0x7ffe3f1cd1b8
READ of size 1 at 0x602000006fd3 thread T0
    #0 0x717cbc in handle_dot_label /home/root/FuzzDateset/yasm/yasm-1.3.0/./modules/parsers/nasm/nasm-token.re:82:13
    #1 0x704533 in nasm_parser_lex /home/root/FuzzDateset/yasm/yasm-1.3.0/./modules/parsers/nasm/nasm-token.re:384:17
    #2 0x594fbb in demand_eol_ /home/root/FuzzDateset/yasm/yasm-1.3.0/modules/parsers/nasm/nasm-parse.c:149:9
    #3 0x591775 in nasm_parser_parse /home/root/FuzzDateset/yasm/yasm-1.3.0/modules/parsers/nasm/nasm-parse.c:232:13
    #4 0x590f3f in nasm_do_parse /home/root/FuzzDateset/yasm/yasm-1.3.0/modules/parsers/nasm/nasm-parser.c:66:5
    #5 0x5907fb in nasm_parser_do_parse /home/root/FuzzDateset/yasm/yasm-1.3.0/modules/parsers/nasm/nasm-parser.c:83:5
    #6 0x4d035f in do_assemble /home/root/FuzzDateset/yasm/yasm-1.3.0/frontends/yasm/yasm.c:519:5
    #7 0x4ccce0 in main /home/root/FuzzDateset/yasm/yasm-1.3.0/frontends/yasm/yasm.c:749:12
    #8 0x7f675d943082 in __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16
    #9 0x41d46d in _start (/home/root/randomFuzz/yasm/yasm/yasm_s_o_f/yasm+0x41d46d)

0x602000006fd3 is located 0 bytes to the right of 3-byte region [0x602000006fd0,0x602000006fd3)
allocated by thread T0 here:
    #0 0x499c1d in __interceptor_malloc (/home/root/randomFuzz/yasm/yasm/yasm_s_o_f/yasm+0x499c1d)
    #1 0x53d0af in def_xmalloc /home/root/FuzzDateset/yasm/yasm-1.3.0/libyasm/xmalloc.c:69:14
    #2 0x53d86e in yasm__xstrndup /home/root/FuzzDateset/yasm/yasm-1.3.0/libyasm/xstrdup.c:64:16
    #3 0x717bfb in handle_dot_label /home/root/FuzzDateset/yasm/yasm-1.3.0/./modules/parsers/nasm/nasm-token.re:79:26
    #4 0x704533 in nasm_parser_lex /home/root/FuzzDateset/yasm/yasm-1.3.0/./modules/parsers/nasm/nasm-token.re:384:17
    #5 0x594fbb in demand_eol_ /home/root/FuzzDateset/yasm/yasm-1.3.0/modules/parsers/nasm/nasm-parse.c:149:9
    #6 0x591775 in nasm_parser_parse /home/root/FuzzDateset/yasm/yasm-1.3.0/modules/parsers/nasm/nasm-parse.c:232:13
    #7 0x590f3f in nasm_do_parse /home/root/FuzzDateset/yasm/yasm-1.3.0/modules/parsers/nasm/nasm-parser.c:66:5
    #8 0x5907fb in nasm_parser_do_parse /home/root/FuzzDateset/yasm/yasm-1.3.0/modules/parsers/nasm/nasm-parser.c:83:5
    #9 0x4d035f in do_assemble /home/root/FuzzDateset/yasm/yasm-1.3.0/frontends/yasm/yasm.c:519:5
    #10 0x4ccce0 in main /home/root/FuzzDateset/yasm/yasm-1.3.0/frontends/yasm/yasm.c:749:12
    #11 0x7f675d943082 in __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16

SUMMARY: AddressSanitizer: heap-buffer-overflow /home/root/FuzzDateset/yasm/yasm-1.3.0/./modules/parsers/nasm/nasm-token.re:82:13 in handle_dot_label
Shadow bytes around the buggy address:
  0x0c047fff8da0: fa fa fd fa fa fa fd fa fa fa fd fa fa fa fd fa
  0x0c047fff8db0: fa fa fd fa fa fa fd fa fa fa fd fa fa fa fd fa
  0x0c047fff8dc0: fa fa fd fa fa fa fd fa fa fa fd fd fa fa fd fd
  0x0c047fff8dd0: fa fa fd fa fa fa fd fa fa fa 05 fa fa fa 05 fa
  0x0c047fff8de0: fa fa fd fa fa fa fd fa fa fa fd fa fa fa fd fa
=>0x0c047fff8df0: fa fa fd fa fa fa fd fa fa fa[03]fa fa fa fa fa
  0x0c047fff8e00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff8e10: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff8e20: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff8e30: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff8e40: 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
==972503==ABORTING
```
The URL of PoC is [PoC](https://github.com/randomssr/PoCs/blob/main/yasm/137-HOF)
yasm heap buffer overflow
This is a GitHub Issue
repo:yasm
owner:yasm
Title : yasm heap buffer overflow
Issue date:

--- start body ---
yasm heap buffer overflow

I found a heap-buffer-overflow in yasm.
Please confirm.
Thanks!



Test Environment
Ubuntu 20.04, 64 bit yasm (version: v1.3.0 ;master)

How to trigger
Compile the program with AddressSanitizer
Run command $ ./yasm -s -o abc --force-strict $PoC 
Details
ASAN report
$./yasm -s -o abc --force-strict $PoC 
```
yasm: file name already has no extension: output will be in `yasm.out'
=================================================================
==972503==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000006fd3 at pc 0x000000717cbd bp 0x7ffe3f1cd1c0 sp 0x7ffe3f1cd1b8
READ of size 1 at 0x602000006fd3 thread T0
    #0 0x717cbc in handle_dot_label /home/root/FuzzDateset/yasm/yasm-1.3.0/./modules/parsers/nasm/nasm-token.re:82:13
    #1 0x704533 in nasm_parser_lex /home/root/FuzzDateset/yasm/yasm-1.3.0/./modules/parsers/nasm/nasm-token.re:384:17
    #2 0x594fbb in demand_eol_ /home/root/FuzzDateset/yasm/yasm-1.3.0/modules/parsers/nasm/nasm-parse.c:149:9
    #3 0x591775 in nasm_parser_parse /home/root/FuzzDateset/yasm/yasm-1.3.0/modules/parsers/nasm/nasm-parse.c:232:13
    #4 0x590f3f in nasm_do_parse /home/root/FuzzDateset/yasm/yasm-1.3.0/modules/parsers/nasm/nasm-parser.c:66:5
    #5 0x5907fb in nasm_parser_do_parse /home/root/FuzzDateset/yasm/yasm-1.3.0/modules/parsers/nasm/nasm-parser.c:83:5
    #6 0x4d035f in do_assemble /home/root/FuzzDateset/yasm/yasm-1.3.0/frontends/yasm/yasm.c:519:5
    #7 0x4ccce0 in main /home/root/FuzzDateset/yasm/yasm-1.3.0/frontends/yasm/yasm.c:749:12
    #8 0x7f675d943082 in __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16
    #9 0x41d46d in _start (/home/root/randomFuzz/yasm/yasm/yasm_s_o_f/yasm+0x41d46d)

0x602000006fd3 is located 0 bytes to the right of 3-byte region [0x602000006fd0,0x602000006fd3)
allocated by thread T0 here:
    #0 0x499c1d in __interceptor_malloc (/home/root/randomFuzz/yasm/yasm/yasm_s_o_f/yasm+0x499c1d)
    #1 0x53d0af in def_xmalloc /home/root/FuzzDateset/yasm/yasm-1.3.0/libyasm/xmalloc.c:69:14
    #2 0x53d86e in yasm__xstrndup /home/root/FuzzDateset/yasm/yasm-1.3.0/libyasm/xstrdup.c:64:16
    #3 0x717bfb in handle_dot_label /home/root/FuzzDateset/yasm/yasm-1.3.0/./modules/parsers/nasm/nasm-token.re:79:26
    #4 0x704533 in nasm_parser_lex /home/root/FuzzDateset/yasm/yasm-1.3.0/./modules/parsers/nasm/nasm-token.re:384:17
    #5 0x594fbb in demand_eol_ /home/root/FuzzDateset/yasm/yasm-1.3.0/modules/parsers/nasm/nasm-parse.c:149:9
    #6 0x591775 in nasm_parser_parse /home/root/FuzzDateset/yasm/yasm-1.3.0/modules/parsers/nasm/nasm-parse.c:232:13
    #7 0x590f3f in nasm_do_parse /home/root/FuzzDateset/yasm/yasm-1.3.0/modules/parsers/nasm/nasm-parser.c:66:5
    #8 0x5907fb in nasm_parser_do_parse /home/root/FuzzDateset/yasm/yasm-1.3.0/modules/parsers/nasm/nasm-parser.c:83:5
    #9 0x4d035f in do_assemble /home/root/FuzzDateset/yasm/yasm-1.3.0/frontends/yasm/yasm.c:519:5
    #10 0x4ccce0 in main /home/root/FuzzDateset/yasm/yasm-1.3.0/frontends/yasm/yasm.c:749:12
    #11 0x7f675d943082 in __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16

SUMMARY: AddressSanitizer: heap-buffer-overflow /home/root/FuzzDateset/yasm/yasm-1.3.0/./modules/parsers/nasm/nasm-token.re:82:13 in handle_dot_label
Shadow bytes around the buggy address:
  0x0c047fff8da0: fa fa fd fa fa fa fd fa fa fa fd fa fa fa fd fa
  0x0c047fff8db0: fa fa fd fa fa fa fd fa fa fa fd fa fa fa fd fa
  0x0c047fff8dc0: fa fa fd fa fa fa fd fa fa fa fd fd fa fa fd fd
  0x0c047fff8dd0: fa fa fd fa fa fa fd fa fa fa 05 fa fa fa 05 fa
  0x0c047fff8de0: fa fa fd fa fa fa fd fa fa fa fd fa fa fa fd fa
=>0x0c047fff8df0: fa fa fd fa fa fa fd fa fa fa[03]fa fa fa fa fa
  0x0c047fff8e00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff8e10: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff8e20: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff8e30: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff8e40: 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
==972503==ABORTING
```
The URL of PoC is [PoC](https://github.com/randomssr/PoCs/blob/main/yasm/137-HOF)
--- end body ---

comments :
--- start comments ---

--- end comments ---