New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.
Starred by 3 users
Status: Fixed
Owner:
Email to this user bounced
Closed: Feb 2015
Cc:



Sign in to add a comment
Flash heap buffer overflow due to integer overflow in JSON.stringify
Project Member Reported by ianbeer@google.com, Dec 14 2014 Back to list
The JSONSerializer class in JSONClass.cpp in avmplus (https://github.com/adobe-flash/avmplus) uses the JSONSerializer::Rope inner class to manage the memory associated with the JSON-serialized output string. JSONSerializer::Rope has a linked list of JSONSerializer::Rope::Chunks, each of which store around 4k of serialized output.

Once the entire input object has been serialized a final output buffer is allocated and the Chunks and all copied into the single output buffer.

The Rope class uses the m_len member to accumulate the total size of all the bytes in the linked-list of Chunks:

...
             int32_t            m_len;
...
             REALLY_INLINE void emit(utf8_t const* buf, int32_t len) {
                 while (len > 0) {
                     int32_t wrote = m_ropeEnd->emit(buf, len);
                     len -= wrote;
                     AvmAssert(len >= 0);
                     buf += wrote;
                     m_len += wrote;                         <--- (a) update the total length of the rope
                     if (m_ropeEnd->exhausted()) {
                         Chunk* newchunk = newChunk(m_ropeEnd);
                         m_ropeEnd = newchunk;
                     }
                 }
             }

This length is then used when the concat() function is called to allocate a buffer for the output string:

             char* concat() {
                 AvmAssert(checkLength() == m_len);
                 char* dst = (char*)m_fixedmalloc->Alloc(m_len);   <--- (b) use m_len
                 char* end = dst;
                 Chunk* r = m_ropeStart;
                 while (r != NULL) {                                                   <--- (c) walk the chunks LL
                     memcpy(end, r->m_payload, r->m_cursor);
                     end += r->m_cursor;
                     r = r->m_next;
                 }
                 return dst;
             }

There is no integer overflow check at (a) so by serializing a large object we can overflow m_len leading to an undersized allocation at (b) and a heap overflow at (c) when the linked list is traversed and the chunks are copied.

Attached PoC has been tested against the latest version of Flash Projector for OS X (16.0.0.235)
 
StringifyOverflow.swf
749 bytes Download
StringifyOverflow.as
2.8 KB Download
Project Member Comment 1 by ianbeer@google.com, Dec 14 2014
Labels: Reported-2014-Dec-15
Project Member Comment 2 by ianbeer@google.com, Dec 15 2014
Labels: Id-3187
Comment 3 by cevans@google.com, Feb 4 2015
Labels: CVE-2015-0324
Comment 4 by cevans@google.com, Feb 6 2015
Labels: Fixed-2015-Feb-5
Status: Fixed
https://helpx.adobe.com/security/products/flash-player/apsb15-04.html
Comment 5 by cevans@google.com, Feb 12 2015
Labels: -Restrict-View-Commit
Sign in to add a comment