Memory safety is a property of a language or runtime that stops a program from touching memory it has no right to touch. Bugs fall into two families: spatial, where an access lands outside the right bounds, and temporal, where memory is used at the wrong time, such as after it was freed.
The two families
A 2024 White House technical report puts it in two sentences. Spatial memory safety issues come from accesses outside the bounds set for variables and objects. Temporal issues arise when memory is accessed outside of time or state, for example using an object after it was freed.
That split is useful because the fixes differ. Bounds checks address the first family. Ownership rules, garbage collection or tagging address the second.
Spatial bugs in practice
Three common shapes:
- Out-of-bounds read. The program reads past the end of a buffer and can expose data that belongs to another user or process.
- Out-of-bounds write. The program writes past the end and corrupts neighbouring data, sometimes data that controls execution.
- Bad length arithmetic. A size is computed wrongly, so a correct looking copy overruns the destination.
The memorysafety.org project lists out-of-bounds reads and writes as two of its three core classes.
Temporal bugs in practice
The third class from that project is use-after-free. Memory is released, the allocator reuses it for something else, and an old pointer still reads or writes it. Double free is the close cousin: the same block is released twice, which can corrupt allocator state.
These bugs are hard to spot in review because the pointer looks fine where it is used. The fault is in the order of events, often across files or threads.
Why it matters for security
In the 2025 CWE Top 25 list, out-of-bounds write sits at rank 5, use after free at rank 7 and out-of-bounds read at rank 8. Three of the ten most dangerous weaknesses on that list are memory safety problems, so this is not a niche concern.
What a memory safe language changes
In a memory safe language the compiler or runtime inserts the checks, or makes the unsafe pattern impossible to write. You do not get a bounds violation as a silent corruption. You get an error, a panic or a compile failure. Languages such as Rust, Go, C#, Java, Swift, Python and JavaScript are listed as memory safe by memorysafety.org, while C, C++ and assembly are not.
Safe does not mean bug free. Logic errors, injection and broken access control all remain.
Try it yourself
Click through it at your own pace, or open it full screen. Look at how a code scan reports a finding and which weakness category it attaches.
Quick check
Is a buffer over-read a spatial or a temporal bug?
Spatial. The access is outside the valid range of the object, whether it reads or writes.
Is use after free spatial or temporal?
Temporal. The address may be valid, but the object it pointed to is no longer live.
If you maintain C or C++ code, Safeguard's dependency scanning and reachability analysis can show which known memory bugs in your libraries are actually reachable from your code. A free scan is at https://gold.safeguard.sh/scan.
Sources
- Back to the Building Blocks, ONCD, February 2024
- memorysafety.org, What is memory safety
- 2025 CWE Top 25, MITRE
Last reviewed: 19 October 2026.