Skip to content

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.

Back to the lesson 201 to 250 of 976
  1. Check for integer overflow before resizing buffers and validate length fields against the destination size.

    Seen in 4 reports
  2. Check for integer overflow before using a computed size for allocation.

    Seen in 4 reports
  3. Check for integer overflow in size calculations and grow the value stack before copying arguments.

    Seen in 4 reports
  4. Check header and field lengths before copying into fixed-size stack buffers.

    Seen in 4 reports
  5. Check size arithmetic for overflow and truncation before allocating buffers.

    Seen in 4 reports
  6. Check size calculations for integer overflow and keep the allocation size and copy size derived from the same checked value.

    Seen in 4 reports
  7. Check size multiplications and subtractions for overflow before allocating buffers.

    Seen in 4 reports
  8. Check tag-supplied lengths and counters against the destination buffer size before copying or indexing.

    Seen in 4 reports
  9. Check that a length is at least the fixed header size before subtracting from it, and use checked arithmetic for allocation sizes.

    Seen in 4 reports
  10. Check that an object still exists before dereferencing it during parsing.

    Seen in 4 reports
  11. Check that an object still exists before operating on it, and avoid destroying a shared parent while other callbacks still reference it.

    Seen in 4 reports
  12. Check that an object still exists before operating on it, and use lifetime-aware references for callbacks.

    Seen in 4 reports
  13. Check that an object still exists before using it, and null out pointers after freeing.

    Seen in 4 reports
  14. Check that an object still exists before using it, to prevent use-after-free.

    Seen in 4 reports
  15. Check that an object still exists before using or freeing it, and clear references after release.

    Seen in 4 reports
  16. Check the length of user-supplied data before copying it into a fixed-length heap buffer.

    Seen in 4 reports
  17. Check user-supplied lengths against the actual buffer size before copying.

    Seen in 4 reports
  18. Clear references when an object is freed and validate that an object still exists before using it.

    Seen in 4 reports
  19. Correct object handling in kernel-mode drivers to prevent memory corruption.

    Seen in 4 reports
  20. Correct object lifetime handling so freed memory is not referenced again.

    Seen in 4 reports
  21. Do not iterate live containers across calls that can run script or re-enter; copy the keys first or hold owning references.

    Seen in 4 reports
  22. Enforce state and size checks in release builds, not only through debug assertions.

    Seen in 4 reports
  23. Hold reference-counted handles rather than raw pointers in callbacks, and iterate copies of containers that can be mutated during the loop.

    Seen in 4 reports
  24. Improve memory handling in the affected framework.

    Seen in 4 reports
  25. Improve memory handling so freed or wrongly typed objects are not reused.

    Seen in 4 reports
  26. Improve memory management and locking to close use-after-free and race conditions.

    Seen in 4 reports
  27. Improve memory management so freed objects are not referenced again.

    Seen in 4 reports
  28. Initialise memory and resources before use.

    Seen in 4 reports
  29. Initialise memory before it is read or used.

    Seen in 4 reports
  30. Initialise memory before use and check that required elements are present.

    Seen in 4 reports
  31. Initialise pointers before use.

    Seen in 4 reports
  32. Mark pipe pages attached to network buffers as shared, and verify that decryption targets memory the buffer owns.

    Seen in 4 reports
  33. Perform size calculations in wider arithmetic and check for overflow before allocating.

    Seen in 4 reports
  34. Reject zero, negative and oversized length fields and check allocation results before use.

    Seen in 4 reports
  35. Security update corrects how the Windows Runtime handles objects in memory.

    Seen in 4 reports
  36. Serialise access to shared state on the owning sequence or use atomic reference counts.

    Seen in 4 reports
  37. Treat all guest-supplied data as untrusted and validate it in virtual device emulation.

    Seen in 4 reports
  38. Use bounded string copying and check parameter lengths before copying into fixed buffers.

    Seen in 4 reports
  39. Use checked 64-bit arithmetic for buffer size calculations.

    Seen in 4 reports
  40. Use overflow-checked or unsigned arithmetic in size and offset calculations.

    Seen in 4 reports
  41. Use overflow-checked size arithmetic in document filter parsers.

    Seen in 4 reports
  42. Use weak pointers or validity checks after synchronous calls that can destroy the object, and remove objects from global sets in their destructors.

    Seen in 4 reports
  43. Use weak references or liveness checks after callbacks that can synchronously destroy objects.

    Seen in 4 reports
  44. Use wide enough size types and check for overflow, underflow and truncation in size calculations.

    Seen in 4 reports
  45. Validate a user-supplied value before using it as a memory pointer.

    Seen in 4 reports
  46. Validate attacker-controlled sizes and counts before using them in pointer arithmetic or copies.

    Seen in 4 reports
  47. Validate file-supplied sizes, counts and offsets against the actual buffer before any read or write.

    Seen in 4 reports
  48. Validate length and index fields in SMB requests and initialise pointers on all paths.

    Seen in 4 reports
  49. Validate length and size fields against the destination buffer before copying, and check arithmetic for overflow before allocating.

    Seen in 4 reports
  50. Validate length, size and offset fields from input against the destination buffer before copying or reading.

    Seen in 4 reports