---
title: "CWE-733: Compiler Optimization Removal or Modification of Security-critical Code"
url: https://radicalnotion.ai/cwe/cwe-733
type: cwe
description: "The developer builds a security-critical protection mechanism into the software, but the compiler optimizes the program such that the mechanism is removed or modified."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-733: Compiler Optimization Removal or Modification of Security-critical Code

- **Abstraction:** Base
- **Structure:** Simple
- **Status:** Incomplete
- **CVEs with this as primary weakness:** 5
- **Of those, in CISA KEV:** 0
- **New in 2026:** 0
- **CWE catalog version:** 4.21

## Description

The developer builds a security-critical protection mechanism into the software, but the compiler optimizes the program such that the mechanism is removed or modified.

## Modes of introduction

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

## Applicable platforms

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

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Access Control, Other | Bypass Protection Mechanism, Alter Execution Logic | - |

## 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));
}
```

## Observed examples

| CVE | Description |
| --- | --- |
| CVE-2008-1685 | C compiler optimization, as allowed by specifications, removes code that is used to perform checks to detect integer overflows. |
| CVE-2019-1010006 | Chain: compiler optimization (CWE-733) removes or modifies code used to detect integer overflow (CWE-190), allowing out-of-bounds write (CWE-787). |

## Real CVEs with this weakness

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2025-13024 | JIT miscompilation in the JavaScript Engine: JIT component | critical | 9.8 | - | No | 2025-11-11 |
| CVE-2025-52496 | mbedtls: Mbed TLS AESNI Race Condition Vulnerability | high | 7.8 | - | No | 2025-07-04 |
| CVE-2020-15294 | Compiler Optimization Removal or Modification of Security-Critical Code vulnerability in Bitdefender Hypervisor Introspection (VA-9339) | high | 7.8 | - | No | 2020-12-17 |
| CVE-2025-20241 | Cisco Nexus 3000 and 9000 Series Switches IS-IS Protocol Denial of Service Vulnerability | high | 7.4 | - | No | 2025-08-27 |
| CVE-2024-58262 | curve25519-dalek has timing variability in \`curve25519-dalek\`'s \`Scalar29::sub\`/\`Scalar52::sub\` | medium | 5.1 | - | No | 2025-07-27 |

## Related attack patterns (CAPEC)

- [CAPEC-10](https://radicalnotion.ai/capec/capec-10): Buffer Overflow via Environment Variables
- [CAPEC-24](https://radicalnotion.ai/capec/capec-24): Filter Failure through Buffer Overflow
- [CAPEC-46](https://radicalnotion.ai/capec/capec-46): Overflow Variables and Tags
- [CAPEC-8](https://radicalnotion.ai/capec/capec-8): Buffer Overflow in an API Call
- [CAPEC-9](https://radicalnotion.ai/capec/capec-9): Buffer Overflow in Local Command-Line Utilities

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-1038](https://radicalnotion.ai/cwe/cwe-1038) | Insecure Automated Optimizations |
| Child | [CWE-14](https://radicalnotion.ai/cwe/cwe-14) | Compiler Removal of Code to Clear Buffers |

## Frequently asked questions

### What is CWE-733?

The developer builds a security-critical protection mechanism into the software, but the compiler optimizes the program such that the mechanism is removed or modified.

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

5 recorded CVEs are attributed to CWE-733, including CVE-2025-13024, CVE-2025-52496 and CVE-2020-15294.

### How is CWE-733 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-733?

Exploiting CWE-733 can lead to: Bypass Protection Mechanism, Alter Execution Logic.

### Is CWE-733 actively exploited?

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

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

---

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