Skip to content

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

Closed
@hongxuchen

Description

@hongxuchen

(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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions