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 in mrb_vm_exec #3675

Closed
clayton-shopify opened this Issue May 29, 2017 · 0 comments

Comments

Projects
None yet
1 participant
@clayton-shopify
Contributor

clayton-shopify commented May 29, 2017

The following input demonstrates a crash, when supplied to mirb:

Array.new{{}}
begin
    Fiber.new{+ x}.resume
rescue
end

{}0
x.a

ASAN report:

==11402==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000022a9c at pc 0x00010d6d97e1 bp 0x7fff526847d0 sp 0x7fff526847c8
READ of size 4 at 0x602000022a9c thread T0
    #0 0x10d6d97e0 in mrb_vm_exec (mirb:x86_64+0x1001687e0)
    #1 0x10d6d5473 in mrb_vm_run (mirb:x86_64+0x100164473)
    #2 0x10d573359 in main mirb.c:549
    #3 0x7fffe5638234 in start (libdyld.dylib:x86_64+0x5234)

0x602000022a9c is located 4 bytes to the right of 8-byte region [0x602000022a90,0x602000022a98)
allocated by thread T0 here:
    #0 0x10d985520 in wrap_realloc (libclang_rt.asan_osx_dynamic.dylib:x86_64h+0x56520)
    #1 0x10d668d9f in mrb_default_allocf (mirb:x86_64+0x1000f7d9f)
    #2 0x10d5e9b08 in mrb_realloc_simple gc.c:203
    #3 0x10d79c955 in codegen_realloc (mirb:x86_64+0x10022b955)
    #4 0x10d7ad02c in scope_finish (mirb:x86_64+0x10023c02c)
    #5 0x10d79f48a in scope_body (mirb:x86_64+0x10022e48a)
    #6 0x10d78a9b5 in codegen (mirb:x86_64+0x1002199b5)
    #7 0x10d7840a1 in mrb_generate_code (mirb:x86_64+0x1002130a1)
    #8 0x10d573065 in main mirb.c:537
    #9 0x7fffe5638234 in start (libdyld.dylib:x86_64+0x5234)

SUMMARY: AddressSanitizer: heap-buffer-overflow (mirb:x86_64+0x1001687e0) in mrb_vm_exec
Shadow bytes around the buggy address:
  0x1c0400004500: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x1c0400004510: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x1c0400004520: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x1c0400004530: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x1c0400004540: fa fa fa fa fa fa 07 fa fa fa 00 fa fa fa 00 fa
=>0x1c0400004550: fa fa 00[fa]fa fa 00 fa fa fa 00 00 fa fa 00 00
  0x1c0400004560: fa fa fd fd fa fa fd fd fa fa 00 00 fa fa fd fd
  0x1c0400004570: fa fa 07 fa fa fa 04 fa fa fa 00 fa fa fa 04 fa
  0x1c0400004580: fa fa 00 fa fa fa 00 00 fa fa fd fd fa fa fd fd
  0x1c0400004590: fa fa fd fd fa fa 07 fa fa fa 00 fa fa fa 00 fa
  0x1c04000045a0: fa fa 00 00 fa fa 07 fa fa fa 00 fa fa fa 00 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
==11402==ABORTING
Abort trap: 6

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

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