Insecure Automated Optimizations

Draft Class
Structure: Simple
Description

This vulnerability occurs when software uses automated tools to optimize code for performance or efficiency, but those optimizations accidentally weaken or bypass critical security protections that the original code relied upon.

Extended Description

Automated optimization tools, like aggressive compilers, minifiers, or bundlers, work by restructuring code to make it faster or smaller. However, their primary goal is efficiency, not security. In the process, they might remove security checks they deem unnecessary, inline sensitive functions, or rearrange operations in a way that breaks the logical flow designed to prevent attacks, such as timing attack mitigations or input validation sequences. Developers often trust that the original security logic will be preserved after optimization, creating a dangerous gap between code written and code executed. To prevent this, you must understand the specific behaviors of your optimization tools, test the final compiled or bundled output for security properties, and use appropriate tool configurations or code annotations to protect security-critical sections from being altered.

Common Consequences 1
Scope: Integrity

Impact: Alter Execution Logic

The optimizations alter the order of execution resulting in side effects that were not intended by the original developer.

Observed Examples 2
CVE-2017-5715Intel, ARM, and AMD processor optimizations related to speculative execution and branch prediction cause access control checks to be bypassed when placing data into the cache. Often known as "Spectre".
CVE-2008-1685C compiler optimization, as allowed by specifications, removes code that is used to perform checks to detect integer overflows.
Likelihood of Exploit

Low

Applicable Platforms
Languages:
Not Language-Specific : Undetermined
Modes of Introduction
Architecture and Design