Sending non-cloned mutable data as a return value may result in that data being altered or deleted by the calling function.
Declare returned data which should not be altered as constant or immutable.
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.
Our security experts can help you identify and remediate CWE-375 vulnerabilities in your codebase.
Get Security Assessment