Skip to content
Memory corruption Disclosed report Advanced CVE-2021-23997

AddressSanitizer: heap-use-after-free at gfxFont.h GetUnicodeRangeMap in RefPtr.h get

A crafted HTML page triggers a heap-use-after-free in Firefox's font cache when the tab is closed, as reported by AddressSanitizer. The crash occurs in gfxFontCache::DestroyFont while looking up a font entry whose memory has already been freed, causing the content process to abort.

Irvan Kurniawan Follow

Originally disclosed on Mozilla

  • Fixed in 3 days
  • Paid in 7 days
  • Disclosed after 3 days

Created attachment 9212511 testcase.html

After open the testcase, then close the tab, the tab crash with SUMMARY: AddressSanitizer: heap-use-after-free /builds/worker/workspace/obj-build/dist/include/mozilla/RefPtr.h:286:27 in get.

I'm currently able to reproduce this on Firefox ASan Nightly 89.0a1 (2021-03-30) (64-bit) from fuzzfetch m-c-20210330035059-fuzzing-asan-opt.

Steps to reproduce:

  1. Open Firefox ASan Nightly from terminal (to view the ASan output)
  2. Visit the testcase.html
  3. Close the tab
  4. On the console, ASan will show output "AddressSanitizer: heap-use-after-free"

ASan output:

