---
title: "CWE-401: Missing Release of Memory after Effective Lifetime"
url: https://radicalnotion.ai/cwe/cwe-401
type: cwe
description: "The product does not sufficiently track and release allocated memory after it has been used, making the memory unavailable for reallocation and reuse."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-401: Missing Release of Memory after Effective Lifetime

- **Abstraction:** Variant
- **Structure:** Simple
- **Status:** Draft
- **Likelihood of exploit:** Medium
- **CVEs with this as primary weakness:** 2,020
- **Of those, in CISA KEV:** 1
- **New in 2026:** 540
- **CWE catalog version:** 4.21

## Description

The product does not sufficiently track and release allocated memory after it has been used, making the memory unavailable for reallocation and reuse.

## Alternate terms

- **Memory Leak:** a common term for not releasing memory; however, the same term is also used for "disclosure of sensitive information from memory," so use of this term is discouraged.

## Modes of introduction

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

## Applicable platforms

**Languages:** C (Undetermined), C++ (Undetermined)

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Availability | DoS: Crash, Exit, or Restart, DoS: Instability, DoS: Resource Consumption (CPU), DoS: Resource Consumption (Memory) | Most memory leaks result in general product reliability problems, but if an attacker can intentionally trigger a memory leak, the attacker might be able to launch a denial of service attack (by crashing or hanging the program) or take advantage of other unexpected program behavior resulting from a low memory condition. |
| Other | Reduce Performance | - |

## Potential mitigations

### Implementation (Libraries or Frameworks)

Choose a language or tool that provides automatic memory management, or makes manual memory management less error-prone.

For example, glibc in Linux provides protection against free of invalid pointers.

When using Xcode to target OS X or iOS, enable automatic reference counting (ARC) \[REF-391\].

To help correctly and consistently manage memory when programming in C++, consider using a smart pointer class such as std::auto\_ptr (defined by ISO/IEC ISO/IEC 14882:2003), std::shared\_ptr and std::unique\_ptr (specified by an upcoming revision of the C++ standard, informally referred to as C++ 1x), or equivalent solutions such as Boost.

### Architecture and Design

Use an abstraction library to abstract away risky APIs. Not a complete solution.

### Architecture and Design, Build and Compilation

Consider using the Boehm-Demers-Weiser garbage collector (bdwgc), which can help avoid leaks.

Effectiveness: Moderate. This is not a complete solution as it is not 100% effective.

## 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 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\] or valgrind \[REF-480\].

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.

### 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

## Demonstrative examples

### Example 1

The following C function leaks a block of allocated memory if the call to read() does not return the expected number of bytes:

Bad code:

```c
char* getBlock(int fd) {
    char* buf = (char*) malloc(BLOCK_SIZE);
    if (!buf) {
        return NULL;
    }
    if (read(fd, buf, BLOCK_SIZE) != BLOCK_SIZE) {

        return NULL;
    }
    return buf;
}
```

## Observed examples

| CVE | Description |
| --- | --- |
| CVE-2005-3119 | Memory leak because function does not free() an element of a data structure. |
| CVE-2004-0427 | Memory leak when counter variable is not decremented. |
| CVE-2002-0574 | Chain: reference count is not decremented, leading to memory leak in OS by sending ICMP packets. |
| CVE-2005-3181 | Kernel uses wrong function to release a data structure, preventing data from being properly tracked by other code. |
| CVE-2004-0222 | Memory leak via unknown manipulations as part of a protocol test suite. |
| CVE-2001-0136 | Memory leak via a series of the same command. |

## Real CVEs with this weakness (sample of 12 of 2,020)

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2023-26083 | Arm Mali GPU Kernel Driver Information Disclosure Vulnerability | medium | 4.8 | - | Yes | 2023-04-06 |
| CVE-2026-46289 | lib/scatterlist: fix length calculations in extract\_kvec\_to\_sg | critical | 9.8 | - | No | 2026-06-08 |
| CVE-2025-39948 | ice: fix Rx page leak on multi-buffer frames | critical | 9.8 | - | No | 2025-10-04 |
| CVE-2025-21954 | netmem: prevent TX of unreadable skbs | critical | 9.8 | - | No | 2025-04-01 |
| CVE-2024-57947 | netfilter: nf\_set\_pipapo: fix initial map fill | critical | 9.8 | - | No | 2025-01-23 |
| CVE-2024-56779 | nfsd: fix nfs4\_openowner leak when concurrent nfsd4\_open occur | critical | 9.8 | - | No | 2025-01-08 |
| CVE-2024-56645 | can: j1939: j1939\_session\_new(): fix skb reference counting | critical | 9.8 | - | No | 2024-12-27 |
| CVE-2024-36911 | hv\_netvsc: Don't free decrypted memory | critical | 9.8 | - | No | 2024-05-30 |
| CVE-2024-27388 | SUNRPC: fix some memleaks in gssx\_dec\_option\_array | critical | 9.8 | - | No | 2024-05-01 |
| CVE-2024-57793 | virt: tdx-guest: Just leak decrypted memory on unrecoverable errors | critical | 9.3 | - | No | 2025-01-11 |
| CVE-2024-36909 | Drivers: hv: vmbus: Don't free ring buffers that couldn't be re-encrypted | critical | 9.3 | - | No | 2024-05-30 |
| CVE-2026-124539 | JSON::XS versions before 4.05 for Perl leak the decoded key of an object rejected for a missing colon in decode\_hv | critical | 9.1 | - | No | 2026-11-14 |

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-404](https://radicalnotion.ai/cwe/cwe-404) | Improper Resource Shutdown or Release |
| Parent | [CWE-772](https://radicalnotion.ai/cwe/cwe-772) | Missing Release of Resource after Effective Lifetime |
| Related | [CWE-390](https://radicalnotion.ai/cwe/cwe-390) | Detection of Error Condition Without Action |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| PLOVER | Memory leak | - | - |
| 7 Pernicious Kingdoms | Memory Leak | - | - |
| CLASP | Failure to deallocate data | - | - |
| OWASP Top Ten 2004 | Denial of Service | A9 | CWE More Specific |
| CERT C Secure Coding | Free dynamically allocated memory when no longer needed | MEM31-C | Exact |
| The CERT Oracle Secure Coding Standard for Java (2011) | Do not leak memory | MSC04-J | - |
| Software Fault Patterns | Failure to Release Resource | SFP14 | - |
| OMG ASCPEM | - | ASCPEM-PRF-14 | - |

## Frequently asked questions

### What is CWE-401?

The product does not sufficiently track and release allocated memory after it has been used, making the memory unavailable for reallocation and reuse.

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

2,020 recorded CVEs are attributed to CWE-401, including CVE-2023-26083, CVE-2026-46289 and CVE-2025-39948. 1 is listed in CISA's Known Exploited Vulnerabilities (KEV) catalog.

### Is CWE-401 part of the OWASP Top 10?

CWE-401 maps to OWASP Top Ten 2004: Denial of Service (A9) in the OWASP security taxonomy.

### How do you prevent CWE-401?

Choose a language or tool that provides automatic memory management, or makes manual memory management less error-prone.

### How is CWE-401 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-401?

Exploiting CWE-401 can lead to: DoS: Crash, Exit, or Restart, DoS: Instability, DoS: Resource Consumption (CPU), DoS: Resource Consumption (Memory), Reduce Performance.

### Is CWE-401 actively exploited?

Yes. 1 CWE-401 vulnerability is in CISA's KEV catalog of actively exploited flaws, out of 2,020 recorded CVEs.

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

---

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