CWE Database
/

CWE-581

Back to CWE list

CWE-581

Object Model Violation: Just One of Equals and Hashcode Defined

Variant
Draft

Description

The product does not maintain equal hashcodes for equal objects.

Java objects are expected to obey a number of invariants related to equality. One of these invariants is that equal objects must have equal hashcodes. In other words, if a.equals(b) == true then a.hashCode() == b.hashCode().

Common Consequences

Scope

Integrity
Other

Impact

Other

Potential Mitigations

Implementation

Both Equals() and Hashcode() should be defined.

Applicable Platforms

Java

Security Training

Train your team to recognize and prevent security threats with our comprehensive security awareness program.

Start Training

Vulnerability Scanning

Discover vulnerabilities in your applications and infrastructure before attackers do.

Scan Now