Public cloneable() Method Without Final ('Object Hijack') |
Weakness ID: 491 (Weakness Variant) | Status: Draft |
Description Summary
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.
Example 1
In this example, a public class "BankAccount" implements the cloneable() method which declares "Object clone(string accountnumber)":
(Bad Code)
Example Language: Java
public class BankAccount implements Cloneable{
public Object clone(String accountnumber) throws
CloneNotSupportedException
{
Object returnMe = new BankAccount(account number);
...
}
}
Example 2
In the example below, a clone() method is defined without being declared final.
(Bad Code)
Example Language: Java
protected Object clone() throws CloneNotSupportedException {
...
}
Nature | Type | ID | Name | View(s) this relationship pertains to![]() |
---|---|---|---|---|
ChildOf | ![]() | 485 | Insufficient Encapsulation | Seven Pernicious Kingdoms (primary)700 |
ChildOf | ![]() | 490 | Mobile Code Issues | Development Concepts (primary)699 |
ChildOf | ![]() | 668 | Exposure of Resource to Wrong Sphere | Research Concepts (primary)1000 |
Mapped Taxonomy Name | Node ID | Fit | Mapped Node Name |
---|---|---|---|
7 Pernicious Kingdoms | Mobile Code: Object Hijack |
OWASP. "OWASP , Attack Category : Mobile code: object hijack". <http://www.owasp.org/index.php/Mobile_code:_object_hijack>. |
Submissions | ||||
---|---|---|---|---|
Submission Date | Submitter | Organization | Source | |
7 Pernicious Kingdoms | Externally Mined | |||
Modifications | ||||
Modification Date | Modifier | Organization | Source | |
2008-07-01 | Sean Eidemiller | Cigital | External | |
added/updated demonstrative examples | ||||
2008-07-01 | Eric Dalci | Cigital | External | |
updated References, Demonstrative Example, Potential Mitigations, Time of Introduction | ||||
2008-09-08 | CWE Content Team | MITRE | Internal | |
updated Relationships, References, Taxonomy Mappings | ||||
2009-05-27 | CWE Content Team | MITRE | Internal | |
updated Name | ||||
2009-07-27 | CWE Content Team | MITRE | Internal | |
updated Demonstrative Examples | ||||
Previous Entry Names | ||||
Change Date | Previous Entry Name | |||
2008-04-11 | Mobile Code: Object Hijack | |||
2009-05-27 | Public cloneable() Method Without Final (aka 'Object Hijack') | |||