CWE一覧に戻る
CWE-595

オブジェクト・コンテンツではなくオブジェクト参照の比較

Comparison of Object References Instead of Object Contents
脆弱性 作成中
JA

この製品は、オブジェクト自体の内容ではなくオブジェクトの参照を比較するため、同等のオブジェクトを検出することができない。

たとえばJavaでは、==演算子は値ではなくオブジェクトの参照を比較するので、==を使ったオブジェクトの比較は通常、欺瞞的な結果を生む。

EN

The product compares object references instead of the contents of the objects themselves, preventing it from detecting equivalent objects.

For example, in Java, comparing objects using == usually produces deceptive results, since the == operator compares object references rather than values; often, this means that using == for strings is actually comparing the strings' references, not their values.

Scope: Other / Impact: Varies by Context
In Java, use the equals() method to compare objects instead of the == operator. If using ==, it is important for performance reasons that your objects are created by a static factory, not by a constructor.
MITRE公式ページ — CWE-595