1337
CWE-597: Use of Wrong Operator in String Comparison
Weakness ID : 597
Structure : Simple
Abstraction : Variant
Description
The product uses the wrong operator when comparing a string, such as using "==" when
the .equals() method should be used instead.
Extended Description
In Java, using == or != to compare two strings for equality actually compares two objects for
equality rather than their string values for equality. Chances are good that the two references will
never be equal. While this weakness often only affects program correctness, if the equality is used
for a security decision, the unintended comparison result could be leveraged to affect program
security.
Relationships
The table(s) below shows the weaknesses and high level categories that are related to this
weakness. These relationships are defined as ChildOf, ParentOf, MemberOr and give insight to
similar items that may exist at higher and lower levels of abstraction. In addition, relationships such
as PeerOf and CanAlsoBe are defined to show similar weaknesses that may want to be explored.
Relevant to the view "Research Concepts" (CWE-1000)
Nature Type ID Name Page
ChildOf 480 Use of Incorrect Operator 1150
ChildOf 595 Comparison of Object References Instead of Object
Contents