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.
-
Uninitialised variables and pointers used during parsing.
-
Untrusted pointer dereference appears where code follows a memory address it should not trust.
-
Untrusted pointer dereference without validating caller-supplied input.
-
Untrusted serialised data is deserialised and treated as trusted objects.
-
Use-after-free: an object is deallocated but the pointer is not nulled, so later checks are bypassed.
-
User data length was not validated before copying to a stack buffer, and objects were used without existence checks.
-
User-controlled names are copied into fixed-size stack buffers with sprintf or with the input length as the limit.
Seen in 2 reports
-
User-controlled text was passed as the format string to an error or logging function.
Seen in 2 reports
-
User-supplied data length is not validated before copying into a heap buffer.
-
User-supplied data length is not validated before copying to a stack buffer.
-
User-supplied length and count fields are trusted without validation before being used in buffer copies and allocations.
-
User-supplied lengths from HSC files are copied into fixed-size buffers without validation.
-
User-supplied strings are used as format specifiers without validation.
-
Virtual device and shared component code uses objects without checking existence or copies data without length checks.
-
Widgets do not stop timers during pre-finalisation, and a task runner override is missing.
Seen in 2 reports
-
A 16-bit format index read from the network is used to index a fixed-size array without bounds validation.
-
A 32-bit signed integer arithmetic is used for the chroma plane size calculation, which can overflow.
Seen in 1 report
-
A 32-bit unsigned integer stores a size that can exceed 4GB and rounding arithmetic overflows, giving an undersized allocation.
Seen in 1 report
-
A 3GP parser does not properly validate the size or structure of data before reading it.
-
A 16-bit capacity field was incremented without an overflow check, wrapped to zero, and caused a tiny allocation followed by a large move.
Seen in 1 report
-
A 16-bit filename size of the maximum value is incremented by one and wraps to zero, causing a huge copy that underflows the destination.
Seen in 1 report
-
A 16-bit index from the file is used to access a six-element array of object pointers without a bounds check.
-
A 16-bit offset variable could be integer-overflowed by a 32-bit packet length, bypassing bounds checks.
Seen in 1 report
-
A 16-bit register move does not clear the upper bits, leaving a stale bit that causes an out-of-bounds index.
Seen in 1 report
-
A 16-bit size field from the network was used directly as a byte count without checking it against the destination buffer size.
Seen in 1 report
-
A 16-bit unsigned integer overflow when adding a fixed allocation size to the group count leads to an undersized allocation followed by a copy using the original size.
Seen in 1 report
-
A 32-bit atomic counter for resource IDs can wrap, and the cache retains bind groups referencing destroyed resources while validation is disabled in release builds.
Seen in 1 report
-
A 32-bit atomic integer used for reference counting can overflow when incremented many times.
Seen in 1 report
-
A 32-bit checked integer is used for the copy length but its validity is never checked, so an overflow truncates the length and the bounds check compares the wrong value.
-
A 32-bit integer overflow in the allocation size calculation gives a too-small buffer and out-of-bounds writes.
Seen in 1 report
-
A 32-bit layer ID counter wraps and release builds skip duplicate-ID checks.
Seen in 1 report
-
A 32-bit length accumulator is incremented without overflow checks and the bulk appender assumes the buffer is large enough.
Seen in 1 report
-
A 32-bit length field is added to fixed offsets without overflow checking, so a huge length wraps to a small value that passes the bounds check.
Seen in 1 report
-
A 32-bit length was assigned to a 16-bit variable, so the allocated hash table was too small for later writes.
Seen in 1 report
-
A 32-bit padding value was added to a 16-bit array size field without an overflow check, so the allocation was smaller than the tracked size.
Seen in 1 report
-
A 32-bit serial counter could wrap around while cache invalidation was deliberately skipped for dynamic uniform buffer descriptors, causing key collisions.
Seen in 1 report
-
A 32-bit signed atomic reference counter is incremented without an overflow check and can wrap to zero while references remain.
Seen in 1 report
-
A 32-bit signed integer overflow in pointer arithmetic combined with a sentinel value bypass in a bounds check.
Seen in 1 report
-
A 32-bit size accumulator wrapped when summing many large strings, and the wrapped value was used for allocation while real lengths were used for copying.
Seen in 1 report
-
A 32-bit size field in the FlatBuffers builder wrapped when serialised data exceeded four gigabytes, and the wrapped size was used to compute rule pointers.
Seen in 1 report
-
A 32-bit unsigned counter accumulates the product of copies and repeating tiles across all stretching groups and wraps to a small value with enough groups.
Seen in 1 report
-
A 32-bit unsigned LRU counter can wrap around and the eviction logic does not exclude the newly created buffer, so it is selected for deletion and then accessed.
Seen in 1 report
-
A 32-bit unsigned multiplication of primitive count by three wraps to a small value, leading to an undersized buffer allocation.
Seen in 1 report
-
A 32-bit value read from the file is used as a loop counter without validation, causing excessive heap clearing.
Seen in 1 report
-
A 64-bit buffer size was passed to an allocation function that only accepts a 32-bit size, so the upper bits were truncated and the buffer was undersized.
Seen in 1 report
-
A 64-bit chunk size was compared against a 32-bit maximum, so larger values passed the check and the later addition overflowed.
Seen in 1 report
-
A 64-bit integer parameter passed to a function expecting 32 bits, truncating to zero and under-allocating.
Seen in 1 report
-
A 64-bit length was truncated to 32 bits before sizing a buffer.
-
A 64-bit maximum handle value is stored in a 32-bit variable and multiplied by four for allocation, overflowing on 32-bit builds.
Seen in 1 report
-
A 64-bit offset is truncated to a 32-bit signed integer and the negative result is used without validation.
Seen in 1 report