Crash [@ stagefright::SampleTable::parseSampleCencInfo] with heap buffer overflow in libstagefright.
Originally disclosed on Mozilla
- Fixed in 8 days
- Paid in 13 days
- Disclosed after 8 days
There is a bug in libstagefright which causes Firefox to crash (invalid read).
I attached a test case to this report. As this seems to be exploitable, I marked this report as security related.
I downloaded Firefox 48.0a1 from: https://ftp.mozilla.org/pub/firefox/tinderbox-builds/mozilla-central-linux64-asan/1457435058/firefox-48.0a1.en-US.linux-x86_64-asan.tar.bz2
The corresponding HG revision is: 05c087337043dd8e71cc27bdb5b9d55fd00aaa26
While inspecting SampleTable.cpp and investigating the issue, I stumbled upon this code fragment (SampleTable:639-640):
if (!mCencSizes.IsEmpty() && mCencOffsets.Length() > 1 &&
mCencSizes.IsEmpty() != mCencOffsets.Length()) {
return ERROR_MALFORMED;
}
which is semantically equivalent to:
if (!mCencSizes.IsEmpty() && mCencOffsets.Length() > 1) {
return ERROR_MALFORMED;
}
I'm not sure what the condition is supposed to be, but it's probably supposed to be an '||' and something around comparing lengths.
The actual place where the crash appears is here (SampleTable:655-657):
for (uint32_t i = 0; i < mCencInfoCount; i++) {
uint8_t size = mCencDefaultSize ? mCencDefaultSize : mCencSizes[i]; /// <--
uint64_t offset = mCencOffsets.Length() == 1 ? nextOffset : mCencOffsets[i];
The reason is the access to mCencSizes[i] with i=0 while mCencOffsets is empty.
At this time, mCencOffsets.Length is 2 and mCencSizes.Length is 0. This goes probably back to the initial (wrong or incomplete?) malform check.
During the execution I got the ASAN trace attached to this report, as well as a crash with SIGILL.
When executing a debug build, I also get:
Assertion failure: aIndex < Length() (invalid array index)
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is known
A high-severity memory corruption bug in Audio/Video: Playback. Mozilla made it public on 16 March 2016 as CVE-2016-2814.
About 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.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
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.