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

AddressSanitizer: heap-buffer-overflow inside get_8bit_row (rdbmp.c) #258

Closed
HongxuChen opened this Issue Jul 20, 2018 · 0 comments

Comments

Projects
None yet
2 participants
@HongxuChen
Copy link

HongxuChen commented Jul 20, 2018

(This was firstly mentioned in mozilla/mozjpeg#299 and following @kornelski's suggestion I checked f4b8a5c and found similar issues; note that libjpeg did not trigger several crashes that mozjpeg triggered).

It can be triggered with cjpeg -outfile /dev/null $POC where $POC can be found in this directory (files ending with .bmp). ASAN messages are like:

=================================================================
==27647==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x611000000150 at pc 0x000000524062 bp 0x7ffd414b8060 sp 0x7ffd414b8058
READ of size 1 at 0x611000000150 thread T0
    #0 0x524061 in get_8bit_row /home/hongxu/FOT/libjpeg-turbo/rdbmp.c:209:26
    #1 0x513497 in main /home/hongxu/FOT/libjpeg-turbo/cjpeg.c:664:21
    #2 0x7fe82e562b96 in __libc_start_main /build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:310
    #3 0x41aa49 in _start (/home/hongxu/FOT/libjpeg-turbo/cjpeg+0x41aa49)

Address 0x611000000150 is a wild pointer.
SUMMARY: AddressSanitizer: heap-buffer-overflow /home/hongxu/FOT/libjpeg-turbo/rdbmp.c:209:26 in get_8bit_row
Shadow bytes around the buggy address:
  0x0c227fff7fd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c227fff7fe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c227fff7ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c227fff8000: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
  0x0c227fff8010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c227fff8020: 00 00 00 00 00 00 07 fa fa fa[fa]fa fa fa fa fa
  0x0c227fff8030: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c227fff8040: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c227fff8050: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c227fff8060: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c227fff8070: fa fa fa fa fa fa fa fa 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
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  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
==27647==ABORTING

dcommander added a commit that referenced this issue Jul 21, 2018

cjpeg: Fix OOB read caused by malformed 8-bit BMP
... in which one or more of the color indices is out of range for the
number of palette entries.

Fix partly borrowed from jpeg-9c.  This commit also adopts Guido's
JERR_PPM_OUTOFRANGE enum value in lieu of our project-specific
JERR_PPM_TOOLARGE enum value.

Fixes #258
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.