CWEweakness
CWE-375 Returning a Mutable Object to an Untrusted Caller
Medium
Official page ↗
- Abstraction
- Base
- Structure
- Simple
- Status
- Draft
- Likelihood of exploit
- Medium
- Languages
- C, C#, C++, Java, Object-Oriented
- CWE version
- 5.0
Description
The code sends non-cloned mutable data as a return value may result in that data being altered or deleted by the calling function.
Common consequences
• Access Control, Integrity: Modify Memory — The muitable data could be altered or deleted by the calling function. If this data was not previously cloned, the class will then be using modified data which may violate assumptions about its internal state.
Potential mitigations
• [Implementation] Declare returned data which should not be altered as constant or immutable.
• [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.
Related
Child of · CWE (1)
- CWE-668 Exposure of Resource to Wrong Sphere weakness