---
title: "CWE-375: Returning a Mutable Object to an Untrusted Caller"
url: https://radicalnotion.ai/cwe/cwe-375
type: cwe
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."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

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

- **Abstraction:** Base
- **Structure:** Simple
- **Status:** Draft
- **Likelihood of exploit:** Medium
- **CVEs with this as primary weakness:** 0
- **Of those, in CISA KEV:** 0
- **New in 2026:** 0
- **CWE catalog version:** 4.21

## 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.

## Modes of introduction

| Phase | Note |
| --- | --- |
| Implementation | - |

## Applicable platforms

**Languages:** Object-Oriented (Undetermined), C (Undetermined), C++ (Undetermined), Java (Undetermined), C# (Undetermined)

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| 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.

## Demonstrative examples

### Example 1

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

Bad code:

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

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

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-668](https://radicalnotion.ai/cwe/cwe-668) | Exposure of Resource to Wrong Sphere |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| CLASP | Mutable object returned | - | - |
| The CERT Oracle Secure Coding Standard for Java (2011) | Provide mutable classes with copy functionality to safely allow passing instances to untrusted code | OBJ04-J | - |
| The CERT Oracle Secure Coding Standard for Java (2011) | Defensively copy private mutable class members before returning their references | OBJ05-J | - |
| SEI CERT Perl Coding Standard | Do not modify $\_ in list or sorting functions | EXP34-PL | Imprecise |
| Software Fault Patterns | Exposed Data | SFP23 | - |

## Frequently asked questions

### What is CWE-375?

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

### How do you prevent CWE-375?

Declare returned data which should not be altered as constant or immutable.

### What are the consequences of CWE-375?

Exploiting CWE-375 can lead to: Modify Memory.

Primary source: [MITRE CWE](https://cwe.mitre.org/data/definitions/375.html)

---

Source: [RadicalNotion.AI](https://radicalnotion.ai/cwe/cwe-375). Licensed CC BY-NC 4.0; attribute RadicalNotion.AI and link the source page when you reuse this data.
