Skip to content
Memory corruption Disclosed report Advanced CVE-2025-1010

heap-use-after-free at remove in mozilla::dom::AbstractRange::UnregisterClosestCommonInclusiveAncestor

Atte Kettunen Follow

Originally disclosed on Mozilla

  • Fixed in 27 days
  • Paid in 34 days
  • Disclosed after 27 days
Text
Created attachment 9443363
fuzzingfunction-heap-use-after-free-remove-AbstractRangeUnregisterClosestCommonInclusiveAncestor-AbstractRangeUnregisterSelection-StyledRangesUnregisterSelection.html

Tested on:
 OS: Ubuntu 22.04
 Firefox:

    fuzzfetch fetched asan build: 
> Identified task: https://firefox-ci-tc.services.mozilla.com/api/index/v1/task/gecko.v2.mozilla-central.latest.firefox.linux64-asan-opt
> Task ID: ddn0wwpGSZyr_vbMtiUYhA
> Rank: 1734038673
> Changeset: a551f98b192c80a6b84cf2e9d9f441251d522f67
> Build ID: 20241212212433

    fuzzfetch fetched asan-fuzzing build:

> Identified task: https://firefox-ci-tc.services.mozilla.com/api/index/v1/task/gecko.v2.mozilla-central.latest.firefox.linux64-fuzzing-asan-opt
> Task ID: DM5PaO_YTkKG7lOT9fkAjg
> Rank: 1734038673
> Changeset: a551f98b192c80a6b84cf2e9d9f441251d522f67
> Build ID: 20241212212433


Reproducing test case uses FuzzingFunctions garbage collection features for reliable reproduction. Test case also has `setTimeout(()=>{location.reload()},1000) `, so that is will eventually crash on regular asan build, but on my machine it can take up to 20 retries.

The original reproducing test case was simpler, but very unreliable, I'll add it as an attachment also, for reference on which parts are actually needed to reproduce.

ASAN-output snippet:
> ==43416==ERROR: AddressSanitizer: heap-use-after-free on address 0x5030008c5e10 at pc 0x706f93827533 bp 0x7ffcaa565260 sp 0x7ffcaa565258
> WRITE of size 8 at 0x5030008c5e10 thread T0 (file:// Content)
>     #0 0x706f93827532 in remove /builds/worker/workspace/obj-build/dist/include/mozilla/LinkedList.h:244:18
>     #1 0x706f93827532 in mozilla::dom::AbstractRange::UnregisterClosestCommonInclusiveAncestor(nsINode*, bool) /builds/worker/checkouts/gecko/dom/base/AbstractRange.cpp:483:3
>     #2 0x706f9382b5dc in mozilla::dom::AbstractRange::UnregisterSelection(mozilla::dom::Selection const&) /builds/worker/checkouts/gecko/dom/base/AbstractRange.cpp:424:5
>     #3 0x706f93c632b7 in mozilla::dom::Selection::StyledRanges::UnregisterSelection() /builds/worker/checkouts/gecko/dom/base/Selection.cpp:2208:24
>     #4 0x706f93c6cd9e in mozilla::dom::Selection::Clear(nsPresContext*) /builds/worker/checkouts/gecko/dom/base/Selection.cpp:1447:17
>     #5 0x706f93c63fb8 in mozilla::dom::Selection::RemoveAllRangesInternal(mozilla::ErrorResult&) /builds/worker/checkouts/gecko/dom/base/Selection.cpp:2420:3
> ...
> 0x5030008c5e10 is located 0 bytes inside of 24-byte region [0x5030008c5e10,0x5030008c5e28)
> freed by thread T0 (file:// Content) here:
>     #0 0x56e6ab8a44b6 in free /builds/worker/fetches/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:52:3
>     #1 0x706f93e36ce9 in operator delete /builds/worker/workspace/obj-build/dist/include/mozilla/cxxalloc.h:51:10
>     #2 0x706f93e36ce9 in operator() /builds/worker/workspace/obj-build/dist/include/mozilla/UniquePtr.h:460:5
>     #3 0x706f93e36ce9 in reset /builds/worker/workspace/obj-build/dist/include/mozilla/UniquePtr.h:302:7
>     #4 0x706f93e36ce9 in ~UniquePtr /builds/worker/workspace/obj-build/dist/include/mozilla/UniquePtr.h:250:18
> ...
> previously allocated by thread T0 (file:// Content) here:
>     #0 0x56e6ab8a474f in malloc /builds/worker/fetches/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:68:3
>     #1 0x56e6ab8ebc95 in moz_xmalloc /builds/worker/checkouts/gecko/memory/mozalloc/mozalloc.cpp:52:15
>     #2 0x706f9382b079 in operator new /builds/worker/workspace/obj-build/dist/include/mozilla/cxxalloc.h:33:10
>     #3 0x706f9382b079 in MakeUnique<mozilla::LinkedList<mozilla::dom::AbstractRange> > /builds/worker/workspace/obj-build/dist/include/mozilla/UniquePtr.h:606:23
>     #4 0x706f9382b079 in mozilla::dom::AbstractRange::RegisterClosestCommonInclusiveAncestor(nsINode*) /builds/worker/checkouts/gecko/dom/base/AbstractRange.cpp:450:14
> ...
> SUMMARY: AddressSanitizer: heap-use-after-free /builds/worker/workspace/obj-build/dist/include/mozilla/LinkedList.h:244:18 in remove
> 


On Debug build we hit:

> [30037] Hit MOZ_CRASH(mozilla::LinkedList<mozilla::dom::AbstractRange>::~LinkedList() [T = mozilla::dom::AbstractRange] has a buggy user: it should have removed all this list's elements before the list's destruction) at /builds/worker/workspace/obj-build/dist/include/mozilla/LinkedList.h:469

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 high-severity memory corruption bug in DOM: Selection. Mozilla made it public on 9 January 2025 as CVE-2025-1010.

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.