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_wstr_clen #2833

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

out of bounds heap read in r_wstr_clen #2833

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_wstr_clen

Test with (needs a real elf file):
radare2 -q -i [script] [elf_file]
Contains the commands aa and pffZ. Found with american fuzzy lop.

Address Sanitizer trace:

==9974==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x604000028a3b at pc 0x7f344a3d5df0 bp 0x7ffcf1fa1120 sp 0x7ffcf1fa1110
READ of size 1 at 0x604000028a3b thread T0
    #0 0x7f344a3d5def in r_wstr_clen /f/radare2/radare2/libr/util/str.c:1050
    #1 0x7f344a48436c in r_print_format /f/radare2/radare2/libr/util/p_format.c:1380
    #2 0x7f344f6a57da in cmd_print_format /f/radare2/radare2/libr/core/cmd_print.c:517
    #3 0x7f344f6a57da in cmd_print /f/radare2/radare2/libr/core/cmd_print.c:2840
    #4 0x7f344f70573a in r_core_cmd_subst_i /f/radare2/radare2/libr/core/cmd.c:1590
    #5 0x7f344f6668c4 in r_core_cmd_subst /f/radare2/radare2/libr/core/cmd.c:1081
    #6 0x7f344f667aa3 in r_core_cmd /f/radare2/radare2/libr/core/cmd.c:1938
    #7 0x7f344f66a8f4 in r_core_cmd_lines /f/radare2/radare2/libr/core/cmd.c:1989
    #8 0x7f344f66ab64 in r_core_cmd_file /f/radare2/radare2/libr/core/cmd.c:2001
    #9 0x7f344f66dba3 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 0x7f3449bcef9f in __libc_start_main (/lib64/libc.so.6+0x1ff9f)
    #12 0x40a333 (/mnt/ram/radare2/radare2+0x40a333)

0x604000028a3b is located 0 bytes to the right of 43-byte region [0x604000028a10,0x604000028a3b)
allocated by thread T0 here:
    #0 0x7f344fd98855 in calloc (/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/libasan.so.1+0x57855)
    #1 0x7f344a47bba4 in r_print_format /f/radare2/radare2/libr/util/p_format.c:1043

SUMMARY: AddressSanitizer: heap-buffer-overflow /f/radare2/radare2/libr/util/str.c:1050 r_wstr_clen
Shadow bytes around the buggy address:
  0x0c087fffd0f0: fa fa 00 00 00 00 02 fa fa fa 00 00 00 00 04 fa
  0x0c087fffd100: fa fa 00 00 00 00 04 fa fa fa fd fd fd fd fd fa
  0x0c087fffd110: fa fa fd fd fd fd fd fa fa fa 00 00 00 00 06 fa
  0x0c087fffd120: fa fa 00 00 00 00 04 fa fa fa fd fd fd fd fd fa
  0x0c087fffd130: fa fa 00 00 00 00 04 fa fa fa 00 00 00 00 04 fa
=>0x0c087fffd140: fa fa 00 00 00 00 00[03]fa fa 00 00 00 00 00 05
  0x0c087fffd150: fa fa 00 00 00 00 00 05 fa fa fa fa fa fa fa fa
  0x0c087fffd160: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c087fffd170: fa fa 00 00 00 00 04 fa fa fa 00 00 00 00 00 05
  0x0c087fffd180: fa fa fa fa fa fa fa fa fa fa 00 00 00 00 04 fa
  0x0c087fffd190: fa fa fd fd fd fd fd fd 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
  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
==9974==ABORTING
@alvarofe alvarofe self-assigned this Jun 24, 2015
alvarofe added a commit to alvarofe/radare2 that referenced this issue Jun 27, 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