Bug 1468471 - There is heap buffer overflow in function ole_init of catdoc.
Summary: There is heap buffer overflow in function ole_init of catdoc.
Alias: None
Product: Fedora
Classification: Fedora
Component: catdoc
Version: 27
Hardware: x86_64
OS: Linux
Target Milestone: ---
Assignee: Adel Gadllah
QA Contact: Fedora Extras Quality Assurance
Depends On:
TreeView+ depends on / blocked
Reported: 2017-07-07 08:07 UTC by owl337
Modified: 2018-11-30 17:51 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Last Closed: 2018-11-30 17:51:25 UTC

Attachments (Terms of Use)
Triggered by "./catdoc $POC" (56.91 KB, application/x-rar)
2017-07-07 08:07 UTC, owl337
no flags Details
this is file format of POC (88.78 KB, application/x-ole-storage)
2017-07-08 09:31 UTC, owl337
no flags Details

Description owl337 2017-07-07 08:07:38 UTC
Created attachment 1295211 [details]
Triggered by  "./catdoc $POC"

Description of problem:

At ole.c:150:
                                                 1, sectorSize, newfile) != sectorSize) {

A short value at 0x1e of the file is assigned the power of sectorSize as follows:

long int sectorSize
sectorSize = 1<<getshort(oleBuf,0x1e);

If sectorSize is less than 4 and i is large enough, the input can override MSAT_ORIG_SIZE (436) so that fread writes data to tmpBuf before the contents cause heap underflow.

Version-Release number of selected component (if applicable):

<= latest version

How reproducible:

./catdoc $POC

Steps to Reproduce:

The ASAN debugging information is as follows:

==8489==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x616000001e7e at pc 0x48ffd8 bp 0x7ffdf50b19d0 sp 0x7ffdf50b19c8
READ of size 1 at 0x616000001e7e thread T0
==8489==WARNING: Trying to symbolize code, but external symbolizer is not initialized!
    #0 0x48ffd7 (/home/company/collafl/testcases/catdoc-0.95/install/bin/catdoc_asan+0x48ffd7)
    #1 0x490de3 (/home/company/collafl/testcases/catdoc-0.95/install/bin/catdoc_asan+0x490de3)
    #2 0x482189 (/home/company/collafl/testcases/catdoc-0.95/install/bin/catdoc_asan+0x482189)
    #3 0x47de9e (/home/company/collafl/testcases/catdoc-0.95/install/bin/catdoc_asan+0x47de9e)
    #4 0x7f9658881a3f (/lib/x86_64-linux-gnu/libc.so.6+0x20a3f)
    #5 0x47c838 (/home/company/collafl/testcases/catdoc-0.95/install/bin/catdoc_asan+0x47c838)

0x616000001e7e is located 2 bytes to the left of 582-byte region [0x616000001e80,0x6160000020c6)
allocated by thread T0 here:
    #0 0x466943 (/home/company/collafl/testcases/catdoc-0.95/install/bin/catdoc_asan+0x466943)
    #1 0x490c57 (/home/company/collafl/testcases/catdoc-0.95/install/bin/catdoc_asan+0x490c57)
    #2 0x482189 (/home/company/collafl/testcases/catdoc-0.95/install/bin/catdoc_asan+0x482189)
    #3 0x47de9e (/home/company/collafl/testcases/catdoc-0.95/install/bin/catdoc_asan+0x47de9e)
    #4 0x7f9658881a3f (/lib/x86_64-linux-gnu/libc.so.6+0x20a3f)

SUMMARY: AddressSanitizer: heap-buffer-overflow ??:0 ??
Shadow bytes around the buggy address:
  0x0c2c7fff8370: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c2c7fff8380: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c2c7fff8390: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c2c7fff83a0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c2c7fff83b0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x0c2c7fff83c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa[fa]
  0x0c2c7fff83d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c2c7fff83e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c2c7fff83f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c2c7fff8400: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c2c7fff8410: 00 00 00 00 00 00 00 00 06 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
  ASan internal:         fe

The gdb debug info is as follows:

#0  0x00007ffff7a43428 in __GI_raise (sig=sig@entry=0x6) at ../sysdeps/unix/sysv/linux/raise.c:54
#1  0x00007ffff7a4502a in __GI_abort () at abort.c:89
#2  0x00007ffff7a857ea in __libc_message (do_abort=do_abort@entry=0x2, fmt=fmt@entry=0x7ffff7b9e2e0 "*** Error in `%s': %s: 0x%s ***\n")
    at ../sysdeps/posix/libc_fatal.c:175
#3  0x00007ffff7a91ae8 in malloc_printerr (ar_ptr=0x0, ptr=<optimized out>, str=0x7ffff7b9e308 "munmap_chunk(): invalid pointer", 
    action=<optimized out>) at malloc.c:5004
#4  munmap_chunk (p=<optimized out>) at malloc.c:2840
#5  __GI___libc_free (mem=<optimized out>) at malloc.c:2961
#6  0x0000000000406400 in ole_init (f=0x68dc80, buffer=0x7fffffffdd40, bufSize=0x8) at ole.c:178
#7  0x00000000004028de in analyze_format (f=0x68dc80) at analyze.c:58
#8  0x0000000000401b6a in main (argc=0x2, argv=0x7fffffffdf28) at catdoc.c:180
#9  0x00007ffff7a2e830 in __libc_start_main (main=0x401526 <main>, argc=0x2, argv=0x7fffffffdf28, init=<optimized out>, 
    fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffdf18) at ../csu/libc-start.c:291
#10 0x0000000000401459 in _start ()

Actual results:


Expected results:


Additional info:

This vulnerability is detected by team OWL337, with our custom fuzzer collAFL. Please contact ganshuitao@gmail.com  and chaoz@tsinghua.edu.cn if you need more info about the team, the tool or the vulnerability.

Comment 1 Robert Scheck 2017-07-07 19:10:23 UTC
Did you also send this bug report to the upstream developers of catdoc?
May I kindly ask you to provide the reproducer in an open format (thus
not *.rar)?

Comment 2 owl337 2017-07-08 09:31:08 UTC
Created attachment 1295476 [details]
this is file format of POC

Comment 3 Agostino Sarubbo 2017-07-12 07:31:56 UTC
Please also check: https://catdocbugs.neocities.org/

Feel free to check by yourself if it is not a duplicate.

Comment 6 Jan Kurik 2017-08-15 09:15:13 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 27 development cycle.
Changing version to '27'.

Comment 7 Ben Cotton 2018-11-27 18:29:58 UTC
This message is a reminder that Fedora 27 is nearing its end of life.
On 2018-Nov-30  Fedora will stop maintaining and issuing updates for
Fedora 27. It is Fedora's policy to close all bug reports from releases
that are no longer maintained. At that time this bug will be closed as
EOL if it remains open with a Fedora  'version' of '27'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 27 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 8 Ben Cotton 2018-11-30 17:51:25 UTC
Fedora 27 changed to end-of-life (EOL) status on 2018-11-30. Fedora 27 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this

Thank you for reporting this bug and we are sorry it could not be fixed.

Note You need to log in before you can comment on or make changes to this bug.