CWE-375: Returning a Mutable Object to an Untrusted Caller

Description

Sending non-cloned mutable data as a return value may result in that data being altered or deleted by the calling function.

Submission Date :

July 19, 2006, midnight

Modification Date :

2023-06-29 00:00:00+00:00

Organization :

MITRE
Extended Description

In situations where functions return references to mutable data, it is possible that the external code which called the function may make changes to the data sent. If this data was not previously cloned, the class will then be using modified data which may violate assumptions about its internal state.

Example Vulnerable Codes

Example - 1

This class has a private list of patients, but provides a way to see the list :


return patientList;private PatientClass[] patientList = new PatientClass[50];public getPatients(...){}public class ClinicalTrial {}

While this code only means to allow reading of the patient list, the getPatients() method returns a reference to the class's original patient list instead of a reference to a copy of the list. Any caller of this method can arbitrarily modify the contents of the patient list even though it is a private member of the class.

Related Weaknesses

This table shows the weaknesses and high level categories that are related to this weakness. These relationships are defined to give an overview of the different insight to similar items that may exist at higher and lower levels of abstraction.

Visit http://cwe.mitre.org/ for more details.

© cvefeed.io
Latest DB Update: Nov. 23, 2024 12:28