The product accidentally uses the wrong operator, which changes the logic in security-relevant ways.
These types of errors are generally the result of a typo by the programmer.

Primary

Implementation

Low

Other
Alter Execution Logic
This weakness can cause unintended logic to be executed and other unexpected application behavior.

Automated Static Analysis
This weakness can be found easily using static analysis. However in some cases an operator might appear to be incorrect, but is actually correct and reflects unusual logic within the program.

Manual Static Analysis
This weakness can be found easily using static analysis. However in some cases an operator might appear to be incorrect, but is actually correct and reflects unusual logic within the program.

The following C/C++ and C# examples attempt to validate an int input parameter against the integer value 100.

int isValid(int value) {if (value=100) {printf("Value is valid\n");return(1);}printf("Value is not valid\n");return(0);}

bool isValid(int value) {if (value=100) {Console.WriteLine("Value is valid.");return true;}Console.WriteLine("Value is not valid.");return false;}

However, the expression to be evaluated in the if statement uses the assignment operator "=" rather than the comparison operator "==". The result of using the assignment operator instead of the comparison operator causes the int variable to be reassigned locally and the expression in the if statement will always evaluate to the value on the right hand side of the expression. This will result in the input value not being properly validated, which can cause unexpected results.

The following C/C++ example shows a simple implementation of a stack that includes methods for adding and removing integer values from the stack. The example uses pointers to add and remove integer values to the stack array variable.

#define SIZE 50int *tos, *p1, stack[SIZE];
void push(int i) {
p1++;if(p1==(tos+SIZE)) {

// Print stack overflow error message and exit

}*p1 == i;
}
int pop(void) {
if(p1==tos) {

// Print stack underflow error message and exit

}p1--;return *(p1+1);
}
int main(int argc, char *argv[]) {

// initialize tos and p1 to point to the top of stack
tos = stack;p1 = stack;
// code to add and remove items from stack
...return 0;
}

The push method includes an expression to assign the integer value to the location in the stack pointed to by the pointer variable.
However, this expression uses the comparison operator "==" rather than the assignment operator "=". The result of using the comparison operator instead of the assignment operator causes erroneous values to be entered into the stack and can cause unexpected results.

The example code below is taken from the CVA6 processor core of the HACK@DAC'21 buggy OpenPiton SoC. Debug access allows users to access internal hardware registers that are otherwise not exposed for user access or restricted access through access control protocols. Hence, requests to enter debug mode are checked and authorized only if the processor has sufficient privileges. In addition, debug accesses are also locked behind password checkers. Thus, the processor enters debug mode only when the privilege level requirement is met, and the correct debug password is provided.
The following code [REF-1377] illustrates an instance of a vulnerable implementation of debug mode. The core correctly checks if the debug requests have sufficient privileges and enables the debug_mode_d and debug_mode_q signals. It also correctly checks for debug password and enables umode_i signal.

module csr_regfile #(
...

// check that we actually want to enter debug depending on the privilege level we are currently in
unique case (priv_lvl_o)

riscv::PRIV_LVL_M: begin

debug_mode_d = dcsr_q.ebreakm;

...

riscv::PRIV_LVL_U: begin

debug_mode_d = dcsr_q.ebreaku;

...

assign priv_lvl_o = (debug_mode_q || umode_i) ? riscv::PRIV_LVL_M : priv_lvl_q;

...

debug_mode_q <= debug_mode_d;

...

However, it grants debug access and changes the privilege level, priv_lvl_o, even when one of the two checks is satisfied and the other is not. Because of this, debug access can be granted by simply requesting with sufficient privileges (i.e., debug_mode_q is enabled) and failing the password check (i.e., umode_i is disabled). This allows an attacker to bypass the debug password checking and gain debug access to the core, compromising the security of the processor.
A fix to this issue is to only change the privilege level of the processor when both checks are satisfied, i.e., the request has enough privileges (i.e., debug_mode_q is enabled) and the password checking is successful (i.e., umode_i is enabled) [REF-1378].

module csr_regfile #(
...

