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

Potential access beyond bounds caused by InChunkPointer::ShouldPointAtValidBlock()

A bounds-checking function in Firefox's profiler code checks the wrong object for null, so if an attacker can control the entry size, it may allow an out-of-bounds memory access.

mozillabugs Follow

Originally disclosed on Mozilla

  • Fixed in 7 days
  • Paid in 25 days
  • Disclosed after 7 days
Text
`InChunkPointer::ShouldPointAtValidBlock()` (`mozglue/baseprofiler/public/ProfileChunkedBufferDetail.h`) contains an invalid check, potentially allowing an access beyond bounds. The bug is at lines 389-90 (FIREFOX_120_0_1_RELEASE), which check `IsNull()` against `*this`, not against `pointer`.

If untrusted code can determine `entrySize` (line 381), then it might be able to cause an access beyond bounds in code that relies on `ShouldPointAtValidBlock()` to perform the correct check.

'''
372:[[nodiscard]] bool ShouldPointAtValidBlock() const {
373:    if (IsNull()) {
374:      // Pointer is null, no blocks here.
375:      MOZ_ASSERT(false, "ShouldPointAtValidBlock - null pointer");
376:      return false;
377:    }
378:    // Use a copy, so we don't modify `*this`.
379:    InChunkPointer pointer = *this;
380:    // Try to read the entry size.
381:    Length entrySize = pointer.ReadEntrySize();
382:    if (entrySize == 0) {
383:      // Entry size of zero means we read 0 or a way-too-big value.
384:      MOZ_ASSERT(false, "ShouldPointAtValidBlock - invalid size");
385:      return false;
386:    }
387:    // See if the last byte of the entry is still inside the buffer.
388:    pointer += entrySize - 1;
389:    MOZ_ASSERT(!IsNull(), "ShouldPointAtValidBlock - past end of buffer");
390:    return !IsNull();
391: }
'''

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

Impact

If untrusted code can determine `entrySize`, it might be able to cause an access beyond bounds in code that relies on this check.

What the attacker needed

Attacker can control entrySize; code relies on ShouldPointAtValidBlock()

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.

This is a bug in a safety check inside Firefox's profiler. The check is supposed to confirm that a pointer still points inside a buffer, but it accidentally checks the original object instead of the moved pointer. If an attacker can influence a size value, the check may pass when it should fail, potentially letting code read or write outside the intended memory.

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.