=================================================================
==1163767==ERROR: AddressSanitizer: heap-use-after-free on address 0x61400055a288 at pc 0x7f639ce90178 bp 0x7ffcb518b280 sp 0x7ffcb518b278
READ of size 8 at 0x61400055a288 thread T0 (file:// Content)
    #0 0x7f639ce90177 in get /builds/worker/workspace/obj-build/dist/include/mozilla/RefPtr.h:286:27
    #1 0x7f639ce90177 in GetUnicodeRangeMap /builds/worker/workspace/obj-build/dist/include/gfxFont.h:1764:29
    #2 0x7f639ce90177 in gfxFontCache::HashEntry::KeyEquals(gfxFontCache::Key const*) const /builds/worker/checkouts/gecko/gfx/thebes/gfxFont.cpp:220:55
    #3 0x7f639a05767c in SearchTable<PLDHashTable::ForSearchOrRemove, (lambda at /builds/worker/checkouts/gecko/xpcom/ds/PLDHashTable.cpp:500:7), (lambda at /builds/worker/checkouts/gecko/xpcom/ds/PLDHashTable.cpp:501:7)> /builds/worker/checkouts/gecko/xpcom/ds/PLDHashTable.cpp:375:11
    #4 0x7f639a05767c in PLDHashTable::Search(void const*) const /builds/worker/checkouts/gecko/xpcom/ds/PLDHashTable.cpp:498:10
    #5 0x7f639ce90f70 in GetEntry /builds/worker/workspace/obj-build/dist/include/nsTHashtable.h:289:16
    #6 0x7f639ce90f70 in gfxFontCache::DestroyFont(gfxFont*) /builds/worker/checkouts/gecko/gfx/thebes/gfxFont.cpp:282:29
    #7 0x7f639ce90e22 in gfxFontCache::NotifyReleased(gfxFont*) /builds/worker/checkouts/gecko/gfx/thebes/gfxFont.cpp:264:5
    #8 0x7f639cfd3eb7 in NotifyReleased /builds/worker/checkouts/gecko/gfx/thebes/gfxFont.h:1440:14
    #9 0x7f639cfd3eb7 in Release /builds/worker/checkouts/gecko/gfx/thebes/gfxFont.h:1415:7
    #10 0x7f639cfd3eb7 in gfxFontGroup::FamilyFace::~FamilyFace() /builds/worker/checkouts/gecko/gfx/thebes/gfxTextRun.h:1230:9
    #11 0x7f639cfff5e7 in Destruct /builds/worker/workspace/obj-build/dist/include/nsTArray.h:645:45
    #12 0x7f639cfff5e7 in nsTArray_Impl<gfxFontGroup::FamilyFace, nsTArrayInfallibleAllocator>::DestructRange(unsigned long, unsigned long) /builds/worker/workspace/obj-build/dist/include/nsTArray.h:2404:7
    #13 0x7f639cfd27df in ClearAndRetainStorage /builds/worker/workspace/obj-build/dist/include/nsTArray.h:1482:5
    #14 0x7f639cfd27df in nsTArray_Impl<gfxFontGroup::FamilyFace, nsTArrayInfallibleAllocator>::~nsTArray_Impl() /builds/worker/workspace/obj-build/dist/include/nsTArray.h:1037:7
    #15 0x7f639cfd26e6 in gfxFontGroup::~gfxFontGroup() /builds/worker/checkouts/gecko/gfx/thebes/gfxTextRun.cpp:1859:1
    #16 0x7f639cfd286d in gfxFontGroup::~gfxFontGroup() /builds/worker/checkouts/gecko/gfx/thebes/gfxTextRun.cpp:1856:31
    #17 0x7f639c785303 in Release /builds/worker/workspace/obj-build/dist/include/gfxFont.h:588:3
    #18 0x7f639c785303 in Release /builds/worker/workspace/obj-build/dist/include/mozilla/RefPtr.h:50:40
    #19 0x7f639c785303 in Release /builds/worker/workspace/obj-build/dist/include/mozilla/RefPtr.h:381:36
    #20 0x7f639c785303 in ~RefPtr /builds/worker/workspace/obj-build/dist/include/mozilla/RefPtr.h:81:7
    #21 0x7f639c785303 in nsFontMetrics::~nsFontMetrics() /builds/worker/checkouts/gecko/gfx/src/nsFontMetrics.cpp:145:1
    #22 0x7f639c7694c5 in Release /builds/worker/checkouts/gecko/gfx/src/nsFontMetrics.h:74:3
    #23 0x7f639c7694c5 in nsFontCache::Flush(int) /builds/worker/checkouts/gecko/gfx/src/nsDeviceContext.cpp:229:5
    #24 0x7f639c76a7d2 in nsDeviceContext::~nsDeviceContext() /builds/worker/checkouts/gecko/gfx/src/nsDeviceContext.cpp:254:17
    #25 0x7f63a21fb7cc in Release /builds/worker/workspace/obj-build/dist/include/nsDeviceContext.h:43:3
    #26 0x7f63a21fb7cc in Release /builds/worker/workspace/obj-build/dist/include/mozilla/RefPtr.h:50:40
    #27 0x7f63a21fb7cc in Release /builds/worker/workspace/obj-build/dist/include/mozilla/RefPtr.h:381:36
    #28 0x7f63a21fb7cc in ~RefPtr /builds/worker/workspace/obj-build/dist/include/mozilla/RefPtr.h:81:7
    #29 0x7f63a21fb7cc in nsPresContext::~nsPresContext() /builds/worker/checkouts/gecko/layout/base/nsPresContext.cpp:308:1
    #30 0x7f63a22128f7 in ~nsRootPresContext /builds/worker/checkouts/gecko/layout/base/nsPresContext.h:1366:7
    #31 0x7f63a22128f7 in nsRootPresContext::~nsRootPresContext() /builds/worker/checkouts/gecko/layout/base/nsPresContext.h:1366:7
    #32 0x7f6399ffe702 in SnowWhiteKiller::~SnowWhiteKiller() /builds/worker/checkouts/gecko/xpcom/base/nsCycleCollector.cpp:2421:7
    #33 0x7f6399ffdb66 in nsCycleCollector::FreeSnowWhite(bool) /builds/worker/checkouts/gecko/xpcom/base/nsCycleCollector.cpp:2611:3
    #34 0x7f639a005719 in nsCycleCollector::BeginCollection(ccType, nsICycleCollectorListener*) /builds/worker/checkouts/gecko/xpcom/base/nsCycleCollector.cpp:3592:3
    #35 0x7f639a004e0e in nsCycleCollector::Collect(ccType, js::SliceBudget&, nsICycleCollectorListener*, bool) /builds/worker/checkouts/gecko/xpcom/base/nsCycleCollector.cpp:3415:9
    #36 0x7f639a004925 in nsCycleCollector::ShutdownCollect() /builds/worker/checkouts/gecko/xpcom/base/nsCycleCollector.cpp:3358:20
    #37 0x7f639a006976 in nsCycleCollector::Shutdown(bool) /builds/worker/checkouts/gecko/xpcom/base/nsCycleCollector.cpp:3653:5
    #38 0x7f639a008503 in nsCycleCollector_shutdown(bool) /builds/worker/checkouts/gecko/xpcom/base/nsCycleCollector.cpp:3968:18
    #39 0x7f639a227f3a in mozilla::ShutdownXPCOM(nsIServiceManager*) /builds/worker/checkouts/gecko/xpcom/build/XPCOMInit.cpp:706:3
    #40 0x7f63a568c85c in XRE_TermEmbedding() /builds/worker/checkouts/gecko/toolkit/xre/nsEmbedFunctions.cpp:212:3
    #41 0x7f639b406304 in mozilla::ipc::ScopedXREEmbed::Stop() /builds/worker/checkouts/gecko/ipc/glue/ScopedXREEmbed.cpp:90:5
    #42 0x7f63a568d3b3 in XRE_InitChildProcess(int, char**, XREChildData const*) /builds/worker/checkouts/gecko/toolkit/xre/nsEmbedFunctions.cpp:738:16
    #43 0x557a2acdbc8d in content_process_main(mozilla::Bootstrap*, int, char**) /builds/worker/checkouts/gecko/browser/app/../../ipc/contentproc/plugin-container.cpp:57:28
    #44 0x557a2acdc0b1 in main /builds/worker/checkouts/gecko/browser/app/nsBrowserApp.cpp:309:18
    #45 0x7f63ba8f9b24 in __libc_start_main (/usr/lib/libc.so.6+0x27b24)
    #46 0x557a2ac2f629 in _start (/tmp/m-c-20210330035059-fuzzing-asan-opt/firefox+0x5a629)

0x61400055a288 is located 72 bytes inside of 400-byte region [0x61400055a240,0x61400055a3d0)
freed by thread T0 (file:// Content) here:
    #0 0x557a2aca923d in free /builds/worker/fetches/llvm-project/llvm/projects/compiler-rt/lib/asan/asan_malloc_linux.cpp:123:3
    #1 0x7f639ce90fcd in gfxFontCache::DestroyFont(gfxFont*) /builds/worker/checkouts/gecko/gfx/thebes/gfxFont.cpp:288:3
    #2 0x7f639ce90e22 in gfxFontCache::NotifyReleased(gfxFont*) /builds/worker/checkouts/gecko/gfx/thebes/gfxFont.cpp:264:5
    #3 0x7f639cfd3eb7 in NotifyReleased /builds/worker/checkouts/gecko/gfx/thebes/gfxFont.h:1440:14
    #4 0x7f639cfd3eb7 in Release /builds/worker/checkouts/gecko/gfx/thebes/gfxFont.h:1415:7
    #5 0x7f639cfd3eb7 in gfxFontGroup::FamilyFace::~FamilyFace() /builds/worker/checkouts/gecko/gfx/thebes/gfxTextRun.h:1230:9
    #6 0x7f639cfff5e7 in Destruct /builds/worker/workspace/obj-build/dist/include/nsTArray.h:645:45
    #7 0x7f639cfff5e7 in nsTArray_Impl<gfxFontGroup::FamilyFace, nsTArrayInfallibleAllocator>::DestructRange(unsigned long, unsigned long) /builds/worker/workspace/obj-build/dist/include/nsTArray.h:2404:7
    #8 0x7f639cfd27df in ClearAndRetainStorage /builds/worker/workspace/obj-build/dist/include/nsTArray.h:1482:5
    #9 0x7f639cfd27df in nsTArray_Impl<gfxFontGroup::FamilyFace, nsTArrayInfallibleAllocator>::~nsTArray_Impl() /builds/worker/workspace/obj-build/dist/include/nsTArray.h:1037:7
    #10 0x7f639cfd26e6 in gfxFontGroup::~gfxFontGroup() /builds/worker/checkouts/gecko/gfx/thebes/gfxTextRun.cpp:1859:1
    #11 0x7f639cfd286d in gfxFontGroup::~gfxFontGroup() /builds/worker/checkouts/gecko/gfx/thebes/gfxTextRun.cpp:1856:31
    #12 0x7f639c785303 in Release /builds/worker/workspace/obj-build/dist/include/gfxFont.h:588:3
    #13 0x7f639c785303 in Release /builds/worker/workspace/obj-build/dist/include/mozilla/RefPtr.h:50:40
    #14 0x7f639c785303 in Release /builds/worker/workspace/obj-build/dist/include/mozilla/RefPtr.h:381:36
    #15 0x7f639c785303 in ~RefPtr /builds/worker/workspace/obj-build/dist/include/mozilla/RefPtr.h:81:7
    #16 0x7f639c785303 in nsFontMetrics::~nsFontMetrics() /builds/worker/checkouts/gecko/gfx/src/nsFontMetrics.cpp:145:1
    #17 0x7f639c7694c5 in Release /builds/worker/checkouts/gecko/gfx/src/nsFontMetrics.h:74:3
    #18 0x7f639c7694c5 in nsFontCache::Flush(int) /builds/worker/checkouts/gecko/gfx/src/nsDeviceContext.cpp:229:5
    #19 0x7f639c76a7d2 in nsDeviceContext::~nsDeviceContext() /builds/worker/checkouts/gecko/gfx/src/nsDeviceContext.cpp:254:17
    #20 0x7f63a21fb7cc in Release /builds/worker/workspace/obj-build/dist/include/nsDeviceContext.h:43:3
    #21 0x7f63a21fb7cc in Release /builds/worker/workspace/obj-build/dist/include/mozilla/RefPtr.h:50:40
    #22 0x7f63a21fb7cc in Release /builds/worker/workspace/obj-build/dist/include/mozilla/RefPtr.h:381:36
    #23 0x7f63a21fb7cc in ~RefPtr /builds/worker/workspace/obj-build/dist/include/mozilla/RefPtr.h:81:7
    #24 0x7f63a21fb7cc in nsPresContext::~nsPresContext() /builds/worker/checkouts/gecko/layout/base/nsPresContext.cpp:308:1
    #25 0x7f63a22128f7 in ~nsRootPresContext /builds/worker/checkouts/gecko/layout/base/nsPresContext.h:1366:7
    #26 0x7f63a22128f7 in nsRootPresContext::~nsRootPresContext() /builds/worker/checkouts/gecko/layout/base/nsPresContext.h:1366:7
    #27 0x7f6399ffe702 in SnowWhiteKiller::~SnowWhiteKiller() /builds/worker/checkouts/gecko/xpcom/base/nsCycleCollector.cpp:2421:7
    #28 0x7f6399ffdb66 in nsCycleCollector::FreeSnowWhite(bool) /builds/worker/checkouts/gecko/xpcom/base/nsCycleCollector.cpp:2611:3
    #29 0x7f639a005719 in nsCycleCollector::BeginCollection(ccType, nsICycleCollectorListener*) /builds/worker/checkouts/gecko/xpcom/base/nsCycleCollector.cpp:3592:3
    #30 0x7f639a004e0e in nsCycleCollector::Collect(ccType, js::SliceBudget&, nsICycleCollectorListener*, bool) /builds/worker/checkouts/gecko/xpcom/base/nsCycleCollector.cpp:3415:9
    #31 0x7f639a004925 in nsCycleCollector::ShutdownCollect() /builds/worker/checkouts/gecko/xpcom/base/nsCycleCollector.cpp:3358:20
    #32 0x7f639a006976 in nsCycleCollector::Shutdown(bool) /builds/worker/checkouts/gecko/xpcom/base/nsCycleCollector.cpp:3653:5
    #33 0x7f639a008503 in nsCycleCollector_shutdown(bool) /builds/worker/checkouts/gecko/xpcom/base/nsCycleCollector.cpp:3968:18
    #34 0x7f639a227f3a in mozilla::ShutdownXPCOM(nsIServiceManager*) /builds/worker/checkouts/gecko/xpcom/build/XPCOMInit.cpp:706:3
    #35 0x7f63a568c85c in XRE_TermEmbedding() /builds/worker/checkouts/gecko/toolkit/xre/nsEmbedFunctions.cpp:212:3
    #36 0x7f639b406304 in mozilla::ipc::ScopedXREEmbed::Stop() /builds/worker/checkouts/gecko/ipc/glue/ScopedXREEmbed.cpp:90:5
    #37 0x7f63a568d3b3 in XRE_InitChildProcess(int, char**, XREChildData const*) /builds/worker/checkouts/gecko/toolkit/xre/nsEmbedFunctions.cpp:738:16
    #38 0x557a2acdbc8d in content_process_main(mozilla::Bootstrap*, int, char**) /builds/worker/checkouts/gecko/browser/app/../../ipc/contentproc/plugin-container.cpp:57:28
    #39 0x557a2acdc0b1 in main /builds/worker/checkouts/gecko/browser/app/nsBrowserApp.cpp:309:18
    #40 0x7f63ba8f9b24 in __libc_start_main (/usr/lib/libc.so.6+0x27b24)

previously allocated by thread T0 (file:// Content) here:
    #0 0x557a2aca94bd in malloc /builds/worker/fetches/llvm-project/llvm/projects/compiler-rt/lib/asan/asan_malloc_linux.cpp:145:3
    #1 0x557a2ace2e4d in moz_xmalloc /builds/worker/checkouts/gecko/memory/mozalloc/mozalloc.cpp:52:15
    #2 0x7f639ce19443 in operator new /builds/worker/workspace/obj-build/dist/include/mozilla/cxxalloc.h:33:10
    #3 0x7f639ce19443 in gfxFontconfigFontEntry::CreateFontInstance(gfxFontStyle const*) /builds/worker/checkouts/gecko/gfx/thebes/gfxFcPlatformFontList.cpp:873:22
    #4 0x7f639ce6a183 in gfxFontEntry::FindOrMakeFont(gfxFontStyle const*, gfxCharacterMap*) /builds/worker/checkouts/gecko/gfx/thebes/gfxFontEntry.cpp:281:24
    #5 0x7f639cfd44ad in gfxFontGroup::GetFontAt(int, unsigned int, bool*) /builds/worker/checkouts/gecko/gfx/thebes/gfxTextRun.cpp:2058:16
    #6 0x7f639cfd5ca2 in gfxFontGroup::GetFirstValidFont(unsigned int, mozilla::StyleGenericFontFamily*) /builds/worker/checkouts/gecko/gfx/thebes/gfxTextRun.cpp:2280:12
    #7 0x7f639c78630a in GetMetrics(nsFontMetrics*, nsFontMetrics::FontOrientation) /builds/worker/checkouts/gecko/gfx/src/nsFontMetrics.cpp:155:46
    #8 0x7f639c785f2d in GetMetrics /builds/worker/checkouts/gecko/gfx/src/nsFontMetrics.cpp:160:10
    #9 0x7f639c785f2d in nsFontMetrics::MaxAscent() /builds/worker/checkouts/gecko/gfx/src/nsFontMetrics.cpp:234:10
    #10 0x7f63a21d26de in nsLayoutUtils::GetCenteredFontBaseline(nsFontMetrics*, int, bool) /builds/worker/checkouts/gecko/layout/base/nsLayoutUtils.cpp:5674:64
    #11 0x7f63a24a8730 in nsLineLayout::VerticalAlignFrames(nsLineLayout::PerSpanData*) /builds/worker/checkouts/gecko/layout/generic/nsLineLayout.cpp:2284:31
    #12 0x7f63a24aa175 in nsLineLayout::VerticalAlignLine() /builds/worker/checkouts/gecko/layout/generic/nsLineLayout.cpp:1506:3
    #13 0x7f63a229954b in nsBlockFrame::PlaceLine(mozilla::BlockReflowInput&, nsLineLayout&, nsLineList_iterator, nsFloatManager::SavedState*, nsFlowAreaRect&, int&, bool*) /builds/worker/checkouts/gecko/layout/generic/nsBlockFrame.cpp:4867:15
    #14 0x7f63a2297f12 in nsBlockFrame::DoReflowInlineFrames(mozilla::BlockReflowInput&, nsLineLayout&, nsLineList_iterator, nsFlowAreaRect&, int&, nsFloatManager::SavedState*, bool*, LineReflowStatus*, bool) /builds/worker/checkouts/gecko/layout/generic/nsBlockFrame.cpp:4461:12
    #15 0x7f63a2290dae in nsBlockFrame::ReflowInlineFrames(mozilla::BlockReflowInput&, nsLineList_iterator, bool*) /builds/worker/checkouts/gecko/layout/generic/nsBlockFrame.cpp:4219:9
    #16 0x7f63a228a6b9 in nsBlockFrame::ReflowLine(mozilla::BlockReflowInput&, nsLineList_iterator, bool*) /builds/worker/checkouts/gecko/layout/generic/nsBlockFrame.cpp:3199:5
    #17 0x7f63a22824a0 in nsBlockFrame::ReflowDirtyLines(mozilla::BlockReflowInput&) /builds/worker/checkouts/gecko/layout/generic/nsBlockFrame.cpp:2733:7
    #18 0x7f63a227ccff in nsBlockFrame::Reflow(nsPresContext*, mozilla::ReflowOutput&, mozilla::ReflowInput const&, nsReflowStatus&) /builds/worker/checkouts/gecko/layout/generic/nsBlockFrame.cpp:1375:3
    #19 0x7f63a26935d9 in mozilla::SVGTextFrame::DoReflow() /builds/worker/checkouts/gecko/layout/svg/SVGTextFrame.cpp:5118:8
    #20 0x7f63a26835de in mozilla::SVGTextFrame::MaybeReflowAnonymousBlockChild() /builds/worker/checkouts/gecko/layout/svg/SVGTextFrame.cpp:5059:5
    #21 0x7f63a265f6b8 in mozilla::SVGTextFrame::ReflowSVG() /builds/worker/checkouts/gecko/layout/svg/SVGTextFrame.cpp:3294:3
    #22 0x7f63a262a3cf in mozilla::SVGDisplayContainerFrame::ReflowSVG() /builds/worker/checkouts/gecko/layout/svg/SVGContainerFrame.cpp:320:17
    #23 0x7f63a26964ed in mozilla::SVGUseFrame::ReflowSVG() /builds/worker/checkouts/gecko/layout/svg/SVGUseFrame.cpp:114:14
    #24 0x7f63a262a3cf in mozilla::SVGDisplayContainerFrame::ReflowSVG() /builds/worker/checkouts/gecko/layout/svg/SVGContainerFrame.cpp:320:17
    #25 0x7f63a266ad5e in mozilla::SVGOuterSVGFrame::Reflow(nsPresContext*, mozilla::ReflowOutput&, mozilla::ReflowInput const&, nsReflowStatus&) /builds/worker/checkouts/gecko/layout/svg/SVGOuterSVGFrame.cpp:453:14
    #26 0x7f63a20b4389 in mozilla::PresShell::DoReflow(nsIFrame*, bool, mozilla::OverflowChangedTracker*) /builds/worker/checkouts/gecko/layout/base/PresShell.cpp:9630:11
    #27 0x7f63a20c6037 in mozilla::PresShell::ProcessReflowCommands(bool) /builds/worker/checkouts/gecko/layout/base/PresShell.cpp:9801:24
    #28 0x7f63a20c4769 in mozilla::PresShell::DoFlushPendingNotifications(mozilla::ChangesToFlush) /builds/worker/checkouts/gecko/layout/base/PresShell.cpp:4277:11
    #29 0x7f63a20549e7 in FlushPendingNotifications /builds/worker/workspace/obj-build/dist/include/mozilla/PresShell.h:1409:5
    #30 0x7f63a20549e7 in nsRefreshDriver::Tick(mozilla::layers::BaseTransactionId<mozilla::VsyncIdType>, mozilla::TimeStamp) /builds/worker/checkouts/gecko/layout/base/nsRefreshDriver.cpp:2221:20
    #31 0x7f63a2060c75 in TickDriver /builds/worker/checkouts/gecko/layout/base/nsRefreshDriver.cpp:347:13
    #32 0x7f63a2060c75 in mozilla::RefreshDriverTimer::TickRefreshDrivers(mozilla::layers::BaseTransactionId<mozilla::VsyncIdType>, mozilla::TimeStamp, nsTArray<RefPtr<nsRefreshDriver> >&) /builds/worker/checkouts/gecko/layout/base/nsRefreshDriver.cpp:325:7
    #33 0x7f63a20609dd in mozilla::RefreshDriverTimer::Tick(mozilla::layers::BaseTransactionId<mozilla::VsyncIdType>, mozilla::TimeStamp) /builds/worker/checkouts/gecko/layout/base/nsRefreshDriver.cpp:341:5

SUMMARY: AddressSanitizer: heap-use-after-free /builds/worker/workspace/obj-build/dist/include/mozilla/RefPtr.h:286:27 in get
Shadow bytes around the buggy address:
  0x0c28800a3400: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd
  0x0c28800a3410: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c28800a3420: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c28800a3430: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fa
  0x0c28800a3440: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd
=>0x0c28800a3450: fd[fd]fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c28800a3460: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c28800a3470: fd fd fd fd fd fd fd fd fd fd fa fa fa fa fa fa
  0x0c28800a3480: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd
  0x0c28800a3490: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c28800a34a0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
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
==1163767==ABORTING

The original report as published on Mozilla's Bugzilla, by Irvan Kurniawan. 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.

How it worked

Root cause

Likely the font cache entry is freed during font group teardown while a hash lookup still holds a reference to the freed font, so KeyEquals reads the released object.

Impact

The content process aborts with a heap-use-after-free, which could potentially be exploited for code execution, though the report only demonstrates a crash.

What the attacker needed

Victim opens a crafted HTML page; victim closes the tab; AddressSanitizer build to observe the crash

How it was found

  1. Open the AddressSanitizer build of Firefox from a terminal so the sanitizer output is visible.
  2. Load the provided testcase page.
  3. Close the tab.
  4. Observe the AddressSanitizer heap-use-after-free report in the console.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

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

When a web page uses fonts, the browser keeps a cache of font objects so it does not have to reload them. A use-after-free means the program frees some memory and then later reads it again, which can crash the browser or, in worse cases, let an attacker run their own code. Here, simply opening a specially crafted page and then closing the tab makes Firefox read font data that has already been freed.

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 Irvan Kurniawan

View all

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