COMMON WEAKNESS ENUMERATIONDraft

CWE-14

Compiler Removal of Code to Clear Buffers

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

Abstraction

Variant

Structure

Simple

Likelihood of Exploit

Medium

Understand the problem

What is the problem?

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

Extended description

This compiler optimization error occurs when: 1. Secret data are stored in memory. 1. The secret data are scrubbed from memory by overwriting its contents. 1. The source code is compiled using an optimizing compiler, which identifies and removes the function that overwrites the contents as a dead store because the memory is not used subsequently.

Root cause

How and when does the problem arise?

Lifecycle phase

Implementation

Lifecycle phase

Build and Compilation

Risk

What does successful exploitation lead to?

Read MemoryBypass Protection Mechanism

Affected security scopes: Confidentiality, Access Control

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.

Defence

How is it prevented and fixed?

Implementation

Implementation-phase defence

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

Build and Compilation

Build and Compilation aşaması savunması

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

Architecture and Design

Architecture and design approach

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

Verification

How is it detected?

Black Box

Limited
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.
CWE-14: Common Weakness Enumeration Entry CWE-14 · DayBreach