---
title: "CWE-374: Passing Mutable Objects to an Untrusted Method"
url: https://radicalnotion.ai/cwe/cwe-374
type: cwe
description: "The product sends non-cloned mutable data as an argument to a method or function."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-374: Passing Mutable Objects to an Untrusted Method

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

## Description

The product sends non-cloned mutable data as an argument to a method or 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 |
| --- | --- | --- |
| Integrity | Modify Memory | The function or method that has been called can alter or delete the mutable data. This could violate assumptions that the calling function has made about its state. In situations where unknown code is called with references to mutable data, this external code could make changes to the data sent. If this data was not previously cloned, the modified data might not be valid in the context of execution. |

## Potential mitigations

### Implementation

Pass in data which should not be altered as constant or immutable.

### Implementation

Clone all mutable data before passing it into an external function . 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

The following example demonstrates the weakness.

Bad code:

```c
private:
    int foo;
    complexType bar;
    String baz;
    otherClass externalClass;

public:
    void doStuff() {
        externalClass.doOtherStuff(foo, bar, baz)
    }
```

In this example, bar and baz will be passed by reference to doOtherStuff() which may change them.

### Example 2

In the following Java example, the BookStore class manages the sale of books in a bookstore, this class includes the member objects for the bookstore inventory and sales database manager classes. The BookStore class includes a method for updating the sales database and inventory when a book is sold. This method retrieves a Book object from the bookstore inventory object using the supplied ISBN number for the book class, then calls a method for the sales object to update the sales information and then calls a method for the inventory object to update inventory for the BookStore.

Bad code:

```java
public class BookStore {
    private BookStoreInventory inventory;
    private SalesDBManager sales;
    ...
    // constructor for BookStore
    public BookStore() {
        this.inventory = new BookStoreInventory();
        this.sales = new SalesDBManager();
        ...
    }
    public void updateSalesAndInventoryForBookSold(String bookISBN) {

        // Get book object from inventory using ISBN
        Book book = inventory.getBookWithISBN(bookISBN);
        // update sales information for book sold
        sales.updateSalesInformation(book);
        // update inventory
        inventory.updateInventory(book);
    }
    // other BookStore methods
    ...
}
public class Book {
    private String title;
    private String author;
    private String isbn;
    // Book object constructors and get/set methods
    ...
}
```

Good code:

```java
...
public void updateSalesAndInventoryForBookSold(String bookISBN) {

    // Get book object from inventory using ISBN
    Book book = inventory.getBookWithISBN(bookISBN);
    // Create copy of book object to make sure contents are not changed
    Book bookSold = (Book) book.clone();
    // update sales information for book sold
    sales.updateSalesInformation(bookSold);
    // update inventory
    inventory.updateInventory(book);
}
...
```

## Real CVEs with this weakness

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2024-3833 | Object corruption in WebAssembly | high | 8.8 | - | No | 2024-04-17 |

## 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 | Passing mutable objects to an untrusted method | - | - |
| 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 | - |
| Software Fault Patterns | Exposed Data | SFP23 | - |

## Frequently asked questions

### What is CWE-374?

The product sends non-cloned mutable data as an argument to a method or function.

### What CVEs are caused by CWE-374?

1 recorded CVE is attributed to CWE-374: CVE-2024-3833.

### How do you prevent CWE-374?

Pass in data which should not be altered as constant or immutable.

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

Exploiting CWE-374 can lead to: Modify Memory.

### Is CWE-374 actively exploited?

1 recorded CVE is caused by CWE-374; it is not currently in CISA's KEV catalog of actively exploited flaws.

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

---

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