---
title: "CWE-416: Use After Free"
url: https://radicalnotion.ai/cwe/cwe-416
type: cwe
description: "The product reuses or references memory after it has been freed. At some point afterward, the memory may be allocated again and saved in another pointer, while the original pointer references a location somewhere within the new allocation. Any operations using the original pointer are no longer valid because the memory \"belongs\" to the code that operates on the new pointer."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-416: Use After Free

- **Abstraction:** Variant
- **Structure:** Simple
- **Status:** Stable
- **Likelihood of exploit:** High
- **CVEs with this as primary weakness:** 10,324
- **Of those, in CISA KEV:** 107
- **New in 2026:** 4,004
- **CWE catalog version:** 4.21

## Description

The product reuses or references memory after it has been freed. At some point afterward, the memory may be allocated again and saved in another pointer, while the original pointer references a location somewhere within the new allocation. Any operations using the original pointer are no longer valid because the memory "belongs" to the code that operates on the new pointer.

## Alternate terms

- **Dangling pointer:** a pointer that no longer points to valid memory, often after it has been freed
- **UAF:** commonly used acronym for Use After Free
- Use-After-Free

## Modes of introduction

| Phase | Note |
| --- | --- |
| Implementation | - |

## Applicable platforms

**Languages:** Memory-Unsafe (Often), C (Often), C++ (Often)

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Integrity | Modify Memory | The use of previously freed memory may corrupt valid data, if the memory area in question has been allocated and used properly elsewhere. |
| Availability | DoS: Crash, Exit, or Restart | If chunk consolidation occurs after the use of previously freed data, the process may crash when invalid data is used as chunk information. |
| Confidentiality | Read Memory | Read operations on freed memory can sometimes leak sensitive information instead of causing a crash |
| Integrity, Confidentiality, Availability | Execute Unauthorized Code or Commands | If malicious data is entered before chunk consolidation can take place, it may be possible to take advantage of a write-what-where primitive to execute arbitrary code. If the newly allocated data happens to hold a class, in C++ for example, various function pointers may be scattered within the heap data. If one of these function pointers is overwritten with an address to valid shellcode, execution of arbitrary code can be achieved. |

## Potential mitigations

### Architecture and Design (Language Selection)

Choose a language that provides automatic memory management.

### Implementation (Attack Surface Reduction)

When freeing pointers, be sure to set them to NULL once they are freed. However, the utilization of multiple or complex data structures may lower the usefulness of this strategy.

Effectiveness: Defense in Depth. If a bug causes an attempted access of this pointer, then a NULL dereference could still lead to a crash or other unexpected behavior, but it will reduce or eliminate the risk of code execution.

## Detection methods

### Fuzzing

Fuzz testing (fuzzing) is a powerful technique for generating large numbers of diverse inputs - either randomly or algorithmically - and dynamically invoking the code with those inputs. Even with random inputs, it is often capable of generating unexpected results such as crashes, memory corruption, or resource consumption. Fuzzing effectively produces repeatable test cases that clearly indicate bugs, which helps developers to diagnose the issues.

Effectiveness: High

### Automated Static Analysis

Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)

Effectiveness: High

### Automated Dynamic Analysis

Use tools that are integrated during compilation to insert runtime error-checking mechanisms related to memory safety errors, such as AddressSanitizer (ASan) for C/C++ \[REF-1518\].

Effectiveness: Moderate. Crafted inputs are necessary to reach the code containing the error, such as generated by fuzzers. Also, these tools may reduce performance, and they only report the error condition - not the original mistake that led to the error.

## Demonstrative examples

### Example 1

The following example demonstrates the weakness.

Bad code:

```c
#include <stdio.h>
#include <unistd.h>
#define BUFSIZER1 512
#define BUFSIZER2 ((BUFSIZER1/2) - 8)
int main(int argc, char **argv) {
    char *buf1R1;
    char *buf2R1;
    char *buf2R2;
    char *buf3R2;
    buf1R1 = (char *) malloc(BUFSIZER1);
    buf2R1 = (char *) malloc(BUFSIZER1);
    free(buf2R1);
    buf2R2 = (char *) malloc(BUFSIZER2);
    buf3R2 = (char *) malloc(BUFSIZER2);
    strncpy(buf2R1, argv[1], BUFSIZER1-1);
    free(buf1R1);
    free(buf2R2);
    free(buf3R2);
}
```

### Example 2

The following code illustrates a use after free error:

