CWEweakness
CWE-482 Comparing instead of Assigning
Low
Official page ↗
- Abstraction
- Variant
- Structure
- Simple
- Status
- Draft
- Likelihood of exploit
- Low
- Languages
- C, C++
- CWE version
- 5.0
Description
The code uses an operator for comparison when the intention was to perform an assignment.
Common consequences
• Availability, Integrity: Unexpected State — The assignment will not take place, which should cause obvious program execution problems.
Potential mitigations
• [Testing] Many IDEs and static analysis products will detect this problem.
Detection methods
• Automated Static Analysis: Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)
• Automated Static Analysis - Source Code: An Integrated Development Environment (IDE) or linter can report or highlight this weakness.
Related
Child of · CWE (1)
- CWE-480 Use of Incorrect Operator weakness
Referenced by CVE · weakness (2)
- CVE-2026-26279 Froxlor is open source server administration software. vulnerability
- CVE-2024-33430 An issue in phiola/src/afilter/pcm_convert.h:513 of phiola v2.0-rc22 allows a remote attacker to execute arbitrary code via the a crafted… vulnerability