...
Creating a mutable class without providing copy functionality can result in the data of its instance becoming corrupted when the instance is passed to untrusted code.
Rule | Severity | Likelihood | Detectable | RepairableRemediation Cost | Priority | Level |
|---|---|---|---|---|---|---|
OBJ04-J | Low | Likely | No | NoMedium | P6P3 | L2L3 |
Automated Detection
Sound automated detection is infeasible in the general case. Heuristic approaches could be useful.
Tool | Version | Checker | Description | ||||||
|---|---|---|---|---|---|---|---|---|---|
| CodeSonarCoverity | 47.25 | FB.MALICIOUS_CODE.EI_EXPOSE_REPREP2 | May expose internal representation by returning reference to mutable object May expose internal representation by incorporating reference to mutable object | Coverity | 7.5 | FB.EI_EXPOSE_REP2 | ImplementedREP | Implemented | |
| Klocwork |
| SV.EXPOSE.RET SV.EXPOSE.STORE | |||||||
| Parasoft Jtest |
| CERT.OBJ04.CLONE CERT.OBJ04.CPCL CERT.OBJ04.MPT CERT.OBJ04.SMO CERT.OBJ04.MUCOP | Make your 'clone()' method "final" for security Enforce returning a defensive copy in 'clone()' methods Do not pass user-given mutable objects directly to certain types Do not store user-given mutable objects directly into variables Provide mutable classes with copy functionality |
Related Guidelines
CWE-374, Passing Mutable Objects to an Untrusted Method | |
Guideline 6-4 / MUTABLE-4: Support copy functionality for a mutable class |
...