CWE-595

Comparison of Object References Instead of Object Contents

Medium

Description

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

Potential Impact

How to Fix

Implementation

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.

Detection Methods

Related Weaknesses

References

View on MITRE CWE Database →

Need Help Fixing This Vulnerability?

Our security experts can help you identify and remediate CWE-595 vulnerabilities in your codebase.

Get Security Assessment