Memory safety bug due to bad test in nsZipArchive.cpp
- Fixed in 15 days
- Paid in 26 days
- Disclosed after 15 days
User Agent: Mozilla/5.0 (Windows; rv:26.0) Gecko/20100101 Firefox/26.0
Build ID: 20150305021524
Steps to reproduce:
(Firefox 38.0.1)
nsZipArchive::GetDataOffset does not validate the archive's local header correctly. It uses the code:
790: uint32_t len = mFd->mLen;
791: const uint8_t* data = mFd->mFileData;
792: uint32_t offset = aItem->LocalOffset();
793: if (offset + ZIPLOCAL_SIZE > len)
794: return 0;
795:
796: // -- check signature before using the structure, in case the zip file is corrupt
797: ZipLocal* Local = (ZipLocal*)(data + offset);
798: if ((xtolong(Local->signature) != LOCALSIG))
799: return 0;
The problem is with the line 793. If offset (which comes directly from the archive field central->localhdr_offset) is >= 0xffffffe2, the quantity offset + ZIPLOCAL_SIZE will overflow a uint32_t, resulting in a value <= len. Line 797 will then compute data+offset, which will point somewhere arbitrary in memory. In almost every case, line 798 will then either cause a read-access violation or a failed comparison to LOCALSIG, which presumably means that nothing will use the corrupt item. It is, however, faintly possible that data+offset points to valid memory that contains LOCALSIG, which would lead to unpredictable behavior somewhere down the road. Hence, I have marked this as a security bug.
This bug seems likely to be the cause of https://bugzilla.mozilla.org/show_bug.cgi?id=1164141 . It might also be involved in https://bugzilla.mozilla.org/show_bug.cgi?id=596826 .
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 Networking: JAR. Mozilla made it public on 5 June 2015 as CVE-2015-2735.
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.