CWE-491 — Public cloneable() Method Without Final ('Object Hijack')
CWE-491: Public cloneable() Method Without Final ('Object Hijack')
MITRE CWE weakness
| Kind | Weakness |
| Abstraction | Variant |
| Status | Draft |
| Likelihood of exploit | — |
Description
A class has a cloneable() method that is not declared final, which allows an object to be created without calling the constructor. This can cause the object to be in an unexpected state.
Common consequences
- Integrity, Other: Unexpected State, Varies by Context
Mitigations
Implementation — Make the cloneable() method final.
References
- CWE page: https://cwe.mitre.org/data/definitions/491.html
- CWE list: https://cwe.mitre.org/data/index.html