Bug 1468472 - There is an illegal address access in ole_readdir funciton of catdoc.
There is an illegal address access in ole_readdir funciton of catdoc.
Status: NEW
Product: Fedora
Classification: Fedora
Component: catdoc (Show other bugs)
x86_64 Linux
unspecified Severity urgent
: ---
: ---
Assigned To: Adel Gadllah
Fedora Extras Quality Assurance
: Reopened
Depends On:
  Show dependency treegraph
Reported: 2017-07-07 04:11 EDT by owl337
Modified: 2017-08-15 05:11 EDT (History)
3 users (show)

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

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

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

Description of problem:

At Ole.c: 450,  res = 512 + rootEntry-> blocks [sbdSecNum] * sectorSize + sbdSecMod * shortSectorSize;

The array blocks of rootEntry  has no initialization caused by illegal address access.

The trigger point is located in ole.c: 356 of the ole_readdir function
If (e-> startBlock> = 0 &&
                E-> length> = 0 &&
                (E-> startBlock <=
                 FileLength / (e-> isBigBlock? SectorSize: shortSectorSize))) {
Constructs a large enough e-> startBlock to bypass, causing blocks to this array without allocating space. 

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

<= latest version

How reproducible:

./catdoc $POC

Steps to Reproduce:

The ASAN debugging information is as follows:

==37892==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000078 (pc 0x000000493422 sp 0x7ffd7817df80 bp 0x7ffd7817e490 T0)
==37892==WARNING: Trying to symbolize code, but external symbolizer is not initialized!
    #0 0x493421 (/home/company/collafl/testcases/catdoc-0.95/install/bin/catdoc_asan+0x493421)
    #1 0x48227a (/home/company/collafl/testcases/catdoc-0.95/install/bin/catdoc_asan+0x48227a)
    #2 0x47de9e (/home/company/collafl/testcases/catdoc-0.95/install/bin/catdoc_asan+0x47de9e)
    #3 0x7fa8f80dfa3f (/lib/x86_64-linux-gnu/libc.so.6+0x20a3f)
    #4 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 ??

The gdb debugging information is as follows:

#0  0x0000000000406f67 in calcFileBlockOffset (e=0x6933d0, blk=0x0) at ole.c:450
#1  0x00000000004070de in ole_read (ptr=0x7fffffffdda0, size=0x1, nmemb=0x80, stream=0x6933d0) at ole.c:493
#2  0x000000000040295b in analyze_format (f=0x68dc80) at analyze.c:64
#3  0x0000000000401b6a in main (argc=0x2, argv=0x7fffffffdf88) at catdoc.c:180
#4  0x00007ffff7a2e830 in __libc_start_main (main=0x401526 <main>, argc=0x2, argv=0x7fffffffdf88, init=<optimized out>, 
    fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffdf78) at ../csu/libc-start.c:291
#5  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 15:11:07 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 1295477 [details]
this is file format of POC
Comment 5 Jan Kurik 2017-08-15 05:11:54 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.