Skip to content

heap-buffer-overflow in lexer_compare_literal_to_string #5367

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
==44846==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x603000001c41 at pc 0x0001019274f4 bp 0x00016f0beb60 sp 0x00016f0be2f8
READ of size 11 at 0x603000001c41 thread T0
    #0 0x0001019274f0 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 0x0001019278c8 in memcmp+0x54 (libclang_rt.asan_osx_dynamic.dylib:arm64+0x1b8c8)
    #2 0x000100e92358 in lexer_compare_literal_to_string+0x274 (jerry:arm64+0x100156358)
    #3 0x000100effc10 in scanner_scan_all js-scanner.c:2587
    #4 0x000100ee4dc4 in parser_parse_source js-parser.c:2167
    #5 0x000100ee4374 in parser_parse_script js-parser.c:3332
    #6 0x000100d446d4 in jerry_parse_common jerryscript.c:413
    #7 0x000100d441d8 in jerry_parse jerryscript.c:481
    #8 0x000100f5577c in jerryx_source_parse_script sources.c:52
    #9 0x000100f55888 in jerryx_source_exec_script sources.c:63
    #10 0x000100d3d5b4 in main main-desktop.c:156
    #11 0x0001822b84e0 in start+0x1b4c (dyld:arm64e+0x204e0)

0x603000001c41 is located 0 bytes after 17-byte region [0x603000001c30,0x603000001c41)
allocated by thread T0 here:
    #0 0x00010196140c in malloc+0x70 (libclang_rt.asan_osx_dynamic.dylib:arm64+0x5540c)
    #1 0x000100f56664 in jerry_port_source_read jerry-port-fs.c:67
    #2 0x000100f55680 in jerryx_source_parse_script sources.c:33
    #3 0x000100f55888 in jerryx_source_exec_script sources.c:63
    #4 0x000100d3d5b4 in main main-desktop.c:156
    #5 0x0001822b84e0 in start+0x1b4c (dyld:arm64e+0x204e0)

SUMMARY: AddressSanitizer: heap-buffer-overflow (jerry:arm64+0x100156358) in lexer_compare_literal_to_string+0x274
Shadow bytes around the buggy address:
  0x603000001980: fa fa 00 00 00 00 fa fa 00 00 00 00 fa fa 00 00
  0x603000001a00: 00 00 fa fa 00 00 00 00 fa fa 00 00 00 00 fa fa
  0x603000001a80: 00 00 00 00 fa fa 00 00 00 00 fa fa 00 00 00 00
  0x603000001b00: fa fa 00 00 00 00 fa fa 00 00 00 00 fa fa 00 00
  0x603000001b80: 00 00 fa fa 00 00 05 fa fa fa 00 00 00 00 fa fa
=>0x603000001c00: 00 00 00 00 fa fa 00 00[01]fa fa fa fa fa fa fa
  0x603000001c80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x603000001d00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x603000001d80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x603000001e00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x603000001e80: 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

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