Katalog CWE

CWE-14 · Słabość

Compiler Removal of Code to Clear Buffers

Abstrakcja
Wariant
Status
Szkic
Dodano
19 lipca 2006
Ostatnia zmiana
11 grudnia 2025

Podatności CVE z tą słabościąPełny wpis na cwe.mitre.org ↗

Opis

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

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.

Skutki

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

Zapobieganie

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

Słabość nadrzędna

Kiedy powstaje

Dotyczy

C, C++, Compiled

Źródła

  1. Seven Pernicious Kingdoms: A Taxonomy of Software Security Errors — Katrina Tsipenyuk, Brian Chess, Gary McGraw, NIST, 2005
  2. Writing Secure Code — Michael Howard, David LeBlanc, Chapter 9, "A Compiler Optimization Caveat" Page 322, Microsoft Press, 2002
  3. When scrubbing secrets in memory doesn't work — Michael Howard, BugTraq, 2002
  4. Some Bad News and Some Good News — Michael Howard, Microsoft, 2002
  5. GNU GCC: Optimizer Removes Code Necessary for Security — Joseph Wagner, Bugtraq, 2002

Wpis z katalogu CWE 4.20.