Overflow in nsAttrAndChildArray::GrowBy causes memory-safety bug
- Fixed in 35 days
- Paid in 45 days
- Disclosed after 35 days
User Agent: Mozilla/5.0 (Windows NT 5.1; rv:36.0) Gecko/20100101 Firefox/36.0
Build ID: 20150305021524
Steps to reproduce:
nsAttrAndChildArray::GrowBy (38.0.1\dom\base\nsAttrAndChildArray.cpp) can overflow if mBufferSize becomes very large, causing a realloc to a tiny buffer size. Other code in the class subsequently writes to unallocated space, potentially permitting the execution of attacker-chosen code, as by modifying an object's virtual-function table:
763: bool
764: nsAttrAndChildArray::GrowBy(uint32_t aGrowSize)
765: {
766: uint32_t size = mImpl ? mImpl->mBufferSize + NS_IMPL_EXTRA_SIZE : 0;
767: uint32_t minSize = size + aGrowSize;
768:
769: if (minSize <= ATTRCHILD_ARRAY_LINEAR_THRESHOLD) {
770: do {
771: size += ATTRCHILD_ARRAY_GROWSIZE;
772: } while (size < minSize);
773: }
774: else {
775: size = 1u << mozilla::CeilingLog2(minSize);
776: }
777:
778: bool needToInitialize = !mImpl;
779: Impl* newImpl = static_cast<Impl*>(moz_realloc(mImpl, size * sizeof(void*)));
780: ...
If size (from mImpl->mBufferSize) is very close to 0xffffffff, line 767 can overflow. If the condition on line 769 is satisfied, size also can overflow. If the condition on line 767 is not satisfied, line 775 computes a tiny size from minSize. In either case, line 779 allocates a buffer far too small to contain all the existing data, and other code in the class writes to the unallocated area.
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 medium-severity memory corruption bug in DOM: Core & HTML. Mozilla made it public on 10 July 2015 as CVE-2015-7174.
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.