CWE-14: Compiler Removal of Code to Clear Buffers

Variant Draft Simple

CWE版本: 4.18

更新日期: 2025-09-09

弱点描述

Sensitive memory is cleared according to the source code, but compiler optimizations leave the memory untouched when it is not read from again, aka "dead store removal."

常见后果

影响范围: Confidentiality Access Control

技术影响: Read Memory Bypass Protection Mechanism

说明: This weakness will allow data that has not been cleared from memory to be read. If this data contains sensitive password information, then an attacker can read the password and use the information to bypass protection mechanisms.

潜在缓解措施

阶段: Implementation

描述: Store the sensitive data in a "volatile" memory location if available.

阶段: Build and Compilation

描述: If possible, configure your compiler so that it does not remove dead stores.

阶段: Architecture and Design

描述: Where possible, encrypt sensitive data that are used by a software system.

检测方法

方法: Black Box

This specific weakness is impossible to detect using black box methods. While an analyst could examine memory to see that it has not been scrubbed, an analysis of the executable would not be successful. This is because the compiler has already removed the relevant code. Only the source code shows whether the programmer intended to clear the memory or not, so this weakness is indistinguishable from others.

方法: White Box

This weakness is only detectable using white box methods (see black box detection factor). Careful analysis is required to determine if the code is likely to be removed by the compiler.

引入模式

阶段 说明
Implementation -
Build and Compilation -

适用平台

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

分类映射

分类名称 条目ID 条目名称 映射适配度
7 Pernicious Kingdoms - Insecure Compiler Optimization -
PLOVER - Sensitive memory uncleared by compiler optimization -
OWASP Top Ten 2004 A8 Insecure Storage CWE More Specific
CERT C Secure Coding MSC06-C Be aware of compiler optimization when dealing with sensitive data -
Software Fault Patterns SFP23 Exposed Data -
关键信息

CWE ID: CWE-14

抽象级别: Variant

结构: Simple

状态: Draft

相关弱点