Private Array-Typed Field Returned From A Public Method |
Weakness ID: 495 (Weakness Variant) | Status: Draft |
Description Summary
Example 1
Here, a public method in a Java class returns a reference to a private array. Given that arrays in Java are mutable, any modifications made to the returned reference would be reflected in the original private array.
Declare the method private. |
Clone the member data and keep an unmodified version of the data private to the object. |
Use public setter methods that govern how a member can be modified. |
Nature | Type | ID | Name | View(s) this relationship pertains to![]() |
---|---|---|---|---|
ChildOf | ![]() | 485 | Insufficient Encapsulation | Development Concepts (primary)699 Seven Pernicious Kingdoms (primary)700 Research Concepts (primary)1000 |
Mapped Taxonomy Name | Node ID | Fit | Mapped Node Name |
---|---|---|---|
7 Pernicious Kingdoms | Private Array-Typed Field Returned From A Public Method |
A weakness where code path has a statement that belongs to a public method and returns a reference to a private array field |
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 Time of Introduction | ||||
2008-08-01 | KDM Analytics | External | ||
added/updated white box definitions | ||||
2008-09-08 | CWE Content Team | MITRE | Internal | |
updated Applicable Platforms, Relationships, Taxonomy Mappings |
Security-Database help your corporation foresee and avoid any security risks that may impact your IT infrastructure and business applications.