Skip to content
Memory corruption Disclosed report Advanced CVE-2024-6606

Missing an array index check in GetClipboardCacheIfValid (trusting data from content process)

The clipboard cache lookup function accessed an array using an attacker-controlled clipboard type value without checking the index bounds. A compromised content process could supply an out-of-range value, causing out-of-bounds reads and returning a pointer to out-of-bounds memory that the caller then used.

LEE YESEOP Follow

Originally disclosed on Mozilla

  • Fixed in 5 days
  • Paid in 5 days
  • Disclosed after 5 days
Text
Created attachment 9407235
patch.diff

It is a simple yet critical out-of-bound read. In |GetClipboardCacheIfValid()|, |mCaches| array is accessed without an index check[1]. Given that the value of |aClipboardType| can be controlled, an attacker could use it to trigger the vulnerability.
Unlike ordinary OOB Read vulnerabilities that involves only a single read, the vulnerability leads to several reads from the out-of-bound memory and, more importantly, it returns the pointer to the out-of-bound memory. Then the caller continues to use the malicious pointer not knowing what has happened.

For a simple patch to address this vulnerability, I suggest using nsTArray instead of a legacy array.

[1]: https://searchfox.org/mozilla-central/source/widget/nsBaseClipboard.cpp#1117 


REPRODUCTION CASE
Type of vulnerbility: Browser Process
Operating System: Mac OS (Only Mac OS has the `widget.clipboard.use-cached-data.enabled` feature enabled by default. If want to test in other OS, the feature should be enabled in about:config)

To reproduce the crash please follow next steps:
1. Apply patch.diff
2. Open test.html  in browser
// patch.diff emulates a compromised content process 

When running this PoC on ASAN build, you can get an ASAN report like attached asan.txt

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 clipboard cache lookup indexed a fixed array with an unvalidated clipboard type value supplied by the content process, with no bounds check.

Impact

A compromised content process could trigger out-of-bounds reads and use a returned out-of-bounds pointer, leading to a crash and possible memory disclosure; the issue is only reachable by default on macOS, where the cached clipboard feature is enabled.

What the attacker needed

Compromised content process; macOS, or the cache feature enabled manually

The fix

The reporter suggested replacing the legacy array with nsTArray so that indexing is bounds-checked.

How it was found

  1. Apply the provided patch, which emulates a compromised content process
  2. Open the test page in the browser
  3. Observe the crash and the ASAN report on an ASAN build

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.

A program stores clipboard data in a list and picks an entry by its position number. The code trusted a number coming from another, less trusted part of the browser and never checked that the number was within the list, so it read memory outside the list. Because the bad pointer was handed back and used further, this could crash the browser and potentially leak memory contents.

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.