In-depth lesson · Memory corruption
Root causes
Every point the Memory corruption reports back under this heading, best-backed first, each with the reports it is seen in.
-
An integer overflow in a symbol count calculation led to an undersized heap allocation that was then overflowed.
-
An integer overflow in the calculation of the last column index from the MULRK record's column field and size leads to an undersized allocation.
-
An object is used after being freed because its existence is not validated.
-
An object of one type is used where another is expected, so a virtual call reads past the end of the wrong vtable.
Seen in 2 reports
-
An object was freed twice because its existence was not checked.
-
An Objective-C block captured a raw this pointer and was posted asynchronously, so the object could be destroyed before the block ran.
Seen in 2 reports
-
An off-by-one or incorrect bounds check in tile processing writes past the allocated array.
Seen in 2 reports
-
An optimisation replaces a class guard with a shape guard or skips a receiver type check, leaving a stale assumption.
Seen in 2 reports
-
An oversized allocation failed and returned null, and the kernel used the result without checking, writing through a null pointer.
-
An unchecked 64-bit to 32-bit truncation produces a value that collides with a reserved sentinel.
Seen in 2 reports
-
An unchecked size value from the request was used in a buffer-size calculation that could overflow.
-
An unsanitised hash or enum equal to a reserved sentinel key causes the garbage collector to skip tracing the entry.
Seen in 2 reports
-
Animation timing updates and keyframe property reads use objects that have already been freed.
-
Argument conversion could run script that closed the document and freed objects, but the method continued to use a stale reference.
-
Array indices from RPCs and string escaping are not bounds checked.
-
Assignment operators do not handle self-assignment, leaving internal state invalid.
-
atoi silently wraps a large digit string to a negative number and only the upper bound of the index is checked before writing to the array.
-
Bare pointers to objects with shorter lifetimes are cached and used after the owning object is freed.
Seen in 2 reports
-
Bounds and overflow checks were missing when parsing attacker-controlled length and count fields from certificates and handshake messages.
-
Buffer size calculated from untrusted guest input without an overflow check, so the allocation is smaller than the data later written.
-
Buffer size calculations that subtract too much or use the wrong unit, so the copy overflows.
-
Buffer sizes were computed in 32-bit arithmetic that wrapped to zero before being stored in a 64-bit variable.
Seen in 2 reports
-
Checksum metadata from a less-trusted guest is trusted and a deferred checksum completion rewrites an already-validated header.
-
Cleanup code frees objects it does not own or frees them twice when code generation fails.
Seen in 2 reports
-
Cleanup or restore logic only runs on the success path, leaving internal state pointing at application data after a failure.
-
Client libraries copied reply data from the server into fixed-size heap buffers without validating the length field.
-
Command iterators fail to consume a data marker in an edge case, desynchronising parsing of subsequent bytes.
Seen in 2 reports
-
Component indices from file segments were used to index arrays without checking them against the declared component count.
Seen in 2 reports
-
Data type not validated before use, causing type confusion.
-
Decoder-side metadata is updated before a native operation that can fail, and is not rolled back on failure, leaving validation out of sync with the driver.
Seen in 2 reports
-
Decryption subsample sizes were accepted without verifying they matched the buffer data size.
-
Delayed callbacks bound to raw object pointers are not cancelled when the object is destroyed.
Seen in 2 reports
-
Device cleanup did not clear callbacks or per-buffer state, leaving dangling pointers to freed structures.
Seen in 2 reports
-
Doc objects were used without validating that they still existed.
-
Document close and page close actions run out of sync, so memory freed by closeDoc is reused in the page close handler.
Seen in 2 reports
-
Double free of the same memory during file parsing.
-
Driver code used objects or array indices without checking existence or bounds.
-
Encoder preprocessing used the U plane stride for both chroma planes, ignoring the V plane stride.
Seen in 2 reports
-
Error handling uses longjmp that skips cleanup, leaving half-finished request data that later code treats as valid.
-
Error paths free resources without returning an error or resetting pointers, causing double-free.
-
Exception and range constructors looked up class objects at runtime instead of using fixed references, so redefining a constant caused a type confusion.
Seen in 2 reports
-
Externally controlled data reaches a format string function without validation.
-
Field lengths taken from the packet are trusted without checking them against the minimum or maximum size of the destination.
-
Firmware or device responses are deserialised without validating them against the expected structure.
-
Fixed header sizes are subtracted from file-controlled lengths without checking the length is at least that big, causing underflow.
-
Font parsing code does not validate the size or structure of embedded font data before reading it.
-
Font table sizes are not validated against the sum of the variation data sizes before processing.
-
Formatted output calls and Content-Length handling in the MXIT protocol overflow buffers.
-
Fragment length is trusted while total length is used for bookkeeping, and the next packet is written into a fixed scratch buffer without checking it fits.
-
Graphics memory read without a bounds check.