CWE-401: Missing Release of Memory after Effective Lifetime

Variant Draft Simple

CWE版本: 4.18

更新日期: 2025-09-09

弱点描述

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

常见后果

影响范围: 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

潜在缓解措施

阶段: Implementation

策略: Libraries or Frameworks

阶段: Architecture and Design

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

阶段: Architecture and Design Build and Compilation

描述: The Boehm-Demers-Weiser Garbage Collector or valgrind can be used to detect leaks in code.

检测方法

方法: 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.

有效性: 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.)

有效性: High

观察示例

参考: 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 protocol test suite.

参考: CVE-2001-0136

Memory leak via a series of the same command.

引入模式

阶段 说明
Implementation -

适用平台

编程语言
C (Undetermined) C++ (Undetermined)

分类映射

分类名称 条目ID 条目名称 映射适配度
PLOVER - Memory leak -
7 Pernicious Kingdoms - Memory Leak -
CLASP - Failure to deallocate data -
OWASP Top Ten 2004 A9 Denial of Service CWE More Specific
CERT C Secure Coding MEM31-C Free dynamically allocated memory when no longer needed Exact
The CERT Oracle Secure Coding Standard for Java (2011) MSC04-J Do not leak memory -
Software Fault Patterns SFP14 Failure to Release Resource -
OMG ASCPEM ASCPEM-PRF-14 -
关键信息

CWE ID: CWE-401

抽象级别: Variant

结构: Simple

状态: Draft

利用可能性: Medium

相关弱点