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

stack buffer overflow in get_fileinfo (lrzip.c:1074) #75

Closed
bestshow opened this issue May 13, 2017 · 3 comments
Closed

stack buffer overflow in get_fileinfo (lrzip.c:1074) #75

bestshow opened this issue May 13, 2017 · 3 comments

Comments

@bestshow
Copy link

bestshow commented May 13, 2017

on lrzip version 0.631

#lrzip -i $FILE
stack-buffer-overflow on address 0x7fff0e9e9038 at pc 0x7f8ece5fb795 bp 0x7fff0e9e8da0 sp 0x7fff0e9e8550
WRITE of size 10 at 0x7fff0e9e9038 thread T0
    #0 0x7f8ece5fb794 in __interceptor_read ../../../../libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:545
    #1 0x413f27 in get_fileinfo /home/haojun/Downloads/lrzip-master/lrzip.c:1074
    #2 0x409ee1 in main /home/haojun/Downloads/lrzip-master/main.c:671
    #3 0x7f8ecd337b34 in __libc_start_main (/lib64/libc.so.6+0x21b34)
    #4 0x403648  (/home/haojun/Downloads/lrzip-build/bin/lrzip+0x403648)

Address 0x7fff0e9e9038 is located in stack of thread T0 at offset 424 in frame
    #0 0x412454 in get_fileinfo /home/haojun/Downloads/lrzip-master/lrzip.c:926

  This frame has 10 object(s):
    [32, 33) 'chunk_byte'
    [96, 97) 'ctype'
    [160, 168) 'u_len'
    [224, 232) 'c_len'
    [288, 296) 'last_head'
    [352, 360) 'expected_size'
    [416, 424) 'chunk_size' <== Memory access at offset 424 overflows this variable
    [480, 496) 'stream_head'
    [544, 560) 'md5_stored'
    [608, 752) 'fdin_stat'
HINT: this may be a false positive if your program uses some custom stack unwind mechanism or swapcontext
      (longjmp and C++ exceptions *are* supported)
SUMMARY: stack-buffer-overflow ../../../../libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:545 in __interceptor_read
Shadow bytes around the buggy address:
  0x100061d351b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x100061d351c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x100061d351d0: 00 00 f1 f1 f1 f1 01 f4 f4 f4 f2 f2 f2 f2 01 f4
  0x100061d351e0: f4 f4 f2 f2 f2 f2 00 f4 f4 f4 f2 f2 f2 f2 00 f4
  0x100061d351f0: f4 f4 f2 f2 f2 f2 00 f4 f4 f4 f2 f2 f2 f2 00 f4
=>0x100061d35200: f4 f4 f2 f2 f2 f2 00[f4]f4 f4 f2 f2 f2 f2 00 00
  0x100061d35210: f4 f4 f2 f2 f2 f2 00 00 f4 f4 f2 f2 f2 f2 00 00
  0x100061d35220: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x100061d35230: f4 f4 f3 f3 f3 f3 00 00 00 00 00 00 00 00 00 00
  0x100061d35240: 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1 04 f4
  0x100061d35250: f4 f4 f2 f2 f2 f2 04 f4 f4 f4 f2 f2 f2 f2 00 f4
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
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb

testcase: https://github.com/bestshow/p0cs/blob/master/stack-buffer-overflow-in-get_fileinfo-lrzip1074
Credit: ADLab of Venustech

@ariccio
Copy link

ariccio commented Jun 16, 2017

turn on verbose/debug mode - it may help here

@bestshow
Copy link
Author

@ariccio The debug mode information is the same to #75 basically.

@ckolivas
Copy link
Owner

Fixed in 7123f55

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants