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_str_escape_ #2765

Closed
hannob opened this issue Jun 15, 2015 · 3 comments
Closed

Out of bounds heap read in r_str_escape_ #2765

hannob opened this issue Jun 15, 2015 · 3 comments
Assignees
Milestone

Comments

@hannob
Copy link

hannob commented Jun 15, 2015

This file will cause an out of bounds heap read in the script parser:
https://crashes.fuzzing-project.org/radare2-script-oob-heap-read-r_str_escape_

It contains the bytes 21 21 1B. Test: radare2 -q -i [script] /dev/null

Address Sanitizer trace:

==9721==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000016893 at pc 0x7f9e16988ec8 bp 0x7fff30b2d650 sp 0x7fff30b2d640
READ of size 1 at 0x602000016893 thread T0
    #0 0x7f9e16988ec7 in r_str_escape_ /f/radare2/radare2/libr/util/str.c:889
    #1 0x7f9e169bc929 in r_sys_cmd_str_full /f/radare2/radare2/libr/util/sys.c:402
    #2 0x7f9e1bc33e39 in cmd_system /f/radare2/radare2/libr/core/cmd.c:932
    #3 0x7f9e1bcae0ee in r_core_cmd_subst_i /f/radare2/radare2/libr/core/cmd.c:1590
    #4 0x7f9e1bc120c8 in r_core_cmd_subst /f/radare2/radare2/libr/core/cmd.c:1081
    #5 0x7f9e1bc1335b in r_core_cmd /f/radare2/radare2/libr/core/cmd.c:1938
    #6 0x7f9e1bc160bc in r_core_cmd_lines /f/radare2/radare2/libr/core/cmd.c:1989
    #7 0x7f9e1bc162f4 in r_core_cmd_file /f/radare2/radare2/libr/core/cmd.c:2001
    #8 0x7f9e1bc1955b in r_core_run_script /f/radare2/radare2/libr/core/cmd.c:373
    #9 0x4054c2 in main /f/radare2/radare2/binr/radare2/radare2.c:729
    #10 0x7f9e16193f9f in __libc_start_main (/lib64/libc.so.6+0x1ff9f)
    #11 0x40a25e (/mnt/ram/radare2/radare2+0x40a25e)

0x602000016893 is located 0 bytes to the right of 3-byte region [0x602000016890,0x602000016893)
allocated by thread T0 here:
    #0 0x7f9e1c3376f7 in malloc (/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/libasan.so.1+0x576f7)
    #1 0x7f9e161f5789 in strdup (/lib64/libc.so.6+0x81789)

SUMMARY: AddressSanitizer: heap-buffer-overflow /f/radare2/radare2/libr/util/str.c:889 r_str_escape_
Shadow bytes around the buggy address:
  0x0c047fffacc0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fffacd0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047ffface0: fa fa fa fa fa fa fa fa fa fa 05 fa fa fa 01 fa
  0x0c047fffacf0: fa fa 07 fa fa fa 00 fa fa fa 00 01 fa fa 00 02
  0x0c047fffad00: fa fa 00 06 fa fa 00 01 fa fa 00 fa fa fa 00 07
=>0x0c047fffad10: fa fa[03]fa fa fa 01 fa fa fa 04 fa fa fa 04 fa
  0x0c047fffad20: fa fa 04 fa fa fa fd fa fa fa fd fd fa fa 06 fa
  0x0c047fffad30: fa fa fd fa fa fa 05 fa fa fa fd fa fa fa 06 fa
  0x0c047fffad40: fa fa fd fa fa fa 03 fa fa fa fd fa fa fa 04 fa
  0x0c047fffad50: fa fa fd fa fa fa fd fa fa fa 04 fa fa fa fd fa
  0x0c047fffad60: fa fa fd fa fa fa fd fa fa fa fd fa fa fa 01 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
==9721==ABORTING
@alvarofe alvarofe self-assigned this Jun 15, 2015
@jjdredd
Copy link
Contributor

jjdredd commented Jun 15, 2015

revskills has a new nickname? :P

@XVilka XVilka added this to the 0.10.0 milestone Jun 15, 2015
alvarofe added a commit to alvarofe/radare2 that referenced this issue Jun 15, 2015
@hannob
Copy link
Author

hannob commented Jun 17, 2015

I just re-checked with latest git and this issue seems still unfixed, I get the same oob error message by asan on that input.

@crowell crowell reopened this Jun 17, 2015
@alvarofe
Copy link
Contributor

I will check then ;)

alvarofe added a commit to alvarofe/radare2 that referenced this issue Jun 17, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants