stack-buffer-underflow in htmldoc
Closed this issue · 2 comments
Kaka201 commented
os: ubuntu 20.04
htmldoc version: master branch
command : ./htmldoc --webpage -f out.pdf ./poc.html
asan report
=================================================================
==100970==ERROR: AddressSanitizer: stack-buffer-underflow on address 0x7ffd98c936be at pc 0x000000605f03 bp 0x7ffd98c93690 sp 0x7ffd98c93688
READ of size 1 at 0x7ffd98c936be thread T0
#0 0x605f02 in image_load_bmp(image_t*, _IO_FILE*, int, int) /home/ubuntu/fuzz/htmldocc/htmldoc/image.cxx:1089:12
#1 0x602b94 in image_load /home/ubuntu/fuzz/htmldocc/htmldoc/image.cxx:831:14
#2 0x53bc18 in write_image(_IO_FILE*, render_str*, int) /home/ubuntu/fuzz/htmldocc/htmldoc/ps-pdf.cxx:10305:5
#3 0x5207fa in pdf_write_document(unsigned char*, unsigned char*, unsigned char*, unsigned char*, unsigned char*, unsigned char*, tree_str*, tree_str*) /home/ubuntu/fuzz/htmldocc/htmldoc/ps-pdf.cxx:2292:7
#4 0x50c977 in pspdf_export /home/ubuntu/fuzz/htmldocc/htmldoc/ps-pdf.cxx:910:7
#5 0x4e1663 in main /home/ubuntu/fuzz/htmldocc/htmldoc/htmldoc.cxx:1291:3
#6 0x7ff2c1e7d0b2 in __libc_start_main /build/glibc-YbNSs7/glibc-2.31/csu/../csu/libc-start.c:308:16
#7 0x41eadd in _start (/home/ubuntu/fuzz/htmldocc/htmldoc/htmldoc+0x41eadd)
Address 0x7ffd98c936be is located in stack of thread T0 at offset 30 in frame
#0 0x6048ef in image_load_bmp(image_t*, _IO_FILE*, int, int) /home/ubuntu/fuzz/htmldocc/htmldoc/image.cxx:881
This frame has 1 object(s):
[32, 1056) 'colormap' (line 894) <== Memory access at offset 30 underflows this variable
HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
(longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-buffer-underflow /home/ubuntu/fuzz/htmldocc/htmldoc/image.cxx:1089:12 in image_load_bmp(image_t*, _IO_FILE*, int, int)
Shadow bytes around the buggy address:
0x10003318a680: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10003318a690: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10003318a6a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10003318a6b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10003318a6c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x10003318a6d0: 00 00 00 00 f1 f1 f1[f1]00 00 00 00 00 00 00 00
0x10003318a6e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10003318a6f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10003318a700: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10003318a710: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10003318a720: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 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
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
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
Shadow gap: cc
==100970==ABORTING
michaelrsweet commented
Kaka201 commented
cve-2021-40985 has been assigned
report by luo likang of NSFOCUS TianJi team