New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heap buffer overflow #3475

Closed
clayton-shopify opened this Issue Feb 27, 2017 · 0 comments

Comments

Projects
None yet
1 participant
@clayton-shopify
Contributor

clayton-shopify commented Feb 27, 2017

The following input demonstrates a crash:

d 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 < 0 - 1&.-- 0

This is a slight variation of the input in #3440, so it may be a related issue.

ASAN report:

==14624==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x61d00001de88 at pc 0x00010adf78ba bp 0x7fff54f6d850 sp 0x7fff54f6d848
WRITE of size 4 at 0x61d00001de88 thread T0
    #0 0x10adf78b9 in mrb_vm_exec vm.c:1164
    #1 0x10adef239 in mrb_vm_run vm.c:815
    #2 0x10ae20a59 in mrb_top_run vm.c:2573
    #3 0x10aeee7f5 in mrb_load_exec parse.y:5755
    #4 0x10aeef5c5 in mrb_load_file_cxt parse.y:5764
    #5 0x10ac8bcca in main mruby.c:232
    #6 0x7fffb4357254 in start (libdyld.dylib+0x5254)

0x61d00001de88 is located 8 bytes to the right of 2048-byte region [0x61d00001d680,0x61d00001de80)
allocated by thread T0 here:
    #0 0x10b02df87 in wrap_realloc (libclang_rt.asan_osx_dynamic.dylib+0x4af87)
    #1 0x10ad84fb5 in mrb_default_allocf state.c:60
    #2 0x10ad06468 in mrb_realloc_simple gc.c:201
    #3 0x10ad06b4e in mrb_realloc gc.c:215
    #4 0x10ad075c3 in mrb_malloc gc.c:236
    #5 0x10ad0765d in mrb_calloc gc.c:254
    #6 0x10ade6672 in stack_init vm.c:97
    #7 0x10ade35df in mrb_funcall_with_block vm.c:376
    #8 0x10ade2f57 in mrb_funcall_with_block vm.c:354
    #9 0x10ade2737 in mrb_funcall_argv vm.c:461
    #10 0x10acc9b35 in mrb_obj_new class.c:1425
    #11 0x10acee59d in mrb_exc_new_str error.c:32
    #12 0x10acf8bb7 in mrb_init_exception error.c:549
    #13 0x10ad29d90 in mrb_init_core init.c:41
    #14 0x10ad84f4e in mrb_open_core state.c:47
    #15 0x10ad8511c in mrb_open_allocf state.c:107
    #16 0x10ad850e7 in mrb_open state.c:99
    #17 0x10ac8aa47 in main mruby.c:172
    #18 0x7fffb4357254 in start (libdyld.dylib+0x5254)

SUMMARY: AddressSanitizer: heap-buffer-overflow vm.c:1164 in mrb_vm_exec
Shadow bytes around the buggy address:
  0x1c3a00003b80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1c3a00003b90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1c3a00003ba0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1c3a00003bb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1c3a00003bc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x1c3a00003bd0: fa[fa]fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x1c3a00003be0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x1c3a00003bf0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x1c3a00003c00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x1c3a00003c10: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x1c3a00003c20: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
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
  Heap right redzone:      fb
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack partial redzone:   f4
  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
==14624==ABORTING
Abort trap: 6

This issue was reported by https://hackerone.com/ssarong

@matz matz closed this in 8b089c0 Mar 1, 2017

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