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."
How it's found
Compiler Removal of Code to Clear Buffers is a specific, narrowly defined instance of a broader pattern. Testers confirm it with targeted code review and a proof-of-concept input that exercises the exact code path this weakness describes.
This compiler optimization error occurs when:Secret data are stored in memory. The secret data are scrubbed from memory by overwriting its contents. 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.
Consequences
- 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.
Mitigations
- 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.
Where this fits in a TurboPentest engagement
TurboPentest's agentic pentest is powerful and covers a broad range of issues automatically. This particular class is best confirmed in a manual IntegSec engagement, where human pentesters apply deeper methodology and a larger context window than any automated pass.
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."
How do you find Compiler Removal of Code to Clear Buffers?
Compiler Removal of Code to Clear Buffers is a specific, narrowly defined instance of a broader pattern. Testers confirm it with targeted code review and a proof-of-concept input that exercises the exact code path this weakness describes.
What is the impact of CWE-14?
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.
Does TurboPentest test for Compiler Removal of Code to Clear Buffers?
TurboPentest's agentic pentest is powerful and covers a broad range of issues automatically. This particular class is best confirmed in a manual IntegSec engagement, where human pentesters apply deeper methodology and a larger context window than any automated pass.
Related CWEs
- Base weaknessCWE-733: Compiler Optimization Removal or Modification of Security-critical Code
- Base weaknessCWE-261: Weak Encoding for Password
- Class weaknessCWE-311: Missing Encryption of Sensitive Data
- Variant weaknessCWE-321: Use of Hard-coded Cryptographic Key
- Class weaknessCWE-326: Inadequate Encryption Strength
- Class weaknessCWE-327: Use of a Broken or Risky Cryptographic Algorithm
About this reference
These security references are maintained by IntegSec, an offensive-security firm whose team holds CISSP, OSCP, and OSCE certifications and has run thousands of penetration tests. Content is kept current as tools, standards, and attack techniques evolve.
Find these issues before an attacker does
TurboPentest runs an agentic AI pentest against your target and reports findings with proof, from $99 per target.
Start a pentest