Memory safety problem in ArrayBufferBuilder::append
- Fixed in 7 days
- Paid in 21 days
- Disclosed after 7 days
User Agent: Mozilla/5.0 (Windows; rv:) Gecko/20100101 Firefox/. Build ID: 20150305021524
Steps to reproduce:
ArrayBufferBuilder::append (in dom\base\nsXMLHttpRequest.cpp) can overwrite memory it does not own if aDataLen is very large. For example, assume that mLength=2, aDataLen=0xffffffff, and mCapacity=2. In this case, the LHS on line 4019 overflows, giving the value 1. Control then skips to line 4047 (assume a release build), which copies aDataLen bytes from aNewData all over Firefox's address space. Presumably this eventually will cause an access-violation crash on 32-bit platforms, but perhaps not before some other thread uses the written data to do something undesirable. On 64-bit platforms, execution might continue for a long time, depending upon how address space is laid out.
I don't know, however, whether ArrayBufferBuilder::append is exposed to external content in such a way that this defect can be exploited. I suppose that a server could send back a defective XMLHttpRequest containing a very large length, though perhaps other code checks for this problem.
4013: bool 4014: ArrayBufferBuilder::append(const uint8_t *aNewData, uint32_t aDataLen, 4015: uint32_t aMaxGrowth) 4016: { 4017: MOZ_ASSERT(!mMapPtr); 4018: 4019: if (mLength + aDataLen > mCapacity) { 4020: uint32_t newcap; 4021: // Double while under aMaxGrowth or if not specified. 4022: if (!aMaxGrowth || mCapacity < aMaxGrowth) { 4023: newcap = mCapacity * 2; 4024: } else { 4025: newcap = mCapacity + aMaxGrowth; 4026: } 4027: 4028: // But make sure there's always enough to satisfy our request. 4029: if (newcap < mLength + aDataLen) { 4030: newcap = mLength + aDataLen; 4031: } 4032: 4033: // Did we overflow? 4034: if (newcap < mCapacity) { 4035: return false; 4036: } 4037: 4038: if (!setCapacity(newcap)) { 4039: return false; 4040: } 4041: } 4042: 4043: // Assert that the region isn't overlapping so we can memcpy. 4044: MOZ_ASSERT(!areOverlappingRegions(aNewData, aDataLen, mDataPtr + mLength, 4045: aDataLen)); 4046: 4047: memcpy(mDataPtr + mLength, aNewData, aDataLen); 4048: mLength += aDataLen; 4049: 4050: return true; 4051: }
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 DOM: Core & HTML. Mozilla made it public on 1 June 2015 as CVE-2015-2739.
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.