-
Notifications
You must be signed in to change notification settings - Fork 432
Description
Hello,
We found a read out-of-bounds in tidy-html5 (git revision 03a643f). A test case to reproduce it is available here. You can see the ASAN report:
==29141== ERROR: AddressSanitizer: heap-buffer-overflow on address 0xb4b000ff at pc 0x81942b8 bp 0xbfffee48 sp 0xbfffee3c
READ of size 1 at 0xb4b000ff thread T0
#0 0x81942b7 (/home/vagrant/afl-tests/progs/tidy-html5/build/cmake/tidy+0x81942b7)
#1 0x81b4233 (/home/vagrant/afl-tests/progs/tidy-html5/build/cmake/tidy+0x81b4233)
#2 0x81b4233 (/home/vagrant/afl-tests/progs/tidy-html5/build/cmake/tidy+0x81b4233)
#3 0x81b74e3 (/home/vagrant/afl-tests/progs/tidy-html5/build/cmake/tidy+0x81b74e3)
#4 0x81b54a3 (/home/vagrant/afl-tests/progs/tidy-html5/build/cmake/tidy+0x81b54a3)
#5 0x81b54a3 (/home/vagrant/afl-tests/progs/tidy-html5/build/cmake/tidy+0x81b54a3)
#6 0x81b54a3 (/home/vagrant/afl-tests/progs/tidy-html5/build/cmake/tidy+0x81b54a3)
#7 0x81b4aeb (/home/vagrant/afl-tests/progs/tidy-html5/build/cmake/tidy+0x81b4aeb)
#8 0x80aaeb7 (/home/vagrant/afl-tests/progs/tidy-html5/build/cmake/tidy+0x80aaeb7)
#9 0x80541af (/home/vagrant/afl-tests/progs/tidy-html5/build/cmake/tidy+0x80541af)
#10 0xb6851a82 (/lib/i386-linux-gnu/libc-2.19.so+0x19a82)
#11 0x8058825 (/home/vagrant/afl-tests/progs/tidy-html5/build/cmake/tidy+0x8058825)
0xb4b000ff is located 1 bytes to the left of 8192-byte region [0xb4b00100,0xb4b02100)
allocated by thread T0 here:
#0 0xb69fc854 (/usr/lib/i386-linux-gnu/libasan.so.0.0.0+0x16854)
#1 0x82040c4 (/home/vagrant/afl-tests/progs/tidy-html5/build/cmake/tidy+0x82040c4)
Shadow bytes around the buggy address:
0x3695ffc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x3695ffd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x3695ffe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x3695fff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x36960000: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x36960010: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa[fa]
0x36960020:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x36960030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x36960040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x36960050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x36960060: 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
Heap righ 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
==29141== ABORTING
and the gdb backtrace is here:
(gdb) bt
#0 0xb7fdd428 in __kernel_vsyscall ()
#1 0xb6866607 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#2 0xb6869a33 in __GI_abort () at abort.c:89
#3 0xb6a042e4 in ?? () from /usr/lib/i386-linux-gnu/libasan.so.0
#4 0xb69f858a in ?? () from /usr/lib/i386-linux-gnu/libasan.so.0
#5 0xb6a00f4b in ?? () from /usr/lib/i386-linux-gnu/libasan.so.0
#6 0xb69ffd3a in __asan_report_error () from /usr/lib/i386-linux-gnu/libasan.so.0
#7 0xb69f88ff in __asan_report_load1 () from /usr/lib/i386-linux-gnu/libasan.so.0
#8 0x081942b8 in TextEndsWithNewline (lexer=, mode=25, node=0xb49017c0)
at /home/vagrant/afl-tests/progs/tidy-html5/src/pprint.c:1870
#9 PPrintText (doc=0xb6601d00, mode=25, indent=0, node=0xb49017c0)
at /home/vagrant/afl-tests/progs/tidy-html5/src/pprint.c:1008
#10 0x081b4234 in PPrintScriptStyle (node=0xb4901830, indent=0, mode=25, doc=0xb6601d00)
at /home/vagrant/afl-tests/progs/tidy-html5/src/pprint.c:1995
#11 prvTidyPPrintTree (doc=0xb6601d00, mode=25, indent=0, node=0xb4901830)
at /home/vagrant/afl-tests/progs/tidy-html5/src/pprint.c:2237
#12 0x081b4234 in PPrintScriptStyle (node=0xb4901910, indent=0, mode=25, doc=0xb6601d00)
at /home/vagrant/afl-tests/progs/tidy-html5/src/pprint.c:1995
#13 prvTidyPPrintTree (doc=0xb6601d00, mode=0, indent=0, node=0xb4901910)
at /home/vagrant/afl-tests/progs/tidy-html5/src/pprint.c:2237
#14 0x081b74e4 in prvTidyPPrintTree (doc=0xb6601d00, mode=0, indent=0, node=0xb49019f0)
at /home/vagrant/afl-tests/progs/tidy-html5/src/pprint.c:2278
#15 0x081b54a4 in prvTidyPPrintTree (doc=0xb6601d00, mode=0, indent=0, node=0xb4901bb0)
at /home/vagrant/afl-tests/progs/tidy-html5/src/pprint.c:2348
#16 0x081b54a4 in prvTidyPPrintTree (doc=0xb6601d00, mode=0, indent=0, node=0xb4901a60)
at /home/vagrant/afl-tests/progs/tidy-html5/src/pprint.c:2348
#17 0x081b54a4 in prvTidyPPrintTree (doc=0xb6601d00, mode=0, indent=0, node=0xb4901b40)
at /home/vagrant/afl-tests/progs/tidy-html5/src/pprint.c:2348
---Type to continue, or q to quit---
#18 0x081b4aec in prvTidyPPrintTree (doc=0xb6601d00, mode=0, indent=0, node=0xb6601d00)
at /home/vagrant/afl-tests/progs/tidy-html5/src/pprint.c:2141
#19 0x080aaeb8 in tidyDocSaveStream (out=0xb6400640, doc=0xb6601d00)
at /home/vagrant/afl-tests/progs/tidy-html5/src/tidylib.c:1899
#20 tidyDocSaveStdout (doc=0xb6601d00) at /home/vagrant/afl-tests/progs/tidy-html5/src/tidylib.c:1096
#21 tidySaveStdout (tdoc=tdoc@entry=0xb6601d00) at /home/vagrant/afl-tests/progs/tidy-html5/src/tidylib.c:997
#22 0x080541b0 in main (argc=2, argv=) at /home/vagrant/afl-tests/progs/tidy-html5/console/tidy.c:1943
Regards,
Gus.