Skip to content
Memory corruption Disclosed report CVE-2012-3995

Out of bounds read in IsCSSWordSpacingSpace

Abhishek Arya Follow

Originally disclosed on Mozilla

Critical View original
  • Fixed in 3 months
  • Paid in 13 months
  • Disclosed after 3 months

Created attachment 633924 Testcase

Reproduces on trunk, run testcase from command line. You also need the empty test.js as in archive. 20120617120215 http://hg.mozilla.org/mozilla-central/rev/b1a0fb2bdbf7

================================================================= ==27356== ERROR: AddressSanitizer heap-buffer-overflow on address 0x7fe2faee2f82 at pc 0x7fe3281b3821 bp 0x7fffdbd009d0 sp 0x7fffdbd009c8 READ of size 1 at 0x7fe2faee2f82 thread T0 #0 0x7fe3281b3821 in nsTextFragment::CharAt(int) const firefox/src/modules/zlib/src/inffast.c:0 #1 0x7fe328cca8a6 in IsCSSWordSpacingSpace(nsTextFragment const*, unsigned int, nsStyleText const*) firefox/src/layout/generic/nsTextFrameThebes.cpp:624 #2 0x7fe328cc811f in PropertyProvider::GetSpacingInternal(unsigned int, unsigned int, gfxFont::Spacing*, bool) firefox/src/layout/generic/nsTextFrameThebes.cpp:2817 #3 0x7fe328cc731d in PropertyProvider::GetSpacing(unsigned int, unsigned int, gfxFont::Spacing*) firefox/src/layout/generic/nsTextFrameThebes.cpp:2776 #4 0x7fe33382d073 in GetAdjustedSpacing(gfxTextRun*, unsigned int, unsigned int, gfxTextRun::PropertyProvider*, gfxFont::Spacing*) firefox/src/gfx/thebes/gfxFont.cpp:4489 #5 0x7fe333838a98 in gfxTextRun::BreakAndMeasureText(unsigned int, unsigned int, bool, double, gfxTextRun::PropertyProvider*, bool, double*, gfxFont::RunMetrics*, gfxFont::BoundingBoxType, gfxContext*, bool*, unsigned int*, bool, gfxBreakPriority*) firefox/src/gfx/thebes/gfxFont.cpp:4866 #6 0x7fe328d43127 in nsTextFrame::ReflowText(nsLineLayout&, int, nsRenderingContext*, bool, nsHTMLReflowMetrics&, unsigned int&) firefox/src/layout/generic/nsTextFrameThebes.cpp:7477 #7 0x7fe328b54e98 in nsLineLayout::ReflowFrame(nsIFrame*, unsigned int&, nsHTMLReflowMetrics*, bool&) firefox/src/layout/generic/nsLineLayout.cpp:836 #8 0x7fe328b2586d in nsInlineFrame::ReflowInlineFrame(nsPresContext*, nsHTMLReflowState const&, nsInlineFrame::InlineReflowState&, nsIFrame*, unsigned int&) firefox/src/layout/generic/nsInlineFrame.cpp:680 #9 0x7fe328b21f9d in nsInlineFrame::ReflowFrames(nsPresContext*, nsHTMLReflowState const&, nsInlineFrame::InlineReflowState&, nsHTMLReflowMetrics&, unsigned int&) firefox/src/layout/generic/nsInlineFrame.cpp:543 #10 0x7fe328b1f2aa in nsInlineFrame::Reflow(nsPresContext*, nsHTMLReflowMetrics&, nsHTMLReflowState const&, unsigned int&) firefox/src/layout/generic/nsInlineFrame.cpp:397 #11 0x7fe328b54b1f in nsLineLayout::ReflowFrame(nsIFrame*, unsigned int&, nsHTMLReflowMetrics*, bool&) firefox/src/layout/generic/nsLineLayout.cpp:824 #12 0x7fe328810a7f in nsBlockFrame::ReflowInlineFrame(nsBlockReflowState&, nsLineLayout&, nsLineList_iterator, nsIFrame*, LineReflowStatus*) firefox/src/layout/generic/nsBlockFrame.cpp:3834 #13 0x7fe32880a4da in nsBlockFrame::DoReflowInlineFrames(nsBlockReflowState&, nsLineLayout&, nsLineList_iterator, nsFlowAreaRect&, int&, nsFloatManager::SavedState*, bool*, LineReflowStatus*, bool) firefox/src/layout/generic/nsBlockFrame.cpp:3630 #14 0x7fe3287fcf57 in nsBlockFrame::ReflowInlineFrames(nsBlockReflowState&, nsLineList_iterator, bool*) firefox/src/layout/generic/nsBlockFrame.cpp:3482 #15 0x7fe3287eb90c in nsBlockFrame::ReflowLine(nsBlockReflowState&, nsLineList_iterator, bool*) firefox/src/layout/generic/nsBlockFrame.cpp:2570 #16 0x7fe3287d0d71 in nsBlockFrame::ReflowDirtyLines(nsBlockReflowState&) firefox/src/layout/generic/nsBlockFrame.cpp:2020 #17 0x7fe3287c480f in nsBlockFrame::Reflow(nsPresContext*, nsHTMLReflowMetrics&, nsHTMLReflowState const&, unsigned int&) firefox/src/layout/generic/nsBlockFrame.cpp:1069 #18 0x7fe328854a8b in nsBlockReflowContext::ReflowBlock(nsRect const&, bool, nsCollapsingMargin&, int, bool, nsLineBox*, nsHTMLReflowState&, unsigned int&, nsBlockReflowState&) firefox/src/layout/generic/nsBlockReflowContext.cpp:262 #19 0x7fe3287f5d77 in nsBlockFrame::ReflowBlockFrame(nsBlockReflowState&, nsLineList_iterator, bool*) firefox/src/layout/generic/nsBlockFrame.cpp:3206 #20 0x7fe3287eb466 in nsBlockFrame::ReflowLine(nsBlockReflowState&, nsLineList_iterator, bool*) firefox/src/layout/generic/nsBlockFrame.cpp:2514 #21 0x7fe3287d0d71 in nsBlockFrame::ReflowDirtyLines(nsBlockReflowState&) firefox/src/layout/generic/nsBlockFrame.cpp:2020 #22 0x7fe3287c480f in nsBlockFrame::Reflow(nsPresContext*, nsHTMLReflowMetrics&, nsHTMLReflowState const&, unsigned int&) firefox/src/layout/generic/nsBlockFrame.cpp:1069 #23 0x7fe3288b4527 in nsContainerFrame::ReflowChild(nsIFrame*, nsPresContext*, nsHTMLReflowMetrics&, nsHTMLReflowState const&, int, int, unsigned int, unsigned int&, nsOverflowContinuationTracker*) firefox/src/layout/generic/nsContainerFrame.cpp:906 #24 0x7fe3289fe1ae in nsHTMLScrollFrame::ReflowScrolledFrame(ScrollReflowState*, bool, bool, nsHTMLReflowMetrics*, bool) firefox/src/layout/generic/nsGfxScrollFrame.cpp:516 #25 0x7fe328a03a5a in nsHTMLScrollFrame::ReflowContents(ScrollReflowState*, nsHTMLReflowMetrics const&) firefox/src/layout/generic/nsGfxScrollFrame.cpp:616 #26 0x7fe328a07d7f in nsHTMLScrollFrame::Reflow(nsPresContext*, nsHTMLReflowMetrics&, nsHTMLReflowState const&, unsigned int&) firefox/src/layout/generic/nsGfxScrollFrame.cpp:857 #27 0x7fe328b54b1f in nsLineLayout::ReflowFrame(nsIFrame*, unsigned int&, nsHTMLReflowMetrics*, bool&) firefox/src/layout/generic/nsLineLayout.cpp:824 #28 0x7fe328810a7f in nsBlockFrame::ReflowInlineFrame(nsBlockReflowState&, nsLineLayout&, nsLineList_iterator, nsIFrame*, LineReflowStatus*) firefox/src/layout/generic/nsBlockFrame.cpp:3834 #29 0x7fe32880a4da in nsBlockFrame::DoReflowInlineFrames(nsBlockReflowState&, nsLineLayout&, nsLineList_iterator, nsFlowAreaRect&, int&, nsFloatManager::SavedState*, bool*, LineReflowStatus*, bool) firefox/src/layout/generic/nsBlockFrame.cpp:3630 #30 0x7fe3287fcf57 in nsBlockFrame::ReflowInlineFrames(nsBlockReflowState&, nsLineList_iterator, bool*) firefox/src/layout/generic/nsBlockFrame.cpp:3482 #31 0x7fe3287eb90c in nsBlockFrame::ReflowLine(nsBlockReflowState&, nsLineList_iterator, bool*) firefox/src/layout/generic/nsBlockFrame.cpp:2570 #32 0x7fe3287d0d71 in nsBlockFrame::ReflowDirtyLines(nsBlockReflowState&) firefox/src/layout/generic/nsBlockFrame.cpp:2020 #33 0x7fe3287c480f in nsBlockFrame::Reflow(nsPresContext*, nsHTMLReflowMetrics&, nsHTMLReflowState const&, unsigned int&) firefox/src/layout/generic/nsBlockFrame.cpp:1069 #34 0x7fe328b54b1f in nsLineLayout::ReflowFrame(nsIFrame*, unsigned int&, nsHTMLReflowMetrics*, bool&) firefox/src/layout/generic/nsLineLayout.cpp:824 #35 0x7fe328810a7f in nsBlockFrame::ReflowInlineFrame(nsBlockReflowState&, nsLineLayout&, nsLineList_iterator, nsIFrame*, LineReflowStatus*) firefox/src/layout/generic/nsBlockFrame.cpp:3834 #36 0x7fe32880af87 in nsBlockFrame::DoReflowInlineFrames(nsBlockReflowState&, nsLineLayout&, nsLineList_iterator, nsFlowAreaRect&, int&, nsFloatManager::SavedState*, bool*, LineReflowStatus*, bool) firefox/src/layout/generic/nsBlockFrame.cpp:3665 #37 0x7fe3287fcf57 in nsBlockFrame::ReflowInlineFrames(nsBlockReflowState&, nsLineList_iterator, bool*) firefox/src/layout/generic/nsBlockFrame.cpp:3482 #38 0x7fe3287eb90c in nsBlockFrame::ReflowLine(nsBlockReflowState&, nsLineList_iterator, bool*) firefox/src/layout/generic/nsBlockFrame.cpp:2570 #39 0x7fe3287d0d71 in nsBlockFrame::ReflowDirtyLines(nsBlockReflowState&) firefox/src/layout/generic/nsBlockFrame.cpp:2020 #40 0x7fe3287c480f in nsBlockFrame::Reflow(nsPresContext*, nsHTMLReflowMetrics&, nsHTMLReflowState const&, unsigned int&) firefox/src/layout/generic/nsBlockFrame.cpp:1069 #41 0x7fe328854a8b in nsBlockReflowContext::ReflowBlock(nsRect const&, bool, nsCollapsingMargin&, int, bool, nsLineBox*, nsHTMLReflowState&, unsigned int&, nsBlockReflowState&) firefox/src/layout/generic/nsBlockReflowContext.cpp:262 #42 0x7fe3287f5d77 in nsBlockFrame::ReflowBlockFrame(nsBlockReflowState&, nsLineList_iterator, bool*) firefox/src/layout/generic/nsBlockFrame.cpp:3206 #43 0x7fe3287eb466 in nsBlockFrame::ReflowLine(nsBlockReflowState&, nsLineList_iterator, bool*) firefox/src/layout/generic/nsBlockFrame.cpp:2514 #44 0x7fe3287d0d71 in nsBlockFrame::ReflowDirtyLines(nsBlockReflowState&) firefox/src/layout/generic/nsBlockFrame.cpp:2020 #45 0x7fe3287c480f in nsBlockFrame::Reflow(nsPresContext*, nsHTMLReflowMetrics&, nsHTMLReflowState const&, unsigned int&) firefox/src/layout/generic/nsBlockFrame.cpp:1069 #46 0x7fe3288b4527 in nsContainerFrame::ReflowChild(nsIFrame*, nsPresContext*, nsHTMLReflowMetrics&, nsHTMLReflowState const&, int, int, unsigned int, unsigned int&, nsOverflowContinuationTracker*) firefox/src/layout/generic/nsContainerFrame.cpp:906 #47 0x7fe328a83b57 in nsCanvasFrame::Reflow(nsPresContext*, nsHTMLReflowMetrics&, nsHTMLReflowState const&, unsigned int&) firefox/src/layout/generic/nsCanvasFrame.cpp:429 #48 0x7fe3288b4527 in nsContainerFrame::ReflowChild(nsIFrame*, nsPresContext*, nsHTMLReflowMetrics&, nsHTMLReflowState const&, int, int, unsigned int, unsigned int&, nsOverflowContinuationTracker*) firefox/src/layout/generic/nsContainerFrame.cpp:906 #49 0x7fe3289fe1ae in nsHTMLScrollFrame::ReflowScrolledFrame(ScrollReflowState*, bool, bool, nsHTMLReflowMetrics*, bool) firefox/src/layout/generic/nsGfxScrollFrame.cpp:516 #50 0x7fe328a03a5a in nsHTMLScrollFrame::ReflowContents(ScrollReflowState*, nsHTMLReflowMetrics const&) firefox/src/layout/generic/nsGfxScrollFrame.cpp:616 #51 0x7fe328a07d7f in nsHTMLScrollFrame::Reflow(nsPresContext*, nsHTMLReflowMetrics&, nsHTMLReflowState const&, unsigned int&) firefox/src/layout/generic/nsGfxScrollFrame.cpp:857 #52 0x7fe3288b4527 in nsContainerFrame::ReflowChild(nsIFrame*, nsPresContext*, nsHTMLReflowMetrics&, nsHTMLReflowState const&, int, int, unsigned int, unsigned int&, nsOverflowContinuationTracker*) firefox/src/layout/generic/nsContainerFrame.cpp:906 #53 0x7fe328ddbb81 in ViewportFrame::Reflow(nsPresContext*, nsHTMLReflowMetrics&, nsHTMLReflowState const&, unsigned int&) firefox/src/layout/generic/nsViewportFrame.cpp:200 #54 0x7fe32853d016 in PresShell::DoReflow(nsIFrame*, bool) firefox/src/layout/base/nsPresShell.cpp:7382 #55 0x7fe32856aaad in PresShell::ProcessReflowCommands(bool) firefox/src/layout/base/nsPresShell.cpp:7523 #56 0x7fe3285691bd in PresShell::FlushPendingNotifications(mozFlushType) firefox/src/layout/base/nsPresShell.cpp:3852 #57 0x7fe32836ba9f in DocumentViewerImpl::LoadComplete(unsigned int) firefox/src/layout/base/nsDocumentViewer.cpp:982 #58 0x7fe32fbd7a68 in nsDocShell::EndPageLoad(nsIWebProgress*, nsIChannel*, unsigned int) firefox/src/docshell/base/nsDocShell.cpp:6241 #59 0x7fe32fbcf7a1 in nsDocShell::OnStateChange(nsIWebProgress*, nsIRequest*, unsigned int, unsigned int) firefox/src/docshell/base/nsDocShell.cpp:6072 #60 0x7fe32fbd0965 in non-virtual thunk to nsDocShell::OnStateChange(nsIWebProgress*, nsIRequest*, unsigned int, unsigned int) firefox/src/modules/zlib/src/inffast.c:0 #61 0x7fe32fcd5004 in nsDocLoader::DoFireOnStateChange(nsIWebProgress*, nsIRequest*, int&, unsigned int) firefox/src/uriloader/base/nsDocLoader.cpp:1352 #62 0x7fe32fcd2a15 in nsDocLoader::doStopDocumentLoad(nsIRequest*, unsigned int) firefox/src/uriloader/base/nsDocLoader.cpp:930 #63 0x7fe32fccbc68 in nsDocLoader::DocLoaderIsEmpty(bool) firefox/src/uriloader/base/nsDocLoader.cpp:822 0x7fe2faee2f82 is located 0 bytes to the right of 2-byte region [0x7fe2faee2f80,0x7fe2faee2f82) allocated by thread T0 here: #0 0x4a3662 in malloc ??:0 #1 0x7fe33fbcc737 in moz_xmalloc firefox/src/memory/mozalloc/mozalloc.cpp:54 #2 0x7fe333280083 in NS_Alloc_P firefox/src/xpcom/base/nsMemoryImpl.cpp:163 #3 0x7fe326c9b033 in nsMemory::Alloc(unsigned long) firefox/src/../../../dist/include/nsMemory.h:36 #4 0x7fe32a1fd170 in nsTextFragment::Append(unsigned short const*, unsigned int, bool) firefox/src/content/base/src/nsTextFragment.cpp:382 #5 0x7fe329f3deb7 in nsGenericDOMDataNode::SetTextInternal(unsigned int, unsigned int, unsigned short const*, unsigned int, bool, CharacterDataChangeInfo::Details*) firefox/src/content/base/src/nsGenericDOMDataNode.cpp:312 #6 0x7fe329f4ccbc in nsGenericDOMDataNode::AppendText(unsigned short const*, unsigned int, bool) firefox/src/content/base/src/nsGenericDOMDataNode.cpp:858 #7 0x7fe32d0dd860 in nsHtml5TreeOperation::AppendTextToTextNode(unsigned short const*, unsigned int, nsIContent*, nsHtml5TreeOpExecutor*) firefox/src/parser/html/nsHtml5TreeOperation.cpp:140 #8 0x7fe32d0dee80 in nsHtml5TreeOperation::AppendText(unsigned short const*, unsigned int, nsIContent*, nsHtml5TreeOpExecutor*) firefox/src/parser/html/nsHtml5TreeOperation.cpp:155 #9 0x7fe32d0e8c5f in nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor*, nsIContent**) firefox/src/parser/html/nsHtml5TreeOperation.cpp:451 #10 0x7fe32d107856 in nsHtml5TreeOpExecutor::RunFlushLoop() firefox/src/parser/html/nsHtml5TreeOpExecutor.cpp:564 #11 0x7fe32d117065 in nsHtml5ExecutorReflusher::Run() firefox/src/parser/html/nsHtml5TreeOpExecutor.cpp:63 #12 0x7fe3331ff2c3 in nsThread::ProcessNextEvent(bool, bool*) firefox/src/xpcom/threads/nsThread.cpp:625 #13 0x7fe332e8e8dd in NS_ProcessNextEvent_P(nsIThread*, bool) firefox/src/objdir-ff-asan-sym/xpcom/build/nsThreadUtils.cpp:217 #14 0x7fe331ff4ee6 in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) firefox/src/ipc/glue/MessagePump.cpp:82 #15 0x7fe3334afcda in MessageLoop::RunInternal() firefox/src/ipc/chromium/src/base/message_loop.cc:209 #16 0x7fe3334afb23 in MessageLoop::RunHandler() firefox/src/ipc/chromium/src/base/message_loop.cc:202 #17 0x7fe3334afa08 in MessageLoop::Run() firefox/src/ipc/chromium/src/base/message_loop.cc:176 #18 0x7fe33152352e in nsBaseAppShell::Run() firefox/src/widget/xpwidgets/nsBaseAppShell.cpp:165 #19 0x7fe33016b098 in nsAppStartup::Run() firefox/src/toolkit/components/startup/nsAppStartup.cpp:256 #20 0x7fe326b3ee17 in XREMain::XRE_mainRun() firefox/src/toolkit/xre/nsAppRunner.cpp:3785 #21 0x7fe326b457d2 in XREMain::XRE_main(int, char**, nsXREAppData const*) firefox/src/toolkit/xre/nsAppRunner.cpp:3862 #22 0x7fe326b48c8b in XRE_main firefox/src/toolkit/xre/nsAppRunner.cpp:3938 ==27356== ABORTING Stats: 154M malloced (167M for red zones) by 355141 calls Stats: 44M realloced by 19866 calls Stats: 114M freed by 225726 calls Stats: 0M really freed by 0 calls Stats: 352M (90162 full pages) mmaped in 88 calls mmaps by size class: 8:278511; 9:57337; 10:20475; 11:18423; 12:3072; 13:2048; 14:1536; 15:384; 16:576; 17:128; 18:160; 19:56; 20:16; mallocs by size class: 8:265584; 9:48356; 10:17023; 11:17025; 12:2568; 13:1904; 14:1480; 15:341; 16:526; 17:112; 18:159; 19:49; 20:14; frees by size class: 8:155781; 9:37742; 10:13552; 11:13792; 12:1632; 13:994; 14:1281; 15:284; 16:456; 17:98; 18:57; 19:46; 20:11; rfrees by size class: Stats: malloc large: 334 small slow: 1873 Shadow byte and word: 0x1ffc5f5dc5f0: 2 0x1ffc5f5dc5f0: 02 fb fb fb fb fb fb fb More shadow bytes: 0x1ffc5f5dc5d0: fd fd fd fd fd fd fd fd 0x1ffc5f5dc5d8: fd fd fd fd fd fd fd fd 0x1ffc5f5dc5e0: fa fa fa fa fa fa fa fa 0x1ffc5f5dc5e8: fa fa fa fa fa fa fa fa =>0x1ffc5f5dc5f0: 02 fb fb fb fb fb fb fb 0x1ffc5f5dc5f8: fb fb fb fb fb fb fb fb 0x1ffc5f5dc600: fa fa fa fa fa fa fa fa 0x1ffc5f5dc608: fa fa fa fa fa fa fa fa 0x1ffc5f5dc610: 00 00 00 00 00 00 00 00

The original report as published on Mozilla's Bugzilla, by Abhishek Arya. 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 Layout: Block and Inline. Mozilla made it public on 18 September 2012 as CVE-2012-3995.

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 Abhishek Arya

View all

130 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.