Bad code:

```c
char* ptr = (char*)malloc (SIZE);
if (err) {
    abrt = 1;
    free(ptr);
}
...
if (abrt) {
    logError("operation aborted before commit", ptr);
}
```

When an error occurs, the pointer is immediately freed. However, this pointer is later incorrectly used in the logError function.

## Observed examples

| CVE | Description |
| --- | --- |
| CVE-2023-38160 | TCP/IP code for an OS has a use-after-free that can leak heap memory contents |
| CVE-2023-5447 | Chain: missing lock check (CWE-414) leads to Use-After-Free (CWE-416) |
| CVE-2022-20141 | Chain: an operating system kernel has insufficient resource locking (CWE-413) leading to a use after free (CWE-416). |
| CVE-2022-2621 | Chain: two threads in a web browser use the same resource (CWE-366), but one of those threads can destroy the resource before the other has completed (CWE-416). |
| CVE-2021-0920 | Chain: mobile platform race condition (CWE-362) leading to use-after-free (CWE-416), as exploited in the wild per CISA KEV. |
| CVE-2020-6819 | Chain: race condition (CWE-362) leads to use-after-free (CWE-416), as exploited in the wild per CISA KEV. |
| CVE-2010-4168 | Use-after-free triggered by closing a connection while data is still being transmitted. |
| CVE-2010-2941 | Improper allocation for invalid data leads to use-after-free. |
| CVE-2010-2547 | certificate with a large number of Subject Alternate Names not properly handled in realloc, leading to use-after-free |
| CVE-2010-1772 | Timers are not disabled when a related object is deleted |
| CVE-2010-1437 | Access to a "dead" object that is being cleaned up |
| CVE-2010-1208 | object is deleted even with a non-zero reference count, and later accessed |
| CVE-2010-0629 | use-after-free involving request containing an invalid version number |
| CVE-2010-0378 | unload of an object that is currently being accessed by other functionality |
| CVE-2010-0302 | incorrectly tracking a reference count leads to use-after-free |
| CVE-2010-0249 | use-after-free related to use of uninitialized memory |
| CVE-2010-0050 | HTML document with incorrectly-nested tags |
| CVE-2009-3658 | Use after free in ActiveX object by providing a malformed argument to a method |
| CVE-2009-3616 | use-after-free by disconnecting during data transfer, or a message containing incorrect data types |
| CVE-2009-3553 | disconnect during a large data transfer causes incorrect reference count, leading to use-after-free |
| CVE-2009-2416 | use-after-free found by fuzzing |
| CVE-2009-1837 | Chain: race condition (CWE-362) from improper handling of a page transition in web client while an applet is loading (CWE-368) leads to use after free (CWE-416) |
| CVE-2009-0749 | realloc generates new buffer and pointer, but previous pointer is still retained, leading to use after free |
| CVE-2010-3328 | Use-after-free in web browser, probably resultant from not initializing memory. |
| CVE-2008-5038 | use-after-free when one thread accessed memory that was freed by another thread |
| CVE-2008-0077 | assignment of malformed values to certain properties triggers use after free |
| CVE-2006-4434 | mail server does not properly handle a long header. |
| CVE-2010-2753 | Chain: integer overflow leads to use-after-free |
| CVE-2006-4997 | freed pointer dereference |
| CVE-2003-0813 | Chain: A multi-threaded race condition (CWE-367) allows attackers to cause two threads to process the same RPC request, which causes a use-after-free (CWE-416) in one thread |

