---
title: "CWE-14: Compiler Removal of Code to Clear Buffers"
url: https://radicalnotion.ai/cwe/cwe-14
type: cwe
description: "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.\""
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-14: Compiler Removal of Code to Clear Buffers

- **Abstraction:** Variant
- **Structure:** Simple
- **Status:** Draft
- **CVEs with this as primary weakness:** 10
- **Of those, in CISA KEV:** 0
- **New in 2026:** 2
- **CWE catalog version:** 4.21

## Description

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."

## Modes of introduction

| Phase | Note |
| --- | --- |
| Build and Compilation | - |

## Applicable platforms

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

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| 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. |

## Potential mitigations

### Implementation

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

### Build and Compilation

If possible, configure the compiler so that it does not remove dead stores.

### Architecture and Design

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

## Detection methods

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

Effectiveness: Limited

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

## Demonstrative examples

### Example 1

The following code reads a password from the user, uses the password to connect to a back-end mainframe, and then attempts to scrub the password from memory using memset().

Bad code:

```c
void GetData(char *MFAddr) {
    char pwd[64];
    if (GetPasswordFromUser(pwd, sizeof(pwd))) {
        if (ConnectToMainframe(MFAddr, pwd)) {
            // Interaction with mainframe
        }
    }
    memset(pwd, 0, sizeof(pwd));
}
```

## Real CVEs with this weakness

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2023-32100 | Key duplication in GSDK | high | 7.5 | - | No | 2023-05-18 |
| CVE-2023-32099 | Key duplication in GSDK | high | 7.5 | - | No | 2023-05-18 |
| CVE-2023-32098 | Key duplication in GSDK | high | 7.5 | - | No | 2023-05-18 |
| CVE-2023-32097 | Key duplication in GSDK | high | 7.5 | - | No | 2023-05-18 |
| CVE-2023-32096 | Key duplication in GSDK | high | 7.5 | - | No | 2023-05-18 |
| CVE-2023-2481 | Key duplication in GSDK | high | 7.5 | - | No | 2023-05-18 |
| CVE-2023-1132 | Key duplication in GSDK | high | 7.5 | - | No | 2023-05-18 |
| CVE-2023-0965 | Key duplication in GSDK | high | 7.5 | - | No | 2023-05-18 |
| CVE-2025-64646 | Multiple Vulnerabilities in IBM Concert Software | medium | 6.2 | - | No | 2026-03-25 |
| CVE-2026-48984 | pam\_usb: xfree() does not call explicit\_bzero — sensitive cryptographic material may linger in freed heap | medium | 4.7 | - | No | 2026-06-18 |

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-733](https://radicalnotion.ai/cwe/cwe-733) | Compiler Optimization Removal or Modification of Security-critical Code |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| 7 Pernicious Kingdoms | Insecure Compiler Optimization | - | - |
| PLOVER | Sensitive memory uncleared by compiler optimization | - | - |
| OWASP Top Ten 2004 | Insecure Storage | A8 | CWE More Specific |
| CERT C Secure Coding | Be aware of compiler optimization when dealing with sensitive data | MSC06-C | - |
| Software Fault Patterns | Exposed Data | SFP23 | - |

## Frequently asked questions

### What is CWE-14?

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."

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

10 recorded CVEs are attributed to CWE-14, including CVE-2023-32100, CVE-2023-32099 and CVE-2023-32098.

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

CWE-14 maps to OWASP Top Ten 2004: Insecure Storage (A8) in the OWASP security taxonomy.

### How do you prevent CWE-14?

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

### How is CWE-14 detected?

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.

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

Exploiting CWE-14 can lead to: Read Memory, Bypass Protection Mechanism.

### Is CWE-14 actively exploited?

10 recorded CVEs are caused by CWE-14; none are currently in CISA's KEV catalog of actively exploited flaws.

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

---

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