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.
-
A race condition influences memory that has already been freed.
-
Reference counting or lifetime handling of surface objects passed to user-mode display drivers was wrong, leading to use of a freed or wrongly owned object.
-
Reference counts are not increased when storing objects, or are released too early during deserialisation.
-
Resource objects are used without checking they still exist.
-
Return values from reads or recursive calls are not checked, so errors are treated as success.
-
Size and offset fields from files are trusted without validation before memory access.
-
Size arithmetic wraps around and pointer arithmetic is not bounded to its buffer.
-
Size or length fields in the file are trusted without being checked against the actual buffer size.
-
A stack-based buffer overflow occurs when copying data without a bounds check.
-
Stale stack pointers are used after the stack is extended, and stack clearing writes one element too many.
Seen in 2 reports
-
The allocation size came straight from the header while the copy length came from the file body, with no bounds check between them.
-
The application does not validate the size or content of user-supplied data when handling app objects.
-
The buffer is sized from the smaller of tile and image dimensions but multiple samples are read into it.
-
The buffer offset and remaining size passed to gethostbyname_r ignore alignment padding for struct hostent, so the data area is smaller than assumed and can be overflowed.
-
The bundled shader compiler's loop analysis mishandles the loop structure produced from translated shaders.
Seen in 2 reports
-
The bytecode generator assumes the body dominates the next expression, so a continue before initialisation lets a hole check be skipped.
Seen in 2 reports
-
The chunk length was parsed with a string-to-long conversion but never checked for a negative result before being passed to the read function.
Seen in 2 reports
-
The code assumed only one callback object existed per picker, so the completion call destroyed the shared parent while other callbacks still referenced it.
Seen in 2 reports
-
The compat syscall cast a user timeout pointer to a kernel pointer and passed it on without copying the timespec from user space.
-
The compiler emitted incorrect machine code for inline assembly blocks.
-
The component count in the SOF3 block was not checked against the sample count declared in the DNG SubIFD, leading to an out-of-bounds write.
-
The copy limit passed to strncpy is taken from the input string itself rather than the destination buffer size.
Seen in 2 reports
-
The CreateSurfacePal function did not validate the size or bounds of user-supplied data before writing to an array.
-
The crossdomain policy used a wildcard origin or set secure to false, letting Flash clients read protected data.
-
The Data Node job processing code does not validate the size or index of user-supplied data before writing to an array, causing an out-of-bounds write.
-
The date parser read past the end of a string that was not properly terminated or bounds-checked.
Seen in 2 reports
-
The decompression code trusts the client-supplied uncompressed size and returns the whole allocated buffer instead of only the decompressed bytes.
-
The delete function trusts a user-supplied index to look up a resource, and later functions use a fallback pointer without checking it is valid.
-
The DICOM parser calculated a buffer size from untrusted file values without checking for overflow, so the size wrapped to a small number.
-
The dispatch code stores a raw pointer to the grabber window and then makes a blocking call that can synchronously destroy it, leaving the pointer dangling.
Seen in 2 reports
-
The driver does not validate the length or content of user-supplied data in 802.11 frames before copying it into a fixed-size buffer.
-
The driver frees a query or texture while queued commands or a rasteriser thread still hold a reference to it.
-
The driver reads a licence entry without checking that its declared size covers the offset being read.
-
The driver used an object without first checking that it still existed.
-
The duplicate check was performed on one object while properties were added to other objects without checking for duplicates.
-
The engine dereferences objects without verifying their type, or optimises JavaScript in a way that confuses types.
-
The engine does not validate the size of data it processes, leading to a buffer overflow.
-
The graphics driver uses an attacker-controlled shader index or repeat count directly as a write address or loop bound.
-
The handler trusted an attacker-controlled length when copying user data instead of checking it against the real buffer.
-
The hash API was used incorrectly for key deletion, and a zval type was checked after its memory was freed.
Seen in 2 reports
-
The IOCTL handler does not validate the size or bounds of user input before writing to a kernel buffer.
-
The iovector length field is not initialised when processing a MAYBE call, so it is later used as a loop bound.
-
The IPP service copies user-supplied data into a fixed-length stack buffer without validating its length.
-
The JIT compiler incorrectly assumed the type of an object in the HasIndexedProperty node, leading to memory corruption.
-
The JIT creates many executable regions per module, lacks constant blinding and uses predictable instruction layouts.
Seen in 2 reports
-
The kernel decrypts network data in place without checking that the target memory belongs to the network buffer rather than a shared page cache page.
-
The kernel unit length setter stored negative values without validation, relying only on a debug assertion removed in release builds.
-
The measurement and write passes disagree on the captured value size because query-string handling escapes characters like plus signs, causing a heap overflow.
-
The mfenced frame freed its fence and separator character objects during automatic-data rebuild or on an attribute change while a display item still held a pointer to one.
-
The parser computes a block size from consecutive offsets but does not verify that the packed point count plus per-tuple data fits inside it.