Mutable Objects Passed by Reference |
Weakness ID: 374 (Weakness Base) | Status: Draft |
Description Summary
Scope | Effect |
---|---|
Integrity | Potentially data could be tampered with by another function which should not have been tampered with. |
Example 1
In this example, bar and baz will be passed by reference to doOtherStuff() which may change them.
Phase: Implementation Pass in data which should not be altered as constant or immutable. |
Phase: Implementation Clone all mutable data before returning references to it. This is the preferred mitigation. This way -- regardless of what changes are made to the data -- a valid copy is retained for use by the class. |
In situations where unknown code is called with references to mutable data, this external code may possibly make changes to the data sent. If this data was not previously cloned, you will be left with modified data which may, or may not, be valid in the context of execution. |
Nature | Type | ID | Name | View(s) this relationship pertains to![]() |
---|---|---|---|---|
ChildOf | ![]() | 371 | State 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 |
---|---|---|---|
CLASP | Mutable objects passed by reference |
Submissions | ||||
---|---|---|---|---|
Submission Date | Submitter | Organization | Source | |
CLASP | Externally Mined | |||
Modifications | ||||
Modification Date | Modifier | Organization | Source | |
2008-07-01 | Eric Dalci | Cigital | External | |
updated Time of Introduction | ||||
2008-09-08 | CWE Content Team | MITRE | Internal | |
updated Applicable Platforms, Common Consequences, Relationships, Other Notes, Taxonomy Mappings |