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().
Parent Weaknesses (ChildOf)
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 TrainingVulnerability Scanning
Discover vulnerabilities in your applications and infrastructure before attackers do.
Scan Now