This vulnerability occurs when a developer incorrectly compares string values, typically by using reference equality operators (like == or !=) instead of dedicated string comparison methods (like .equals()).
In languages like Java, using '==' to compare strings checks if two object references point to the same memory location, not whether their textual content is identical. This is a common logic error because two separate string objects with the same characters will fail an '==' test, leading to unexpected program behavior and flawed conditional logic. While this often results in general bugs or incorrect functionality, it becomes a security issue when the flawed comparison is part of an authentication check, authorization decision, or input validation. An attacker could potentially bypass security controls by exploiting the unintended mismatch, turning a simple coding mistake into a system vulnerability.
Impact: Other
Effectiveness: High
javajava(i === s1) is FALSE
(s4 === i) is FALSE
(s4 === s1) is FALSE
var i = 65; var s1 = '65'; var s4 = new String('65');
if (i === s1) {
javascript(i == s1) is FALSE
(s4 == i) is FALSE
(s4 == s1) is FALSE
var i = 65; var s1 = '65'; var s4 = new String('65');
if (i == s1) {
javascriptvar $i = 65; var $s1 = "65";
if ($i === $s1) {
phpvar $i = 65; var $s1 = "65";
if ($i == $s1) {
php