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.
-
Reset iterators that track append positions whenever the range they point into is removed, regardless of timestamp state.
Seen in 2 reports
-
Reset the phi node traversal state between calls and verify all inputs before marking a node as zero-extended.
Seen in 2 reports
-
Run state restore and cleanup on failure paths as well as success paths.
-
Sanitise hashes and enums so they cannot equal reserved sentinel keys.
Seen in 2 reports
-
Security update corrects how the service handles certain objects in memory.
-
Set the handle's cookie pointer to null after freeing the cookie store, and sort only the filled entries.
Seen in 2 reports
-
Size the buffer for all samples per pixel rather than the smaller of tile and image dimensions.
-
Some Apple fixes removed the vulnerable code entirely rather than patching it.
-
Stop JavaScript execution when the document closes and clear references to freed objects.
-
String methods should re-read the buffer pointer and length after argument conversion and after yielding to user blocks.
Seen in 2 reports
-
Synchronise document close and page close actions so freed objects are not reused.
Seen in 2 reports
-
Synchronise object destruction with use on other threads.
Seen in 2 reports
-
The user-supplied length should be kept unsigned or range-checked before use in size calculations and allocations.
-
Track ownership of canvas and stream objects so they are destroyed once.
-
Treat an invalid block switch as a fatal format error rather than a need for more input, and bounds-check the streaming buffer.
-
Unlink an association object from its group before freeing it.
-
Use a full-width size calculation and check the computed allocation size before copying record data.
Seen in 2 reports
-
Use each chroma plane's own stride when copying.
Seen in 2 reports
-
Use the same size calculation for allocation and for the read or write, and validate the two against each other.
Seen in 2 reports
-
Validate attacker-controlled length fields against the actual buffer size before indexing or setting memory.
-
Validate indices in bracket data insertion and segment building.
Seen in 2 reports
-
Validate length fields from server packets before using them in arithmetic or decryption.
Seen in 2 reports
-
Validate lengths and offsets from network data against the size of the allocated buffer.
-
Validate numeric input and handle overflow and truncation safely.
-
Validate object existence and array indices before use.
-
Validate pointers received from untrusted sources before dereferencing them.
-
Validate pointers supplied from user mode before dereferencing them in kernel code.
-
Validate register indices and operands in shader bytecode before using them to compute write addresses.
-
Validate shader-supplied indices and repeat counts before using them as write addresses or loop bounds.
-
Validate size values and use widened arithmetic before allocating buffers.
-
Validate that file-supplied values used as lookup table indices are within the table bounds.
-
Validate that the calculated authentication trailer pointer stays within the received packet buffer.
-
Validate the integer from the file before using it to calculate a buffer size.
-
Validate the size and bounds of user-supplied data before writing to a buffer.
-
Validate the user-supplied resource index and check the fallback resource pointer before use.
-
Validate values taken from input before using them as pointers.
-
Verify the backend type and expected interface before casting or constructing.
-
Verify the record size read from the file is smaller than the fixed record buffer before copying.
Seen in 2 reports
-
Abort after raising the exception rather than storing an error sentinel as the component count in PDF colour space handling.
Seen in 1 report
-
Abort processing when a size or consistency check fails instead of continuing to decode.
Seen in 1 report
-
Account for quads split during clipping when sizing batches against the index buffer.
Seen in 1 report
-
Account for re-entrant JavaScript during microtask checkpoints and re-check the parser object after navigation.
Seen in 1 report
-
Check that the mapped buffer byte count is at least the MAC header size plus the VLAN tag length before processing Wi-Fi frames.
-
Add a default case and a trailing return to switches over renderer-controlled values such as accessibility enums.
Seen in 1 report
-
Add a re-entrancy guard to the cw-pause writer as was done for cw-out.
Seen in 1 report
-
Add a self-assignment check to the move assignment operator.
Seen in 1 report
-
Add a size check before reading headers into a fixed-size buffer.
Seen in 1 report
-
Add a type check in the jsToWasm inline-cache entrypoint.
Seen in 1 report
-
Add bounds checks before writing to memory buffers while parsing archives.
-
Add bounds checks on the plane number and write pointer in the RLE decoder.
Seen in 1 report