Skip to content
Memory corruption Disclosed report Advanced CVE-2020-15678

Iterator invalidation potentially causing memory corruption

A function in the Firefox compositor code kept an iterator into an unordered map across a recursive call that could insert into the same map and trigger a rehash, leaving the iterator dangling. The reporter was unsure whether an attacker could reach the path with enough control over inputs, so the security impact was unclear.

lukas.bernhard Follow

Originally disclosed on Mozilla

  • Fixed in 46 hours
  • Paid in 33 days
  • Disclosed after 46 hours
Text
User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0

Steps to reproduce:

The function `ComputeClippedCompositionBounds` in APZCTreeManager.cpp is not following iterator invalidation rules, potentially causing memory corruption.
The return value of the `aDestMap.insert` holds an iterator to the inserted key.
https://searchfox.org/mozilla-central/rev/6cc48251bb97600fdf11a5b4c5f621bfc8606d55/gfx/layers/apz/src/APZCTreeManager.cpp#902

Recursively calling `ComputeClippedCompositionBounds` potentially invalidates the iterator, depending on whether the insert caused a rehash of the std::unordered_map.
https://searchfox.org/mozilla-central/rev/6cc48251bb97600fdf11a5b4c5f621bfc8606d55/gfx/layers/apz/src/APZCTreeManager.cpp#929

The (potentially invalid) iterator is used to insert another value.
https://searchfox.org/mozilla-central/rev/6cc48251bb97600fdf11a5b4c5f621bfc8606d55/gfx/layers/apz/src/APZCTreeManager.cpp#953

I'm not sure whether an adversary is able to reach the code path while exercising sufficient control over the input variables. Hence the severity from a security standpoint remains unclear to me, feel free to de-restrict the bug report.

The original report as published on Mozilla's Bugzilla, by lukas.bernhard. 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 an iterator returned by an insert into a std::unordered_map was held across a recursive call that could insert again and rehash the map, invalidating it.

Impact

Could cause memory corruption, though the reporter could not confirm an attacker can reach the code path with sufficient control over inputs.

What the attacker needed

Attacker reaches the compositor code path; control over input variables (unconfirmed)

How it was found

  1. Call ComputeClippedCompositionBounds, which inserts into a destination map and keeps the returned iterator.
  2. The function recurses, and the recursive insert may rehash the map.
  3. The now possibly invalid iterator is used to insert another value.

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 items in a container and uses a pointer-like handle to one item. If the container grows and rearranges its contents, that handle can point at nothing useful. Using it afterwards can corrupt memory, which may crash the browser or, in the worst case, let an attacker run code.

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 lukas.bernhard

View all

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