Use-after-free
A program keeps using a pointer after the memory it points to has been freed (CWE-416). If an attacker can get that memory reallocated with data they control, the stale pointer reads or calls through it, which often leads to code execution.
- Also called
- UAF · dangling pointer
- Defined in
- MITRE CWE-416
- Identifiers
- CWE-416: Use after free
Covered in
Find, fix and contain memory-safety bugs in C and C++
Recognize out-of-bounds access, use after free, NULL dereference and integer overflow in C and C++, fix them with checked lengths and single ownership, harden release builds, catch the rest with sanitizers and fuzzing, and plan new code in a memory-safe language.
Audit unsafe Rust, FFI boundaries and crate dependencies
Know what the Rust compiler proves and what it leaves to you: review unsafe code for soundness, wrap foreign calls in small safe functions, decide how overflow and panics behave in release builds, gate crates with RustSec, and replace C one boundary at a time.