CWE
CWE/SANS Top 25 Most Dangerous Software Errors Common Weakness Scoring System
Common Weakness Risk Analysis Framework
Home > CWE List > CWE- Individual Dictionary Definition (2.1)  

CWE-480: Use of Incorrect Operator

 
Use of Incorrect Operator
Weakness ID: 480 (Weakness Base)Status: Draft
+ Description

Description Summary

The programmer accidentally uses the wrong operator, which changes the application logic in security-relevant ways.
+ Time of Introduction
  • Implementation
+ Applicable Platforms

Languages

C: (Sometimes)

C++: (Sometimes)

Perl: (Sometimes)

All

+ Common Consequences
ScopeEffect
Other

Technical Impact: Alter execution logic

+ Likelihood of Exploit

Low

+ Demonstrative Examples

Example 1

Example Language:
char foo;
foo=a+c;
+ Potential Mitigations

Pre-design through Build: Most static analysis programs should be able to catch these errors.

Phase: Implementation

Save an index variable. This is the recommended solution. Rather than subtract pointers from one another, use an index variable of the same size as the pointers in question. Use this variable to "walk" from one pointer to the other and calculate the difference. Always sanity check this number.

+ Other Notes

These types of bugs generally are the result of a typo. Although most of them can easily be found when testing of the program, it is important that one correct these problems, since they almost certainly will break the code.

+ Relationships
NatureTypeIDNameView(s) this relationship pertains toView(s)
ChildOfCategoryCategory569Expression Issues
Development Concepts (primary)699
ChildOfWeakness ClassWeakness Class670Always-Incorrect Control Flow Implementation
Research Concepts (primary)1000
ChildOfCategoryCategory747CERT C Secure Coding Section 49 - Miscellaneous (MSC)
Weaknesses Addressed by the CERT C Secure Coding Standard (primary)734
ChildOfCategoryCategory847CERT Java Secure Coding Section 02 - Expressions (EXP)
Weaknesses Addressed by the CERT Java Secure Coding Standard (primary)844
ChildOfCategoryCategory871CERT C++ Secure Coding Section 03 - Expressions (EXP)
Weaknesses Addressed by the CERT C++ Secure Coding Standard (primary)868
ChildOfCategoryCategory883CERT C++ Secure Coding Section 49 - Miscellaneous (MSC)
Weaknesses Addressed by the CERT C++ Secure Coding Standard868
ParentOfWeakness VariantWeakness Variant481Assigning instead of Comparing
Development Concepts699
Research Concepts (primary)1000
ParentOfWeakness VariantWeakness Variant482Comparing instead of Assigning
Development Concepts699
Research Concepts (primary)1000
ParentOfWeakness VariantWeakness Variant597Use of Wrong Operator in String Comparison
Development Concepts699
Research Concepts1000
+ Taxonomy Mappings
Mapped Taxonomy NameNode IDFitMapped Node Name
CLASPUsing the wrong operator
CERT C Secure CodingMSC02-CAvoid errors of omission
CERT C Secure CodingMSC03-CAvoid errors of addition
CERT Java Secure CodingEXP04-JDo not perform assignments in conditional statements
CERT C++ Secure CodingEXP19-CPPDo not perform assignments in conditional ressions
CERT C++ Secure CodingMSC02-CPPAvoid errors of omission
CERT C++ Secure CodingMSC03-CPPAvoid errors of addition
+ Content History
Submissions
Submission DateSubmitterOrganizationSource
CLASPExternally Mined
Modifications
Modification DateModifierOrganizationSource
2008-07-01Eric DalciCigitalExternal
updated Time_of_Introduction
2008-09-08CWE Content TeamMITREInternal
updated Applicable_Platforms, Relationships, Other_Notes, Taxonomy_Mappings
2008-10-14CWE Content TeamMITREInternal
updated Relationships
2008-11-24CWE Content TeamMITREInternal
updated Relationships, Taxonomy_Mappings
2011-06-01CWE Content TeamMITREInternal
updated Common_Consequences, Relationships, Taxonomy_Mappings
2011-09-13CWE Content TeamMITREInternal
updated Relationships, Taxonomy_Mappings
Previous Entry Names
Change DatePrevious Entry Name
2008-04-11Using the Wrong Operator
Page Last Updated: September 12, 2011