Skip to content
Memory corruption Disclosed report

Heap-use-after-free/buffer-overflow in nsHtml5TreeBuilder::adoptionAgencyEndTag

Atte Kettunen Follow

Originally disclosed on Mozilla

Critical View original
  • Fixed in 6 days
  • Paid in 2 months
  • Disclosed after 6 days
Text
Created attachment 8389397
Repro-file UAF

Tested on:

OS: Ubuntu 12.04 x64

Firefox: ASAN build from https://ftp.mozilla.org/pub/mozilla.org/firefox/tinderbox-builds/mozilla-central-linux64-asan/1394359324//firefox-30.0a1.en-US.linux-x86_64-asan.tar.bz2


ASAN-report:

=================================================================
==26462==ERROR: AddressSanitizer: heap-use-after-free on address 0x6060006f5128 at pc 0x7f759deeac53 bp 0x7f757e1f0e80 sp 0x7f757e1f0e78
READ of size 8 at 0x6060006f5128 thread T18 (HTML5 Parser)
    #0 0x7f759deeac52 in nsHtml5TreeBuilder::adoptionAgencyEndTag(nsIAtom*) /builds/slave/m-cen-l64-asan-000000000000000/build/parser/html/nsHtml5TreeBuilder.cpp:3515:0
    #1 0x7f759de87ee6 in nsHtml5TreeBuilder::endTag(nsHtml5ElementName*) /builds/slave/m-cen-l64-asan-000000000000000/build/parser/html/nsHtml5TreeBuilder.cpp:2683:0
    #2 0x7f759de84fee in nsHtml5Tokenizer::emitCurrentTagToken(bool, int) /builds/slave/m-cen-l64-asan-000000000000000/build/parser/html/nsHtml5Tokenizer.cpp:303:0
    #3 0x7f759dec47c4 in int nsHtml5Tokenizer::stateLoop<nsHtml5SilentPolicy>(int, char16_t, int, char16_t*, bool, int, int) /builds/slave/m-cen-l64-asan-000000000000000/build/parser/html/nsHtml5Tokenizer.cpp:562:0
    #4 0x7f759de7580a in nsHtml5Tokenizer::tokenizeBuffer(nsHtml5UTF16Buffer*) /builds/slave/m-cen-l64-asan-000000000000000/build/parser/html/nsHtml5Tokenizer.cpp:413:0
    #5 0x7f759de6fa8b in nsHtml5StreamParser::ParseAvailableData() /builds/slave/m-cen-l64-asan-000000000000000/build/parser/html/nsHtml5StreamParser.cpp:1381:0
    #6 0x7f759de7158e in nsHtml5StreamParser::DoDataAvailable(unsigned char const*, unsigned int) /builds/slave/m-cen-l64-asan-000000000000000/build/parser/html/nsHtml5StreamParser.cpp:1091:0
    #7 0x7f759df0c395 in nsHtml5DataAvailable::Run() /builds/slave/m-cen-l64-asan-000000000000000/build/parser/html/nsHtml5StreamParser.cpp:1123:0
    #8 0x7f759afde7b2 in nsThread::ProcessNextEvent(bool, bool*) /builds/slave/m-cen-l64-asan-000000000000000/build/xpcom/threads/nsThread.cpp:694:0
    #9 0x7f759aeb0a71 in NS_ProcessNextEvent(nsIThread*, bool) /builds/slave/m-cen-l64-asan-000000000000000/build/xpcom/glue/nsThreadUtils.cpp:263:0
    #10 0x7f759b818d70 in mozilla::ipc::MessagePumpForNonMainThreads::Run(base::MessagePump::Delegate*) /builds/slave/m-cen-l64-asan-000000000000000/build/ipc/glue/MessagePump.cpp:332:0
    #11 0x7f759b78a793 in RunInternal /builds/slave/m-cen-l64-asan-000000000000000/build/ipc/chromium/src/base/message_loop.cc:226:0
    #12 0x7f759b78a793 in RunHandler /builds/slave/m-cen-l64-asan-000000000000000/build/ipc/chromium/src/base/message_loop.cc:219:0
    #13 0x7f759b78a793 in MessageLoop::Run() /builds/slave/m-cen-l64-asan-000000000000000/build/ipc/chromium/src/base/message_loop.cc:193:0
    #14 0x7f759afdb532 in nsThread::ThreadFunc(void*) /builds/slave/m-cen-l64-asan-000000000000000/build/xpcom/threads/nsThread.cpp:308:0
    #15 0x7f75a948f009 in _pt_root /builds/slave/m-cen-l64-asan-000000000000000/build/nsprpub/pr/src/pthreads/ptthread.c:212:0
    #16 0x44cf03 in __asan::AsanThread::ThreadStart(unsigned long) _asan_rtl_:0
    #17 0x7f75ac9b7f8d in start_thread ??:?
    #18 0x7f75abab7a0c in ?? ??:0
