Skip to content

heap-buffer-overflow in lexer_token_is_identifier #5366

Backlog

Description

@renatahodovan
JerryScript revision

b706935

Build platform

macOS 26.6.2, arm64

Build steps
./tools/build.py --clean --debug --compile-flag=-fsanitize=address --logging=on --compile-flag="-Wno-error=enum-enum-conversion" --compile-flag="-Wno-unterminated-string-initialization"
Test case

test.js

Output
==41539==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6020000000d8 at pc 0x000104bb34f4 bp 0x00016bcb2760 sp 0x00016bcb1ef8
READ of size 6 at 0x6020000000d8 thread T0
    #0 0x000104bb34f0 in MemcmpInterceptorCommon(void*, int (*)(void const*, void const*, unsigned long), void const*, void const*, unsigned long)+0x594 (libclang_rt.asan_osx_dynamic.dylib:arm64+0x1b4f0)
    #1 0x000104bb38c8 in memcmp+0x54 (libclang_rt.asan_osx_dynamic.dylib:arm64+0x1b8c8)
    #2 0x0001042a1168 in lexer_token_is_identifier+0x1c0 (jerry:arm64+0x100159168)
    #3 0x00010430493c in scanner_try_scan_new_target js-scanner-util.c:2187
    #4 0x0001043108b4 in scanner_scan_primary_expression js-scanner.c:103
    #5 0x00010430b480 in scanner_scan_all js-scanner.c:2504
    #6 0x0001042f0dc4 in parser_parse_source js-parser.c:2167
    #7 0x0001042f0374 in parser_parse_script js-parser.c:3332
    #8 0x0001041506d4 in jerry_parse_common jerryscript.c:413
    #9 0x0001041501d8 in jerry_parse jerryscript.c:481
    #10 0x00010436177c in jerryx_source_parse_script sources.c:52
    #11 0x000104361888 in jerryx_source_exec_script sources.c:63
    #12 0x0001041495b4 in main main-desktop.c:156
    #13 0x0001822b84e0 in start+0x1b4c (dyld:arm64e+0x204e0)

0x6020000000d8 is located 0 bytes after 8-byte region [0x6020000000d0,0x6020000000d8)
allocated by thread T0 here:
    #0 0x000104bed40c in malloc+0x70 (libclang_rt.asan_osx_dynamic.dylib:arm64+0x5540c)
    #1 0x000104362664 in jerry_port_source_read jerry-port-fs.c:67
    #2 0x000104361680 in jerryx_source_parse_script sources.c:33
    #3 0x000104361888 in jerryx_source_exec_script sources.c:63
    #4 0x0001041495b4 in main main-desktop.c:156
    #5 0x0001822b84e0 in start+0x1b4c (dyld:arm64e+0x204e0)

SUMMARY: AddressSanitizer: heap-buffer-overflow (jerry:arm64+0x100159168) in lexer_token_is_identifier+0x1c0
Shadow bytes around the buggy address:
  0x601ffffffe00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x601ffffffe80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x601fffffff00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x601fffffff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x602000000000: fa fa fd fa fa fa fd fd fa fa fd fd fa fa 00 02
=>0x602000000080: fa fa 00 04 fa fa 00 00 fa fa 00[fa]fa fa fa fa
  0x602000000100: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x602000000180: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x602000000200: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x602000000280: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x602000000300: 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

Found with grammarinator integrated with AFL++.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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