security
security copied to clipboard
Roundup: [oss-security] jasper: heap-based buffer overflow in jpc_dec_decodepkt (jpc_t2dec.c)
Here is a report from the oss-security mailing list for Vulnerability Roundup 27.
Skip to First Email
Instructions:
Identification
Identify if we have the software, in 16.09, 17.03, and unstable. Then determine if we are vulnerable, and make a comment with your findings. It can also be helpful to specify if you think there is a patch, or if it can be fixed via a general update.
Example:
unstable: we are not vulnerable (link to the package)
17.03: we are vulnerable (link to the package)
16.09: we don't have it packaged
IMPORTANT: If you believe there are possibly related issues, bring them up on the parent issue!
Patching
Start by commenting on this issue saying you're working on a patch. This way, we don't duplicate work.
If you open a pull request, tag this issue and the master issue for the roundup.
If you commit the patch directly to a branch, please leave a comment on this issue with the branch and the commit hash, example:
fixed:
release-16.09: abc123
Skip to First Email
Upon Completion ...
- [ ] Update Graham's database
Info
Triage Indicator:
-needs-triage +roundup27 thread:00000000000037ac
- File Search: https://search.nix.gsc.io/?q=jasper&i=fosho&repos=nixos-nixpkgs
- GitHub Search: https://github.com/NixOS/nixpkgs/search?utf8=%E2%9C%93&q=jasper+in%3Apath&type=Code
Should the search term be changed from jasper
? Suggest a new package search by commenting:
-suggested:jasper +suggested:correctPackageName thread:00000000000037ac
Known CVEs: CVE-2017-6852
Skip to End
Wed, 25 Jan 2017 10:16:01 +0100 Agostino Sarubbo <ago-at-gentoo.org>, 2979113.NTRsFXjtRy@blackgate
Description:
jasper is an open-source initiative to provide a free software-based reference
implementation of the codec specified in the JPEG-2000 Part-1 standard.
Another round of fuzzing shows that a crafted image causes a read overflow.
The complete ASan output:
# imginfo -f $FILE
warning: ignoring unknown marker segment (0xff70)
type = 0xff70 (UNKNOWN); len = 35;00 01 43 72 65 61 74 6f 74 3a 30 4a 61 73 50
65 72 00 01 00 00 73 69 6f 6e 20 31 2e 39 30 30 2e 39 warning: trailing
garbage in marker segment (3 bytes)
warning: trailing garbage in marker segment (8 bytes)
warning: trailing garbage in marker segment (6 bytes)
=================================================================
==30315==ERROR: AddressSanitizer: heap-buffer-overflow on address
0x61a00001f808 at pc 0x7fb7b2667e54 bp 0x7ffd0a9ab890 sp 0x7ffd0a9ab888
READ of size 8 at 0x61a00001f808 thread T0
#0 0x7fb7b2667e53 in jpc_dec_decodepkt /tmp/portage/media-
libs/jasper-2.0.10/work/jasper-2.0.10/src/libjasper/jpc/jpc_t2dec.c:245:14
#1 0x7fb7b2667e53 in jpc_dec_decodepkts /tmp/portage/media-
libs/jasper-2.0.10/work/jasper-2.0.10/src/libjasper/jpc/jpc_t2dec.c:454
#2 0x7fb7b25ccd37 in jpc_dec_process_sod /tmp/portage/media-
libs/jasper-2.0.10/work/jasper-2.0.10/src/libjasper/jpc/jpc_dec.c:628:6
#3 0x7fb7b25d6853 in jpc_dec_decode /tmp/portage/media-
libs/jasper-2.0.10/work/jasper-2.0.10/src/libjasper/jpc/jpc_dec.c:425:10
#4 0x7fb7b25d6853 in jpc_decode /tmp/portage/media-
libs/jasper-2.0.10/work/jasper-2.0.10/src/libjasper/jpc/jpc_dec.c:262
#5 0x7fb7b25a6231 in jp2_decode /tmp/portage/media-
libs/jasper-2.0.10/work/jasper-2.0.10/src/libjasper/jp2/jp2_dec.c:218:21
#6 0x7fb7b2568214 in jas_image_decode /tmp/portage/media-
libs/jasper-2.0.10/work/jasper-2.0.10/src/libjasper/base/jas_image.c:444:16
#7 0x50a3be in main /tmp/portage/media-
libs/jasper-2.0.10/work/jasper-2.0.10/src/appl/imginfo.c:238:16
#8 0x7fb7b164878f in __libc_start_main /tmp/portage/sys-libs/glibc-2.23-
r3/work/glibc-2.23/csu/../csu/libc-start.c:289
#9 0x419cd8 in _start (/usr/bin/imginfo+0x419cd8)
0x61a00001f808 is located 48 bytes to the right of 1368-byte region
[0x61a00001f280,0x61a00001f7d8)
allocated by thread T0 here:
#0 0x4d2a98 in malloc /tmp/portage/sys-
devel/llvm-3.9.1/work/llvm-3.9.1.src/projects/compiler-
rt/lib/asan/asan_malloc_linux.cc:64
#1 0x7fb7b2575160 in jas_malloc /tmp/portage/media-
libs/jasper-2.0.10/work/jasper-2.0.10/src/libjasper/base/jas_malloc.c:242:11
#2 0x7fb7b2575160 in jas_alloc2 /tmp/portage/media-
libs/jasper-2.0.10/work/jasper-2.0.10/src/libjasper/base/jas_malloc.c:275
#3 0x7fb7b25ca2bf in jpc_dec_tileinit /tmp/portage/media-
libs/jasper-2.0.10/work/jasper-2.0.10/src/libjasper/jpc/jpc_dec.c:841:24
#4 0x7fb7b25ca2bf in jpc_dec_process_sod /tmp/portage/media-
libs/jasper-2.0.10/work/jasper-2.0.10/src/libjasper/jpc/jpc_dec.c:594
#5 0x7fb7b25d6853 in jpc_dec_decode /tmp/portage/media-
libs/jasper-2.0.10/work/jasper-2.0.10/src/libjasper/jpc/jpc_dec.c:425:10
#6 0x7fb7b25d6853 in jpc_decode /tmp/portage/media-
libs/jasper-2.0.10/work/jasper-2.0.10/src/libjasper/jpc/jpc_dec.c:262
#7 0x7fb7b25a6231 in jp2_decode /tmp/portage/media-
libs/jasper-2.0.10/work/jasper-2.0.10/src/libjasper/jp2/jp2_dec.c:218:21
#8 0x7fb7b2568214 in jas_image_decode /tmp/portage/media-
libs/jasper-2.0.10/work/jasper-2.0.10/src/libjasper/base/jas_image.c:444:16
#9 0x50a3be in main /tmp/portage/media-
libs/jasper-2.0.10/work/jasper-2.0.10/src/appl/imginfo.c:238:16
#10 0x7fb7b164878f in __libc_start_main /tmp/portage/sys-libs/glibc-2.23-
r3/work/glibc-2.23/csu/../csu/libc-start.c:289
SUMMARY: AddressSanitizer: heap-buffer-overflow /tmp/portage/media-
libs/jasper-2.0.10/work/jasper-2.0.10/src/libjasper/jpc/jpc_t2dec.c:245:14 in
jpc_dec_decodepkt
Shadow bytes around the buggy address:
0x0c347fffbeb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c347fffbec0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c347fffbed0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c347fffbee0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c347fffbef0: 00 00 00 00 00 00 00 00 00 00 00 fa fa fa fa fa
=>0x0c347fffbf00: fa[fa]fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c347fffbf10: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c347fffbf20: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c347fffbf30: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c347fffbf40: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c347fffbf50: 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
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
==30315==ABORTING
Affected version:
2.0.10
Fixed version:
N/A
Commit fix:
N/A
Credit:
This bug was discovered by Agostino Sarubbo of Gentoo.
CVE:
N/A
Reproducer:
https://github.com/asarubbo/poc/blob/master/00126-jasper-heapoverflow-jpc_dec_decodepkt
Timeline:
2017-01-25: bug discovered and reported upstream
2017-01-25: blog post about the issue
Note:
This bug was found with American Fuzzy Lop.
Permalink:
https://blogs.gentoo.org/ago/2017/01/25/jasper-heap-based-buffer-overflow-in-jpc_dec_decodepkt-jpc_t2dec-c
--
Agostino Sarubbo
Gentoo Linux Developer
Skip to End
Wed, 25 Jan 2017 10:41:17 +0100 Salvatore Bonaccorso <carnil-at-debian.org>, [email protected]
On Wed, Jan 25, 2017 at 10:16:01AM +0100, Agostino Sarubbo wrote:
> Description:
> jasper is an open-source initiative to provide a free software-based reference
> implementation of the codec specified in the JPEG-2000 Part-1 standard.
>
> Another round of fuzzing shows that a crafted image causes a read overflow.
>
> The complete ASan output:
>
> # imginfo -f $FILE
> warning: ignoring unknown marker segment (0xff70)
> type = 0xff70 (UNKNOWN); len = 35;00 01 43 72 65 61 74 6f 74 3a 30 4a 61 73 50
> 65 72 00 01 00 00 73 69 6f 6e 20 31 2e 39 30 30 2e 39 warning: trailing
> garbage in marker segment (3 bytes)
> warning: trailing garbage in marker segment (8 bytes)
> warning: trailing garbage in marker segment (6 bytes)
> =================================================================
> ==30315==ERROR: AddressSanitizer: heap-buffer-overflow on address
> 0x61a00001f808 at pc 0x7fb7b2667e54 bp 0x7ffd0a9ab890 sp 0x7ffd0a9ab888
> READ of size 8 at 0x61a00001f808 thread T0
> #0 0x7fb7b2667e53 in jpc_dec_decodepkt /tmp/portage/media-
> libs/jasper-2.0.10/work/jasper-2.0.10/src/libjasper/jpc/jpc_t2dec.c:245:14
> #1 0x7fb7b2667e53 in jpc_dec_decodepkts /tmp/portage/media-
> libs/jasper-2.0.10/work/jasper-2.0.10/src/libjasper/jpc/jpc_t2dec.c:454
> #2 0x7fb7b25ccd37 in jpc_dec_process_sod /tmp/portage/media-
> libs/jasper-2.0.10/work/jasper-2.0.10/src/libjasper/jpc/jpc_dec.c:628:6
> #3 0x7fb7b25d6853 in jpc_dec_decode /tmp/portage/media-
> libs/jasper-2.0.10/work/jasper-2.0.10/src/libjasper/jpc/jpc_dec.c:425:10
> #4 0x7fb7b25d6853 in jpc_decode /tmp/portage/media-
> libs/jasper-2.0.10/work/jasper-2.0.10/src/libjasper/jpc/jpc_dec.c:262
> #5 0x7fb7b25a6231 in jp2_decode /tmp/portage/media-
> libs/jasper-2.0.10/work/jasper-2.0.10/src/libjasper/jp2/jp2_dec.c:218:21
> #6 0x7fb7b2568214 in jas_image_decode /tmp/portage/media-
> libs/jasper-2.0.10/work/jasper-2.0.10/src/libjasper/base/jas_image.c:444:16
> #7 0x50a3be in main /tmp/portage/media-
> libs/jasper-2.0.10/work/jasper-2.0.10/src/appl/imginfo.c:238:16
> #8 0x7fb7b164878f in __libc_start_main /tmp/portage/sys-libs/glibc-2.23-
> r3/work/glibc-2.23/csu/../csu/libc-start.c:289
> #9 0x419cd8 in _start (/usr/bin/imginfo+0x419cd8)
>
> 0x61a00001f808 is located 48 bytes to the right of 1368-byte region
> [0x61a00001f280,0x61a00001f7d8)
> allocated by thread T0 here:
> #0 0x4d2a98 in malloc /tmp/portage/sys-
> devel/llvm-3.9.1/work/llvm-3.9.1.src/projects/compiler-
> rt/lib/asan/asan_malloc_linux.cc:64
> #1 0x7fb7b2575160 in jas_malloc /tmp/portage/media-
> libs/jasper-2.0.10/work/jasper-2.0.10/src/libjasper/base/jas_malloc.c:242:11
> #2 0x7fb7b2575160 in jas_alloc2 /tmp/portage/media-
> libs/jasper-2.0.10/work/jasper-2.0.10/src/libjasper/base/jas_malloc.c:275
> #3 0x7fb7b25ca2bf in jpc_dec_tileinit /tmp/portage/media-
> libs/jasper-2.0.10/work/jasper-2.0.10/src/libjasper/jpc/jpc_dec.c:841:24
> #4 0x7fb7b25ca2bf in jpc_dec_process_sod /tmp/portage/media-
> libs/jasper-2.0.10/work/jasper-2.0.10/src/libjasper/jpc/jpc_dec.c:594
> #5 0x7fb7b25d6853 in jpc_dec_decode /tmp/portage/media-
> libs/jasper-2.0.10/work/jasper-2.0.10/src/libjasper/jpc/jpc_dec.c:425:10
> #6 0x7fb7b25d6853 in jpc_decode /tmp/portage/media-
> libs/jasper-2.0.10/work/jasper-2.0.10/src/libjasper/jpc/jpc_dec.c:262
> #7 0x7fb7b25a6231 in jp2_decode /tmp/portage/media-
> libs/jasper-2.0.10/work/jasper-2.0.10/src/libjasper/jp2/jp2_dec.c:218:21
> #8 0x7fb7b2568214 in jas_image_decode /tmp/portage/media-
> libs/jasper-2.0.10/work/jasper-2.0.10/src/libjasper/base/jas_image.c:444:16
> #9 0x50a3be in main /tmp/portage/media-
> libs/jasper-2.0.10/work/jasper-2.0.10/src/appl/imginfo.c:238:16
> #10 0x7fb7b164878f in __libc_start_main /tmp/portage/sys-libs/glibc-2.23-
> r3/work/glibc-2.23/csu/../csu/libc-start.c:289
>
> SUMMARY: AddressSanitizer: heap-buffer-overflow /tmp/portage/media-
> libs/jasper-2.0.10/work/jasper-2.0.10/src/libjasper/jpc/jpc_t2dec.c:245:14 in
> jpc_dec_decodepkt
> Shadow bytes around the buggy address:
> 0x0c347fffbeb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> 0x0c347fffbec0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> 0x0c347fffbed0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> 0x0c347fffbee0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> 0x0c347fffbef0: 00 00 00 00 00 00 00 00 00 00 00 fa fa fa fa fa
> =>0x0c347fffbf00: fa[fa]fa fa fa fa fa fa fa fa fa fa fa fa fa fa
> 0x0c347fffbf10: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
> 0x0c347fffbf20: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
> 0x0c347fffbf30: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
> 0x0c347fffbf40: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
> 0x0c347fffbf50: 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
> 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
> ==30315==ABORTING
>
> Affected version:
> 2.0.10
>
> Fixed version:
> N/A
>
> Commit fix:
> N/A
>
> Credit:
> This bug was discovered by Agostino Sarubbo of Gentoo.
>
> CVE:
> N/A
>
> Reproducer:
> https://github.com/asarubbo/poc/blob/master/00126-jasper-heapoverflow-jpc_dec_decodepkt
>
> Timeline:
> 2017-01-25: bug discovered and reported upstream
> 2017-01-25: blog post about the issue
>
> Note:
> This bug was found with American Fuzzy Lop.
>
> Permalink:
> https://blogs.gentoo.org/ago/2017/01/25/jasper-heap-based-buffer-overflow-in-jpc_dec_decodepkt-jpc_t2dec-c
This one should be https://github.com/mdadams/jasper/issues/114
Regards,
Salvatore
Skip to End
Mon, 13 Mar 2017 12:14:57 +0100 Agostino Sarubbo <ago-at-gentoo.org>, 4259614.1heLH0LskT@blackgate
On Wednesday 25 January 2017 10:16:01 Agostino Sarubbo wrote:
> Permalink:
> https://blogs.gentoo.org/ago/2017/01/25/jasper-heap-based-buffer-overflow-in
> -jpc_dec_decodepkt-jpc_t2dec-c
This is CVE-2017-6852
--
Agostino Sarubbo
Gentoo Linux Developer
Skip to End
Working, updating to latest version
Added some additional checking to prevent a potential integer overflow; Not sure if this is a commit to fix this issue; That msg came from a commit msg for this software
Edit: I dont think it does, but could be wrong
Hm, the upstream issue is open. It also has a testcase, interesting.
imginfo -f 00126-jasper-heapoverflow-jpc_dec_decodepkt
gives imginfo: /tmp/nix-build-jasper-2.0.10.drv-0/jasper-2.0.10/src/libjasper/jpc/jpc_t2cod.c:305: jpc_pi_nextrpcl: Assertion `pi->prcno < pi->pirlvl->numprcs' failed.
Does the updated version do the same?
… Yes it does.
If only we could snooze this issue until the upstream issue mdadams/jasper#114 gets closed or mentioned in PR/commit… (being able to translate comments from the upstream issue would also be nice)
fwiw I've merged the .12 update, because they're usually worth updating to. This issue is still one.
The patches I madee are:
master: 6c17ad677c4970c87e8562574ea7e6fbf12b0813 release-16.09: 4368adb6ac631b3bdbb071e96dfc545c1f8f92e1 release-17.03: beab3073c9caec3e6b67558efc6111bb68c7a2ab