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

Heap-buffer-overflow in jp2_enc.c:309 at jasper version-2.0.14 and master branch #191

Open
wuk0n9 opened this Issue Dec 28, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@wuk0n9
Copy link

wuk0n9 commented Dec 28, 2018

A crafted input will lead to heap buffer overflow failed in jp2_enc.c:309 at jasper version-2.0.14 and master branch

Triggered by
./jasper --output /dev/null --output-format jp2 --input ./crashes/poc

Poc
poc.zip

The ASAN information is as follows:

================================================
==5337==ERROR: AddressSanitizer: heap-buffer-overflow on address 0xf63004b8 at pc 0xf796cf76 bp 0xfff37868 sp 0xfff37858
READ of size 4 at 0xf63004b8 thread T0
    #0 0xf796cf75 in jp2_encode /work/jasper-master/src/libjasper/jp2/jp2_enc.c:309
    #1 0xf793ee12 in jas_image_encode /work/jasper-master/src/libjasper/base/jas_image.c:469
    #2 0x8049e3b in main /work/jasper-master/src/appl/jasper.c:277
    #3 0xf7778636 in __libc_start_main (/lib/i386-linux-gnu/libc.so.6+0x18636)
    #4 0x80491a0  (/work/jasper-master/xbuild/src/appl/jasper+0x80491a0)

0xf63004b8 is located 0 bytes to the right of 8-byte region [0xf63004b0,0xf63004b8)
allocated by thread T0 here:
    #0 0xf7ae7dee in malloc (/usr/lib/i386-linux-gnu/libasan.so.2+0x96dee)
    #1 0xf7949cca in jas_malloc /work/jasper-master/src/libjasper/base/jas_malloc.c:241
    #2 0xf7949e68 in jas_alloc2 /work/jasper-master/src/libjasper/base/jas_malloc.c:274
    #3 0xf793ca2f in jas_image_create /work/jasper-master/src/libjasper/base/jas_image.c:153
    #4 0xf797cead in jpc_dec_process_sot /work/jasper-master/src/libjasper/jpc/jpc_dec.c:502
    #5 0xf797c863 in jpc_dec_decode /work/jasper-master/src/libjasper/jpc/jpc_dec.c:424
    #6 0xf797bca1 in jpc_decode /work/jasper-master/src/libjasper/jpc/jpc_dec.c:261
    #7 0xf796770d in jp2_decode /work/jasper-master/src/libjasper/jp2/jp2_dec.c:218
    #8 0xf793ec40 in jas_image_decode /work/jasper-master/src/libjasper/base/jas_image.c:442
    #9 0x8049aa3 in main /work/jasper-master/src/appl/jasper.c:236
    #10 0xf7778636 in __libc_start_main (/lib/i386-linux-gnu/libc.so.6+0x18636)

SUMMARY: AddressSanitizer: heap-buffer-overflow /work/jasper-master/src/libjasper/jp2/jp2_enc.c:309 jp2_encode
Shadow bytes around the buggy address:
  0x3ec60040: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
  0x3ec60050: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
  0x3ec60060: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
  0x3ec60070: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
  0x3ec60080: fa fa fd fd fa fa fd fd fa fa fd fa fa fa fd fd
=>0x3ec60090: fa fa fd fd fa fa 00[fa]fa fa fd fd fa fa fd fa
  0x3ec600a0: fa fa fd fa fa fa fd fa fa fa fd fd fa fa fd fd
  0x3ec600b0: fa fa 04 fa fa fa 04 fa fa fa 04 fa fa fa 04 fa
  0x3ec600c0: fa fa 04 fa fa fa 04 fa fa fa 04 fa fa fa 04 fa
  0x3ec600d0: fa fa 04 fa fa fa 04 fa fa fa 04 fa fa fa 04 fa
  0x3ec600e0: fa fa 04 fa fa fa 04 fa fa fa 04 fa fa fa 04 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
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
==5337==ABORTING

FoundBy: wu.an.1900@gmail.com

@apoleon

This comment has been minimized.

Copy link

apoleon commented Jan 3, 2019

After applying my patches I cannot reproduce this issue anymore. See

#182

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment