In-depth lesson · Memory corruption
Typical fixes
Every point the Memory corruption reports back under this heading, best-backed first, each with the reports it is seen in.
-
Validate lengths and sizes before copying or writing input into buffers.
Seen in 8 reports
-
Validate size calculations for underflow and overflow before allocating or indexing.
Seen in 8 reports
-
Validate size, offset and count fields against the actual buffer length before reading or writing.
Seen in 8 reports
-
Validate user-supplied pointer values before dereferencing them in driver drawing routines.
Seen in 8 reports
-
Add bounds checks before reading or writing based on file-supplied sizes.
Seen in 7 reports
-
Add improved input validation and bounds checks when parsing crafted files in Apple frameworks.
Seen in 7 reports
-
Apply improved bounds checking and memory lifetime handling in SMB, UDF, GPU and storage drivers.
Seen in 7 reports
-
Check a weak pointer for liveness after any callback that could destroy the object, and avoid relying on synchronous callbacks.
Seen in 7 reports
-
Check length, offset and element count fields against buffer bounds before indexing or reading.
Seen in 7 reports
-
Check size and offset arithmetic for overflow and underflow before allocating or indexing.
Seen in 7 reports
-
Check that an object still exists before dereferencing it, and clear pointers when freeing.
Seen in 7 reports
-
Check that an object still exists before using or freeing it, and initialise memory before accessing it.
Seen in 7 reports
-
Correct how kernel components handle objects in memory so crafted applications cannot corrupt kernel memory.
Seen in 7 reports
-
Correct how the component handles objects in memory so freed or out-of-range objects are not used.
Seen in 7 reports
-
Correct object handling in the scripting engine.
Seen in 7 reports
-
Improve input sanitisation and bounds checking in media parsers.
Seen in 7 reports
-
Improve validation, state handling and memory handling for crafted web content.
Seen in 7 reports
-
Improved input validation and bounds checking when parsing media files.
Seen in 7 reports
-
Initialise memory resources before use and do not let crafted input steer writes to uninitialised state.
Seen in 7 reports
-
Initialise resources before use and check bounds on all reads and writes.
Seen in 7 reports
-
Length-check user-supplied parameters before copying them into fixed-size buffers.
Seen in 7 reports
-
Prevent the same memory from being freed more than once.
Seen in 7 reports
-
Validate a value from the file before using it as a pointer, and check for null before dereferencing.
Seen in 7 reports
-
Validate image-supplied size and offset values against the destination buffer before computing write addresses and loop counts.
Seen in 7 reports
-
Validate lengths and offsets from the file against the destination buffer size before copying or reading.
Seen in 7 reports
-
Validate size, length and offset fields from the file against the actual buffer before copying or reading.
Seen in 7 reports
-
Validate that a value read from a file is of the expected type and is a valid pointer before it is used.
Seen in 7 reports
-
Validate the length of user-supplied data before copying it into a fixed-length buffer.
Seen in 7 reports
-
Validate the type and length of arguments before using them in the JavaScript API methods.
Seen in 7 reports
-
Bound the length of multipart values, boundaries, headers and bodies before copying them into fixed buffers.
Seen in 6 reports
-
Check arithmetic on untrusted sizes for overflow, underflow and truncation before using the result.
Seen in 6 reports
-
Check object types before use and do not trust type fields from input.
Seen in 6 reports
-
Check size calculations for overflow before allocating buffers.
Seen in 6 reports
-
Check that a Doc object still exists before performing operations on it.
Seen in 6 reports
-
Check that an object still exists before performing operations on it, and hold strong references where needed.
Seen in 6 reports
-
Check that an object still exists before using it and track lifetime with strong references rather than raw pointers.
Seen in 6 reports
-
Check that an object still exists before using it, and clear pointers when objects are freed or detached.
Seen in 6 reports
-
Check that an object still exists before using or freeing it, and track object lifetime across event handlers.
Seen in 6 reports
-
Check that length fields are within expected bounds before using them in arithmetic or memory operations.
Seen in 6 reports
-
Check the length of incoming data before copying it into fixed-size stack or heap buffers.
Seen in 6 reports
-
Correct how the driver or component handles objects in memory.
Seen in 6 reports
-
Improve input validation when parsing crafted files and messages.
Seen in 6 reports
-
Improved bounds checking and memory management in the SMB client.
Seen in 6 reports
-
Invalidate or reference-count objects when a document closes so later script access cannot reach freed memory.
Seen in 6 reports
-
Pass the remaining space rather than the full buffer size to each formatting call, and check lengths from files and network data against the destination buffer before copying.
Seen in 6 reports
-
Perform size calculations with overflow-checked arithmetic and validate counts against the actual data length before allocating.
Seen in 6 reports
-
Use weak pointers or liveness guards after any call that can synchronously destroy the object.
Seen in 6 reports
-
Validate every length read from a file against the destination buffer size before copying.
Seen in 6 reports
-
Validate file-supplied sizes, lengths and offsets against the allocated buffer before copying or reading.
Seen in 6 reports
-
Validate lengths and array indices from files before copying or indexing.
Seen in 6 reports