// check that we actually want to enter debug depending on the privilege level we are currently in
unique case (priv_lvl_o)

riscv::PRIV_LVL_M: begin

debug_mode_d = dcsr_q.ebreakm;

...

riscv::PRIV_LVL_U: begin

debug_mode_d = dcsr_q.ebreaku;

...

assign priv_lvl_o = (debug_mode_q && umode_i) ? riscv::PRIV_LVL_M : priv_lvl_q;

...

debug_mode_q <= debug_mode_d;

...

CVE-2022-3979
Chain: data visualization program written in PHP uses the "!=" operator instead of the type-strict "!==" operator (CWE-480) when validating hash values, potentially leading to an incorrect type conversion (CWE-704)
https://www.cve.org/CVERecord?id=CVE-2022-3979

CVE-2021-3116
Chain: Python-based HTTP Proxy server uses the wrong boolean operators (CWE-480) causing an incorrect comparison (CWE-697) that identifies an authN failure if all three conditions are met instead of only one, allowing bypass of the proxy authentication (CWE-1390)
https://www.cve.org/CVERecord?id=CVE-2021-3116

Using the wrong operator

EXP45-C
Do not perform assignments in selection statements
CWE More Abstract

EXP46-C
Do not use a bitwise operator with a Boolean-like operand
CWE More Abstract

SFP1
Glitch in Computation

Allowed
This CWE entry is at the Base level of abstraction, which is a preferred level of abstraction for mapping to the root causes of vulnerabilities.
Carefully read both the name and description to ensure that this mapping is an appropriate fit. Do not try to 'force' a mapping to a lower-level Base/Variant simply to comply with this preferred level of abstraction.

CLASP
2006-07-19
Draft 3
2006-07-19

Eric Dalci
Cigital
2008-07-01
updated Time_of_Introduction

CWE Content Team
MITRE
2008-09-08
updated Applicable_Platforms, Relationships, Other_Notes, Taxonomy_Mappings

CWE Content Team
MITRE
2008-10-14
updated Relationships

CWE Content Team
MITRE
2008-11-24
updated Relationships, Taxonomy_Mappings

CWE Content Team
MITRE
2011-06-01
updated Common_Consequences, Relationships, Taxonomy_Mappings

CWE Content Team
MITRE
2011-09-13
updated Relationships, Taxonomy_Mappings

CWE Content Team
MITRE
2012-05-11
updated Common_Consequences, References, Relationships, Taxonomy_Mappings

CWE Content Team
MITRE
2012-10-30
updated Demonstrative_Examples, Potential_Mitigations

CWE Content Team
MITRE
2014-06-23
updated Applicable_Platforms, Description, Detection_Factors, Other_Notes

CWE Content Team
MITRE
2014-07-30
updated Relationships

CWE Content Team
MITRE
2017-11-08
updated Demonstrative_Examples, Taxonomy_Mappings

CWE Content Team
MITRE
2019-01-03
updated Relationships

CWE Content Team
MITRE
2020-02-24
updated References, Relationships, Taxonomy_Mappings

CWE Content Team
MITRE
2020-08-20
updated Relationships

CWE Content Team
MITRE
2021-03-15
updated Demonstrative_Examples, Relationships

CWE Content Team
MITRE
2023-01-31
updated Description, Observed_Examples

CWE Content Team
MITRE
2023-04-27
updated Relationships

CWE Content Team
MITRE
2023-06-29
updated Mapping_Notes

CWE Content Team
MITRE
2023-10-26
updated Observed_Examples

CWE Content Team
MITRE
2024-02-29
4.14
2024-02-29
updated Demonstrative_Examples, References

CWE Content Team
MITRE
2025-12-11
4.19
2025-12-11
updated Weakness_Ordinalities

Chen Chen, Rahul Kande, Jeyavijayan Rajendran
Texas A&M University
2023-11-07
suggested demonstrative example

Shaza Zeitouni, Mohamadreza Rostami, Ahmad-Reza Sadeghi
Technical University of Darmstadt
2023-11-07
suggested demonstrative example

Using the Wrong Operator