CWE-580: clone() Method Without super.clone()
The product contains a clone() method that does not call super.clone() to obtain the new object.
Last updated
Overview
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.
Common consequences
What can happen when CWE-580 is exploited.
Unexpected State, Quality Degradation
Affects: Integrity, Other
How it happens
When it is introduced
Typically introduced during these phases of the software lifecycle.
Applies to
Languages
How to prevent it
Practical mitigations for CWE-580, grouped by where in the lifecycle they apply.
Call super.clone() within your clone() method, when obtaining a new object.
In some cases, you can eliminate the clone method altogether and use copy constructors.
How to detect it
Automated Static Analysis
Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)
Effectiveness: High
Code examples
Illustrative examples from MITRE showing how the weakness appears in code.
The following two classes demonstrate a bug introduced by not calling super.clone(). Because of the way Kibitzer implements clone(), FancyKibitzer's clone method will return an object of type Kibitzer instead of FancyKibitzer.
Vulnerable example
public class Kibitzer {Terminology & mappings
Mapped taxonomies
- Software Fault Patterns: Unexpected access points (SFP28)
Frequently asked questions
Common questions about CWE-580.
- What is CWE-580?
- The product contains a clone() method that does not call super.clone() to obtain the new object.
- How do you prevent CWE-580?
- Call super.clone() within your clone() method, when obtaining a new object.
- How is CWE-580 detected?
- Automated Static Analysis: Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)
- What are the consequences of CWE-580?
- Exploiting CWE-580 can lead to: Unexpected State, Quality Degradation.
References
- MITRE CWE definition (CWE-580) (opens in a new tab)
- CWE-580 vulnerabilities on NVD (opens in a new tab)
- Learn: What is a CWE?
Weakness data is sourced from the MITRE CWE catalog (v4.20). CVE associations are aggregated and kept current by RadicalNotion.AI.
Stay ahead of CWE-580
Get alerted the moment a new CWE-580 vulnerability affects your stack, with AI-written analysis, severity context, and remediation guidance.