Skip to content
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

out of bounds heap read in r_mem_copyendian #2832

Closed
hannob opened this issue Jun 23, 2015 · 0 comments
Closed

out of bounds heap read in r_mem_copyendian #2832

hannob opened this issue Jun 23, 2015 · 0 comments
Labels

Comments

@hannob
Copy link

hannob commented Jun 23, 2015

This script will cause a heap oob:
https://crashes.fuzzing-project.org/radare2-oob-heap-read-r_mem_copyendian
Contains the string "pt@!"

It must be tested with a real executable, however it seems any 64 bit elf will do.
Test: radare2 -q -i [script] [elf_file]

Found with american fuzzy lop. Address Sanitizer trace:

==9520==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6020000416d0 at pc 0x7f3558e41103 bp 0x7ffc7a950240 sp 0x7ffc7a950230
READ of size 4 at 0x6020000416d0 thread T0
    #0 0x7f3558e41102 in memmove /usr/include/bits/string3.h:57
    #1 0x7f3558e41102 in r_mem_copyendian /f/radare2/radare2/libr/util/mem.c:157
    #2 0x7f3558ef84a7 in r_print_date_unix /f/radare2/radare2/libr/util/p_date.c:40
    #3 0x7f355e12cda1 in cmd_print /f/radare2/radare2/libr/core/cmd_print.c:2891
    #4 0x7f355e18dac6 in r_core_cmd_subst_i /f/radare2/radare2/libr/core/cmd.c:1569
    #5 0x7f355e0ee8c4 in r_core_cmd_subst /f/radare2/radare2/libr/core/cmd.c:1081
    #6 0x7f355e0efaa3 in r_core_cmd /f/radare2/radare2/libr/core/cmd.c:1938
    #7 0x7f355e0f28f4 in r_core_cmd_lines /f/radare2/radare2/libr/core/cmd.c:1989
    #8 0x7f355e0f2b64 in r_core_cmd_file /f/radare2/radare2/libr/core/cmd.c:2001
    #9 0x7f355e0f5ba3 in r_core_run_script /f/radare2/radare2/libr/core/cmd.c:373
    #10 0x405572 in main /f/radare2/radare2/binr/radare2/radare2.c:729
    #11 0x7f3558656f9f in __libc_start_main (/lib64/libc.so.6+0x1ff9f)
    #12 0x40a333 (/mnt/ram/radare2/radare2+0x40a333)

0x6020000416d2 is located 0 bytes to the right of 2-byte region [0x6020000416d0,0x6020000416d2)
allocated by thread T0 here:
    #0 0x7f355e8209d6 in __interceptor_realloc (/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/libasan.so.1+0x579d6)
    #1 0x7f355e0a1100 in r_core_block_size /f/radare2/radare2/libr/core/core.c:1108

SUMMARY: AddressSanitizer: heap-buffer-overflow /usr/include/bits/string3.h:57 memmove
Shadow bytes around the buggy address:
  0x0c0480000280: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c0480000290: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c04800002a0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c04800002b0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c04800002c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x0c04800002d0: fa fa fa fa fa fa fa fa fa fa[02]fa fa fa 01 fa
  0x0c04800002e0: fa fa 05 fa fa fa 05 fa fa fa 05 fa fa fa fd fa
  0x0c04800002f0: fa fa fd fa fa fa fd fd fa fa fd fa fa fa fd fd
  0x0c0480000300: fa fa fd fa fa fa fd fd fa fa 02 fa fa fa fd fd
  0x0c0480000310: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
  0x0c0480000320: fa fa fd fd fa fa fd fd fa fa fd fd fa fa 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
  Contiguous container OOB:fc
  ASan internal:           fe
==9520==ABORTING
@XVilka XVilka added the bug label Jun 24, 2015
@alvarofe alvarofe self-assigned this Jun 24, 2015
alvarofe added a commit to alvarofe/radare2 that referenced this issue Jun 28, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants