Discussion:
[gs-bugs] [Bug 698804] - MuPDF - heap-buffer-overflow in ensure_solid_xref
b***@artifex.com
2017-12-09 20:23:18 UTC
Permalink
http://bugs.ghostscript.com/show_bug.cgi?id=698804

Bug ID: 698804
Summary: heap-buffer-overflow in ensure_solid_xref
Product: MuPDF
Version: master
Hardware: PC
OS: Linux
Status: UNCONFIRMED
Severity: normal
Priority: P4
Component: fuzzing
Assignee: mupdf-***@artifex.com
Reporter: ***@gmail.com
QA Contact: gs-***@ghostscript.com
Word Size: ---

Created attachment 14515
--> http://bugs.ghostscript.com/attachment.cgi?id=14515&action=edit
PoC

Hello.

I found a heap-buffer-overflow bug in MuPDF.

Please confirm.

Thanks.

OS: Ubuntu 16.04 32bit
Version: mutool version 1.12.0
Steps to reproduce:
1.Download the .POC files.
2.Compile the source code with ASan.
3../mutool info $PoC

```
=================================================================
==19702==ERROR: AddressSanitizer: heap-buffer-overflow on address 0xb5400690 at
pc 0x082a090e bp 0xbf958d68 sp 0xbf958d58
WRITE of size 32 at 0xb5400690 thread T0
#0 0x82a090d in ensure_solid_xref source/pdf/pdf-xref.c:211
#1 0x82a192f in pdf_get_xref_entry source/pdf/pdf-xref.c:324
#2 0x82a995f in pdf_load_xref source/pdf/pdf-xref.c:1240
#3 0x82aaf2e in pdf_init_document source/pdf/pdf-xref.c:1371
#4 0x82b1cb9 in pdf_open_document source/pdf/pdf-xref.c:2285
#5 0x808a252 in pdfinfo_info source/tools/pdfinfo.c:976
#6 0x808a976 in pdfinfo_main source/tools/pdfinfo.c:1041
#7 0x804ab86 in main source/tools/mutool.c:127
#8 0xb6f88636 in __libc_start_main (/lib/i386-linux-gnu/libc.so.6+0x18636)
#9 0x804a3d0 (/home/karas/mupdf/build/debug/mutool+0x804a3d0)

0xb5400690 is located 0 bytes to the right of 32-byte region
[0xb5400670,0xb5400690)
allocated by thread T0 here:
#0 0xb722edee in malloc (/usr/lib/i386-linux-gnu/libasan.so.2+0x96dee)
#1 0x8177fe6 in fz_malloc_default source/fitz/memory.c:227
#2 0x817733e in do_scavenging_malloc source/fitz/memory.c:22
#3 0x817797f in fz_calloc source/fitz/memory.c:124
#4 0x82a0522 in ensure_solid_xref source/pdf/pdf-xref.c:190
#5 0x82a192f in pdf_get_xref_entry source/pdf/pdf-xref.c:324
#6 0x82a995f in pdf_load_xref source/pdf/pdf-xref.c:1240
#7 0x82aaf2e in pdf_init_document source/pdf/pdf-xref.c:1371
#8 0x82b1cb9 in pdf_open_document source/pdf/pdf-xref.c:2285
#9 0x808a252 in pdfinfo_info source/tools/pdfinfo.c:976
#10 0x808a976 in pdfinfo_main source/tools/pdfinfo.c:1041
#11 0x804ab86 in main source/tools/mutool.c:127
#12 0xb6f88636 in __libc_start_main (/lib/i386-linux-gnu/libc.so.6+0x18636)

SUMMARY: AddressSanitizer: heap-buffer-overflow source/pdf/pdf-xref.c:211
ensure_solid_xref
Shadow bytes around the buggy address:
0x36a80080: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x36a80090: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x36a800a0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x36a800b0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x36a800c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa 00 00
=>0x36a800d0: 00 00[fa]fa 00 00 04 fa fa fa 00 00 00 fa fa fa
0x36a800e0: fd fd fd fa fa fa 00 00 00 04 fa fa 00 00 04 fa
0x36a800f0: fa fa fd fd fd fa fa fa 00 00 00 00 fa fa 00 00
0x36a80100: 04 fa fa fa 00 00 00 fa fa fa 00 00 00 fa fa fa
0x36a80110: 00 00 00 00 fa fa 00 00 00 fa fa fa 00 00 00 fa
0x36a80120: fa fa 00 00 00 00 fa fa 00 00 00 fa fa fa 00 00
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
==19702==ABORTING
```
--
You are receiving this mail because:
You are the QA Contact for the bug.
b***@artifex.com
2017-12-10 10:33:05 UTC
Permalink
http://bugs.ghostscript.com/show_bug.cgi?id=698804

Ken Sharp <***@artifex.com> changed:

What |Removed |Added
----------------------------------------------------------------------------
Product|MuPDF |Security
Assignee|mupdf-***@artifex.com |***@artifex.com
Component|fuzzing |Security
Priority|P4 |P1
Version|master |unspecified
Group| |Security
QA Contact|gs-***@ghostscript.com |gs-***@artifex.com
--
You are receiving this mail because:
You are the QA Contact for the bug.
Loading...