CWE-580: clone() Method Without super.clone()
Description
The product contains a clone() method that does not call super.clone() to obtain the new object.
All implementations of clone() should obtain the new object by calling super.clone(). If a class does not follow this convention, a subclass's clone() method will return an object of the wrong type.
- Abstraction
- VariantA weakness tied to a specific language, technology or resource.
- Likelihood of exploit
- Not rated by MITRE
- Status
- Draft
Common consequences
- IntegrityOther
Unexpected State; Quality Degradation
Potential mitigations
- Implementation
Call super.clone() within your clone() method, when obtaining a new object.
- Implementation
In some cases, you can eliminate the clone method altogether and use copy constructors.
Related weaknesses
CAPEC attack patterns that exploit it
CWE 4.20 links no CAPEC attack pattern to this weakness.