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.
-
Check the length of user-supplied data against the destination buffer before copying.
Seen in 14 reports
-
Validate the size and content of user-supplied data before copying it into fixed-size buffers or using it as a pointer.
Seen in 14 reports
-
Add bounds checks before writing input into heap buffers.
Seen in 13 reports
-
Check the length of user-supplied data before copying it into a fixed-size buffer.
Seen in 13 reports
-
Correct how kernel-mode drivers handle objects in memory.
Seen in 13 reports
-
Correct object lifetime handling so freed memory is not reused or freed twice.
Seen in 13 reports
-
Validate size and length fields from files against the destination buffer before copying or reading, and add bounds checks in parsers.
Seen in 13 reports
-
Check that an object still exists before using it, and clear queued callbacks when the owner is freed.
Seen in 12 reports
-
Reject values that would overflow, underflow or wrap before using them in size calculations.
Seen in 12 reports
-
Add bounds checks on lengths and offsets taken from user-supplied files before copying or reading.
Seen in 11 reports
-
Check that an object still exists before using it, and re-check weak pointers after calls that can destroy the object.
Seen in 11 reports
-
Correct how the engine handles objects in memory when parsing crafted files.
Seen in 11 reports
-
Correct object handling in Office document parsing, including the Preview Pane path.
Seen in 11 reports
-
Correct object lifetime and validation in kernel-mode drivers.
Seen in 11 reports
-
Validate input lengths against the destination buffer size before copying or reading.
Seen in 11 reports
-
Validate that a user-supplied value is a valid pointer before dereferencing it.
Seen in 11 reports
-
Validate the size and type of data read from files before using it or writing it to buffers.
Seen in 11 reports
-
Check declared lengths against the destination buffer size before every copy in packet and file parsers.
Seen in 10 reports
-
Check size calculations for overflow and sign-extension before allocating or indexing.
Seen in 10 reports
-
Improved bounds checking, improved state handling, improved memory management, and adopting 64-bit timestamps in the kernel.
Seen in 10 reports
-
Improved memory handling and memory management.
Seen in 10 reports
-
Initialise pointers and zero allocated arrays before use, especially on error paths.
Seen in 10 reports
-
Validate all file-supplied lengths and counts against the actual buffer sizes and check allocation arithmetic for overflow before allocating.
Seen in 10 reports
-
Check that an object still exists before operating on it, and correct object handling in the affected component.
Seen in 9 reports
-
Fix object lifetime handling so freed memory is not referenced, and close race windows.
Seen in 9 reports
-
Improve memory handling and management in the affected parser.
Seen in 9 reports
-
Keep objects alive across asynchronous callbacks or re-check references after event loop re-entry.
Seen in 9 reports
-
Manage object lifetimes so freed memory is not referenced again, including under concurrent teardown.
Seen in 9 reports
-
Validate caller-supplied pointers and initialise pointers before use.
Seen in 9 reports
-
Validate declared lengths against the destination buffer before copying, and check dimensions for overflow before allocating.
Seen in 9 reports
-
Validate every length, size and index read from the file against the destination buffer before copying or indexing.
Seen in 9 reports
-
Validate input length before copying into fixed-size heap or stack buffers.
Seen in 9 reports
-
Validate length and size fields from a file against the destination buffer before copying or writing.
Seen in 9 reports
-
Validate lengths and sizes from untrusted input before copying or allocating.
Seen in 9 reports
-
Validate size and count values and use checked arithmetic for allocation calculations.
Seen in 9 reports
-
Validate size and length values from image files against the allocated buffer before copying or writing.
Seen in 9 reports
-
Validate the size, length and structure of every field read from a file before copying or writing it to a buffer.
Seen in 9 reports
-
Validate the type of user-supplied data before using it in command handlers.
Seen in 9 reports
-
Bound every copy by the destination buffer size and check TLV counts and offsets before use.
Seen in 8 reports
-
Check integer arithmetic for overflow and wraparound before using the result as a size.
Seen in 8 reports
-
Check integer arithmetic for overflow, underflow and truncation before the resulting value is used as a size or index.
Seen in 8 reports
-
Check integer calculations for overflow, underflow and wraparound before using the result as a size or index.
Seen in 8 reports
-
Check that an object still exists before using it, and invalidate or reference-count handles that outlive the internal list they point into.
Seen in 8 reports
-
Check user-supplied lengths and counts against the destination buffer size before copying or looping.
Seen in 8 reports
-
Correct memory management so objects are not used after being freed.
Seen in 8 reports
-
Perform size arithmetic with overflow and underflow checks before comparing against limits or allocating buffers.
Seen in 8 reports
-
Use bounded copies and pass the destination buffer size to configuration retrieval functions.
Seen in 8 reports
-
Use weak pointers or liveness checks around calls that can synchronously destroy an object through callbacks or nested loops.
Seen in 8 reports
-
Validate every file-supplied length and size against the destination buffer before copying or reading.
Seen in 8 reports
-
Validate lengths and indices against the actual allocated size before copying or indexing, not against global limits.
Seen in 8 reports