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

use after free in r_num_calc_index #2889

Closed
hannob opened this issue Jul 5, 2015 · 1 comment
Closed

use after free in r_num_calc_index #2889

hannob opened this issue Jul 5, 2015 · 1 comment
Labels

Comments

@hannob
Copy link

hannob commented Jul 5, 2015

Slightly different than #2855
https://crashes.fuzzing-project.org/radare2-script-oob-heap-read-r_num_calc_index-2

Content:
0
~[[0

Address Sanitizer:

==5680==ERROR: AddressSanitizer: heap-use-after-free on address 0x6020000156b3 at pc 0x7f8831e65d70 bp 0x7ffe1c067070 sp 0x7ffe1c067040
READ of size 2 at 0x6020000156b3 thread T0
    #0 0x7f8831e65d6f in strlen (/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/libasan.so.1+0x32d6f)
    #1 0x7f882c529d1f in r_num_calc_index /f/radare2/radare2/libr/util/calc.c:152
    #2 0x7f88316e1d5f in num_callback /f/radare2/radare2/libr/core/core.c:149
    #3 0x7f882c480b26 in r_num_get /f/radare2/radare2/libr/util/num.c:118
    #4 0x7f8830f23a47 in r_cons_grep /f/radare2/radare2/libr/cons/grep.c:104
    #5 0x7f88317d9ea3 in r_core_cmd_subst_i /f/radare2/radare2/libr/core/cmd.c:1423
    #6 0x7f8831737dec in r_core_cmd_subst /f/radare2/radare2/libr/core/cmd.c:1084
    #7 0x7f8831739123 in r_core_cmd /f/radare2/radare2/libr/core/cmd.c:1947
    #8 0x7f883173bd3c in r_core_cmd_lines /f/radare2/radare2/libr/core/cmd.c:1998
    #9 0x7f883173c064 in r_core_cmd_file /f/radare2/radare2/libr/core/cmd.c:2010
    #10 0x7f883173f00e in r_core_run_script /f/radare2/radare2/libr/core/cmd.c:373
    #11 0x405416 in main /f/radare2/radare2/binr/radare2/radare2.c:729
    #12 0x7f882bc92f9f in __libc_start_main (/lib64/libc.so.6+0x1ff9f)
    #13 0x40a703 (/mnt/ram/r2/radare2+0x40a703)

0x6020000156b4 is located 0 bytes to the right of 4-byte region [0x6020000156b0,0x6020000156b4)
freed by thread T0 here:
    #0 0x7f8831e8a47f in __interceptor_free (/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/libasan.so.1+0x5747f)
    #1 0x7f8831737ba7 in r_core_cmd_subst /f/radare2/radare2/libr/core/cmd.c:1108

previously allocated by thread T0 here:
    #0 0x7f8831e8a6f7 in malloc (/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/libasan.so.1+0x576f7)
    #1 0x7f882bcf4789 in strdup (/lib64/libc.so.6+0x81789)

SUMMARY: AddressSanitizer: heap-use-after-free ??:0 strlen
Shadow bytes around the buggy address:
  0x0c047fffaa80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fffaa90: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fffaaa0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fffaab0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fffaac0: fa fa fa fa fa fa 02 fa fa fa 01 fa fa fa 05 fa
=>0x0c047fffaad0: fa fa fd fa fa fa[fd]fa fa fa fd fa fa fa fd fa
  0x0c047fffaae0: fa fa 07 fa fa fa 07 fa fa fa fd fd fa fa fd fd
  0x0c047fffaaf0: fa fa fd fa fa fa fd fa fa fa fd fa fa fa fd fa
  0x0c047fffab00: fa fa fd fa fa fa fd fa fa fa fd fd fa fa 02 fa
  0x0c047fffab10: fa fa fd fa fa fa fd fd fa fa fd fa fa fa fd fd
  0x0c047fffab20: fa fa fd fa fa fa fd fa 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
==5680==ABORTING
@alvarofe alvarofe self-assigned this Jul 6, 2015
@jvoisin jvoisin added the fuzzing label Jul 7, 2015
@radare radare closed this as completed in 61eb7d3 Jul 8, 2015
@radare
Copy link
Collaborator

radare commented Jul 8, 2015

just added a test case because the fix was exposing a regression

radare added a commit that referenced this issue Jul 8, 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