0x6060006f5128 is located 8 bytes inside of 56-byte region [0x6060006f5120,0x6060006f5158)
freed by thread T18 (HTML5 Parser) here:
    #0 0x446255 in __interceptor_free _asan_rtl_:0
    #1 0x7f759deed77b in ~nsHtml5StackNode /builds/slave/m-cen-l64-asan-000000000000000/build/obj-firefox/parser/html/../../dist/include/mozilla/mozalloc.h:225:0
    #2 0x7f759deed77b in operator[] /builds/slave/m-cen-l64-asan-000000000000000/build/parser/html/nsHtml5StackNode.cpp:215:0
    #3 0x7f759deed77b in nsHtml5TreeBuilder::removeFromStack(int) /builds/slave/m-cen-l64-asan-000000000000000/build/parser/html/nsHtml5TreeBuilder.cpp:3458:0
previously allocated by thread T18 (HTML5 Parser) here:
    #0 0x446395 in malloc _asan_rtl_:0
    #1 0x7f75a70b0b18 in moz_xmalloc /builds/slave/m-cen-l64-asan-000000000000000/build/memory/mozalloc/mozalloc.cpp:52:0
Thread T18 (HTML5 Parser) created by T0 here:
    #0 0x437801 in __interceptor_pthread_create _asan_rtl_:0
    #1 0x7f75a948aea2 in _PR_CreateThread /builds/slave/m-cen-l64-asan-000000000000000/build/nsprpub/pr/src/pthreads/ptthread.c:453:0
    #2 0x7f75a948a9f7 in PR_CreateThread /builds/slave/m-cen-l64-asan-000000000000000/build/nsprpub/pr/src/pthreads/ptthread.c:544:0
Shadow bytes around the buggy address:
  0x0c0c800d69d0: 00 00 00 00 00 00 00 fa fa fa fa fa 00 00 00 00
  0x0c0c800d69e0: 00 00 00 00 fa fa fa fa 00 00 00 00 00 00 00 04
  0x0c0c800d69f0: fa fa fa fa 00 00 00 00 00 00 00 00 fa fa fa fa
  0x0c0c800d6a00: fd fd fd fd fd fd fd fa fa fa fa fa 00 00 00 00
  0x0c0c800d6a10: 00 00 00 00 fa fa fa fa fa fa fa fa fa fa fa fa
=>0x0c0c800d6a20: fa fa fa fa fd[fd]fd fd fd fd fd fa fa fa fa fa
  0x0c0c800d6a30: 00 00 00 00 00 00 00 00 fa fa fa fa fd fd fd fd
  0x0c0c800d6a40: fd fd fd fa fa fa fa fa 00 00 00 00 00 00 00 00
  0x0c0c800d6a50: fa fa fa fa 00 00 00 00 00 00 00 04 fa fa fa fa
  0x0c0c800d6a60: fd fd fd fd fd fd fd fd fa fa fa fa 00 00 00 00
  0x0c0c800d6a70: 00 00 00 00 fa fa fa fa 00 00 00 00 00 00 00 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
==26462==ABORTING

The original report as published on Mozilla's Bugzilla, by Atte Kettunen. Images and videos are our own copies; raw HTML is shown as text. View it on Mozilla's Bugzilla.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

What is known

A critical-severity memory corruption bug in DOM: HTML Parser. Mozilla made it public on 18 March 2014.

About Memory corruption

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

More by Atte Kettunen

View all

62 more disclosed reports, best first.

More from Mozilla

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.