Bug 1468475 - There is an out of bound read in ole.c of catdoc.
There is an out of bound read in ole.c of catdoc.
Status: NEW
Product: Fedora
Classification: Fedora
Component: catdoc (Show other bugs)
27
x86_64 Linux
unspecified Severity urgent
: ---
: ---
Assigned To: Adel Gadllah
Fedora Extras Quality Assurance
: Reopened
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2017-07-07 04:14 EDT by owl337
Modified: 2017-08-15 05:12 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2017-07-12 11:07:30 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Triggered by "./catdoc $POC" (61.37 KB, application/x-rar)
2017-07-07 04:14 EDT, owl337
no flags Details
this is file format of POC (88.43 KB, application/msword)
2017-07-08 05:32 EDT, owl337
no flags Details

  None (edit)
Description owl337 2017-07-07 04:14:59 EDT
Created attachment 1295216 [details]
Triggered by  "./catdoc $POC"

Description of problem:

ole.c:254 propCurrent = getlong(BBD, propCurrent*4);

When allocated BBD,
bbdNumBlocks = getulong(oleBuf,0x2c);
        bbdSize = bbdNumBlocks * sectorSize;
        if (bbdSize > fileLength) {
                /* broken file, BBD size greater than entire file*/
                return NULL;
        }

        if((BBD=malloc(bbdNumBlocks*sectorSize)) == NULL ) {


If the value at 0x2c of bbdNumBlocks equals 0 will cause the BBD size smaller, the following analytical code failed to check this situation, leading to out of bound read.


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

<= latest version

How reproducible:

./catdoc $POC


Steps to Reproduce:


The ASAN debugging information is as follows:

ASAN:SIGSEGV
=================================================================
==52554==ERROR: AddressSanitizer: SEGV on unknown address 0x602000047a3c (pc 0x00000048ffdd sp 0x7ffe186591a0 bp 0x7ffe18659790 T0)
==52554==WARNING: Trying to symbolize code, but external symbolizer is not initialized!
    #0 0x48ffdc (/home/company/collafl/testcases/catdoc-0.95/install/bin/catdoc_asan+0x48ffdc)
    #1 0x491739 (/home/company/collafl/testcases/catdoc-0.95/install/bin/catdoc_asan+0x491739)
    #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 0x7f78138a0a3f (/lib/x86_64-linux-gnu/libc.so.6+0x20a3f)
    #5 0x47c838 (/home/company/afl-fuzz-master/testcases/catdoc-0.95/install/bin/catdoc_asan+0x47c838)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV ??:0 ??
==52554==ABORTING


The gdb debug info is as follows:

#0  0x0000000000405bfa in getlong (buffer=0x691110 "", offset=0x3a00c) at numutils.c:22
#1  0x00000000004067fb in ole_init (f=0x68dc80, buffer=0x7fffffffdd40, bufSize=0x8) at ole.c:254
#2  0x00000000004028de in analyze_format (f=0x68dc80) at analyze.c:58
#3  0x0000000000401b6a in main (argc=0x2, argv=0x7fffffffdf28) at catdoc.c:180
#4  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
#5  0x0000000000401459 in _start ()

Actual results:

crash

Expected results:

crash

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 15:11:46 EDT
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 05:32 EDT
Created attachment 1295478 [details]
this is file format of POC
Comment 5 Jan Kurik 2017-08-15 05:12:01 EDT
This bug appears to have been reported against 'rawhide' during the Fedora 27 development cycle.
Changing version to '27'.

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