Skip to content
Memory corruption Disclosed report Advanced CVE-2023-5170

heap memory leak in memory shared with compromised content process due to wrong GetPreparedMap

A graphics caching routine in Firefox's canvas translation code checks that the mapped surface matches the requested surface, but the requested surface can be swapped between the set and get calls while the mapped surface stays the same. This lets a compromised content process receive heap memory it should not have, which the reporter argues could be used for a sandbox escape.

LEE YESEOP Follow

Originally disclosed on Mozilla

  • Fixed in 33 days
  • Paid in 34 days
  • Disclosed after 33 days
Text
Created attachment 9346865
ASAN.txt

While graphics rendering, |SetPreparedMap()|[1], |GetPreparedMap()|[2] are used to cache |dataSurface|[3]. In |SetPreparedMap()|, it assign the |dataSurface| to |mPreparedMap| and set corresponding |mMappedSurface|. In |GetPreparedMap()|, it checks |aSurface| has changed by "MOZ_RELEASE_ASSERT(mMappedSurface == aSurface". However, |aSurface| can be replaced between |SetPreparedMap()| and |GetPreparedMap()| with the same |mMappedSurface|. The non-corresponding |aSurface| is used with |GetPreparedMap()|[4]. It leads to heap memory leak and the memory is sent to the compromised content process with shared memory[5].

It is verified that heap memory leak leads to sandbox escape many times, especially with ipc port leaked. There is also |Port| in firefox[6] and I think firefox is not safe from this.

[1]: https://searchfox.org/mozilla-central/source/gfx/layers/ipc/CanvasTranslator.cpp#540
[2]: https://searchfox.org/mozilla-central/source/gfx/layers/ipc/CanvasTranslator.cpp#547
[3]: https://searchfox.org/mozilla-central/source/gfx/layers/RecordedCanvasEventImpl.h#309
[4]: https://searchfox.org/mozilla-central/source/gfx/layers/RecordedCanvasEventImpl.h#359
[5]: https://searchfox.org/mozilla-central/source/gfx/layers/RecordedCanvasEventImpl.h#364
[6]: https://searchfox.org/mozilla-central/source/ipc/chromium/src/mojo/core/ports/port.h#102 




REPRODUCE
Operating System: All
1.apply *patch.diff
2.visit index.html

*: Patch to emulate a compromised content process.


Crash State: see asan file

The original report as published on Mozilla's Bugzilla, by LEE YESEOP. 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 assertion in GetPreparedMap only compares the stored mapped surface against the requested surface, so a caller can pass a different surface that happens to share the same mapped surface and receive the cached data surface.

Impact

A compromised content process could obtain heap memory from the parent through shared memory, which the reporter suggests may be chained into a sandbox escape.

What the attacker needed

Compromised content process; patch applied to emulate attacker

How it was found

  1. Apply the supplied patch that emulates a compromised content process.
  2. Open the provided index page in the browser.
  3. Observe the heap memory leak reported by the address sanitiser.

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.

Firefox splits its work into a privileged parent process and less trusted content processes that render web pages. A small caching helper was supposed to confirm it was handing back the same drawing surface it stored earlier, but the check compared the wrong values, so a different surface could slip through. The result is that memory from the privileged side can end up shared with a process that is assumed to be already compromised.

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 LEE YESEOP

View all

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