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.
View on MITREMake the cloneable() method final.
No detection method information available for this CWE.
In this example, a public class "BankAccount" implements the cloneable() method which declares "Object clone(string accountnumber)":
In the example below, a clone() method is defined without being declared final.
No relationship information available for this CWE.
CWE-491: Public cloneable() Method Without Final ('Object Hijack') is a Common Weakness Enumeration (CWE) entry maintained by MITRE. 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.
If exploited, CWE-491 (Public cloneable() Method Without Final ('Object Hijack')) it can compromise Integrity and Other, leading to outcomes such as Unexpected State and Varies by Context.
Recommended mitigations for CWE-491 include: Make the cloneable() method final.
CWE-491 commonly affects Java. Note that weaknesses are often language-agnostic patterns, so secure coding practices apply broadly.
A CWE (Common Weakness Enumeration) like CWE-491 describes a category of software weakness — the underlying flaw type. A CVE (Common Vulnerabilities and Exposures) identifies a specific, real-world vulnerability in a particular product. In short, a CWE is the kind of mistake, and a CVE is an instance of that mistake being found in software.