## Real CVEs with this weakness (sample of 12 of 10,324)

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2025-24085 | iOS and iPadOS: CoreMedia - A malicious application may be able to elevate privileges | critical | 10.0 | - | Yes | 2025-01-27 |
| CVE-2025-43529 | Apple Multiple Products Use-After-Free WebKit Vulnerability | critical | 9.4 | - | Yes | 2025-12-17 |
| CVE-2023-43000 | iOS and iPadOS: WebKit - Processing maliciously crafted web content may lead to memory corruption | critical | 9.4 | - | Yes | 2025-11-05 |
| CVE-2024-9680 | Mozilla Firefox Use-After-Free Vulnerability | critical | 9.4 | - | Yes | 2024-10-09 |
| CVE-2024-4671 | Use after free in Visuals | critical | 9.4 | - | Yes | 2024-05-09 |
| CVE-2022-26485 | Mozilla Firefox Use-After-Free Vulnerability | critical | 9.4 | - | Yes | 2022-12-22 |
| CVE-2022-26486 | Mozilla Firefox Use-After-Free Vulnerability | critical | 9.4 | - | Yes | 2022-12-22 |
| CVE-2021-4102 | Google Chromium V8 Use-After-Free Vulnerability | critical | 9.4 | - | Yes | 2022-02-11 |
| CVE-2021-37973 | Use after free in Portals | critical | 9.4 | - | Yes | 2021-10-08 |
| CVE-2021-30633 | Use after free in Indexed DB API | critical | 9.4 | - | Yes | 2021-10-08 |
| CVE-2021-28550 | Adobe Acrobat Reader use after free vulnerability could lead to arbitrary code execution | critical | 9.4 | - | Yes | 2021-09-02 |
| CVE-2021-30858 | macOS Big Sur: WebKit - Processing maliciously crafted web content may lead to arbitrary code execution | critical | 9.4 | - | Yes | 2021-08-24 |

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-672](https://radicalnotion.ai/cwe/cwe-672) | Operation on a Resource after Expiration or Release |
| Parent | [CWE-825](https://radicalnotion.ai/cwe/cwe-825) | Expired Pointer Dereference |
| Peer | [CWE-415](https://radicalnotion.ai/cwe/cwe-415) | Double Free |
| Can precede | [CWE-120](https://radicalnotion.ai/cwe/cwe-120) | Buffer Copy without Checking Size of Input |
| Can precede | [CWE-123](https://radicalnotion.ai/cwe/cwe-123) | Write-what-where Condition |
| Related | [CWE-362](https://radicalnotion.ai/cwe/cwe-362) | Concurrent Execution using Shared Resource with Improper Synchronization |
| Related | [CWE-364](https://radicalnotion.ai/cwe/cwe-364) | Signal Handler Race Condition |
| Related | [CWE-754](https://radicalnotion.ai/cwe/cwe-754) | Improper Check for Unusual or Exceptional Conditions |
| Related | [CWE-1265](https://radicalnotion.ai/cwe/cwe-1265) | Unintended Reentrant Invocation of Non-reentrant Code Via Nested Calls |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| ISA/IEC 62443 | Req SI-1 | Part 4-1 | - |
| 7 Pernicious Kingdoms | Use After Free | - | - |
| CLASP | Using freed memory | - | - |
| CERT C Secure Coding | Allocate and free memory in the same module, at the same level of abstraction | MEM00-C | - |
| CERT C Secure Coding | Store a new value in pointers immediately after free() | MEM01-C | - |
| CERT C Secure Coding | Do not access freed memory | MEM30-C | Exact |
| Software Fault Patterns | Faulty Resource Use | SFP15 | - |

## Frequently asked questions

### What is CWE-416?

The product reuses or references memory after it has been freed. At some point afterward, the memory may be allocated again and saved in another pointer, while the original pointer references a location somewhere within the new allocation. Any operations using the original pointer are no longer valid because the memory "belongs" to the code that operates on the new pointer.

### What CVEs are caused by CWE-416?

10,324 recorded CVEs are attributed to CWE-416, including CVE-2025-24085, CVE-2025-43529 and CVE-2023-43000. 107 are listed in CISA's Known Exploited Vulnerabilities (KEV) catalog.

### How do you prevent CWE-416?

Choose a language that provides automatic memory management.

### How is CWE-416 detected?

Fuzzing: Fuzz testing (fuzzing) is a powerful technique for generating large numbers of diverse inputs - either randomly or algorithmically - and dynamically invoking the code with those inputs. Even with random inputs, it is often capable of generating unexpected results such as crashes, memory corruption, or resource consumption. Fuzzing effectively produces repeatable test cases that clearly indicate bugs, which helps developers to diagnose the issues.

### What are the consequences of CWE-416?

Exploiting CWE-416 can lead to: Modify Memory, DoS: Crash, Exit, or Restart, Read Memory, Execute Unauthorized Code or Commands.

### Is CWE-416 actively exploited?

Yes. 107 CWE-416 vulnerabilities are in CISA's KEV catalog of actively exploited flaws, out of 10,324 recorded CVEs.

Primary source: [MITRE CWE](https://cwe.mitre.org/data/definitions/416.html)

---

Source: [RadicalNotion.AI](https://radicalnotion.ai/cwe/cwe-416). Licensed CC BY-NC 4.0; attribute RadicalNotion.AI and link the source page when you reuse this data.
