Umbra Wiki weakness weakness/CWE-581
Back to wiki

CWE-581 — Object Model Violation: Just One of Equals and Hashcode Defined

provenance: imported · CWE: CWE-581

CWE-581: Object Model Violation: Just One of Equals and Hashcode Defined

MITRE CWE weakness

Kind Weakness
Abstraction Variant
Status Draft
Likelihood of exploit —

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

  • Integrity, Other: Other

Mitigations

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

References

  • CWE page: https://cwe.mitre.org/data/definitions/581.html
  • CWE list: https://cwe.mitre.org/data/index.html

See all 1,245 pages under Weakness classes (CWE) →

Related pages