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

Potential use of uninitialized storage on self-assignment in MarkStack::operator=()

The assignment operators of a garbage-collector marking stack reinitialise the object in place with placement new, which the reporter argues leaves the object's storage in an indeterminate state on self-assignment. The text does not demonstrate a concrete exploit or memory-safety consequence, only a suspected undefined-behaviour pattern.

mozillabugs Follow

Originally disclosed on Mozilla

  • Fixed in 6 days
  • Paid in 11 days
  • Disclosed after 6 days
Text
`MarkStack::operator=()` (`js/src/gc/Marking.cpp`) uses uninitialized storage on self-assignment:

'''
    1718: MarkStack& MarkStack::operator=(const MarkStack& other) {
    1719:   new (this) MarkStack(other);
    1720:   return *this;
    1721: }
    ...
    1734: MarkStack& MarkStack::operator=(MarkStack&& other) noexcept {
    1735:   new (this) MarkStack(std::move(other));
    1736:   return *this;
    1737: }
'''
as the memory containing `this` is considered reused (and therefore of indeterminate content) upon return from the placement new function and before the new-initializer.

Searchfox says that these functions aren't called, but contradicts itself by saying that the move version has been hit over 5,000,000 times in coverage. I can't seem to find the code that calls it.

The original report as published on Mozilla's Bugzilla, by mozillabugs. 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 assignment operators destroy and reconstruct the object in place via placement new, which is unsafe when the source and destination are the same object.

What the attacker needed

Self-assignment of the object

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 C++ object can be rebuilt in the same memory using a special construct called placement new. The reporter thinks that when an object is assigned to itself this way, the memory is treated as if it holds unknown data, which is not allowed. No actual attack or crash is shown, so this is a code-quality concern rather than a proven vulnerability.

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 mozillabugs

View all

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