Use-after-free (UAF) is a memory safety vulnerability that occurs when a program continues to use a pointer to dynamically allocated memory after that memory has been freed. If the freed region is reallocated for other data, the program may read or write corrupted values, leading to crashes, information disclosure, or arbitrary code execution. It is classified as CWE-416 in the Common Weakness Enumeration.
The bug arises mainly in languages such as C and C++ where programmers manage memory manually, and a large share of the critical vulnerabilities found in web browsers, operating system kernels, and language interpreters are of this type. It is one of the main motivations behind the move toward memory-safe languages such as Rust.