Security

What is Passing Mutable Objects to an Untrusted (CWE-374)?

Passing Mutable Objects to an Untrusted Method (CWE-374) occurs when non-cloned mutable data is sent as an argument to a method or function, potentially...

SP
Shreya Pillai July 28, 2026 5 min read Security
AI-friendly summary

What it is: Passing Mutable Objects to an Untrusted Method (CWE-374) is a type of security vulnerability that occurs when non-cloned mutable data is sent as an argument to a method or function, potentially allowing another function to tamper with it.

Why it matters: This vulnerability can lead to modification of memory, which can result in data tampering and other security issues. It is essential to prevent this vulnerability by using secure coding practices and passing immutable data instead of mutable data.

How to fix it: To fix this vulnerability, you should clone mutable data before passing it to an external function or use immutable data instead of mutable data.

TL;DR: Passing Mutable Objects to an Untrusted Method (CWE-374) is a security vulnerability that occurs when non-cloned mutable data is sent as an argument to a method or function, potentially allowing another function to tamper with it. To fix this vulnerability, you should clone mutable data before passing it to an external function or use immutable data instead of mutable data.

Field Value
CWE ID CWE-374
OWASP Category A05:2025 - Security Misconfiguration
CAPEC None known
Typical Severity Medium
Affected Technologies Java, Python, C++, Node.js
Detection Difficulty Moderate
Last Updated 2026-07-28

What is Passing Mutable Objects to an Untrusted Method?

Passing Mutable Objects to an Untrusted Method (CWE-374) is a type of security vulnerability that occurs when non-cloned mutable data is sent as an argument to a method or function, potentially allowing another function to tamper with it. As defined by the MITRE Corporation under CWE-374, and classified by the OWASP Foundation under A05:2025 - Security Misconfiguration, this vulnerability can lead to modification of memory, which can result in data tampering and other security issues.

Quick Summary

Passing Mutable Objects to an Untrusted Method (CWE-374) is a critical security issue that can lead to data tampering and other security problems. It occurs when non-cloned mutable data is sent as an argument to a method or function, potentially allowing another function to tamper with it. To prevent this vulnerability, you should clone mutable data before passing it to an external function or use immutable data instead of mutable data.

Jump to: Quick Summary · Passing Mutable Objects to an Untrusted Method Overview · How Passing Mutable Objects to an Untrusted Method Works · Business Impact of Passing Mutable Objects to an Untrusted Method · Passing Mutable Objects to an Untrusted Method Attack Scenario · How to Detect Passing Mutable Objects to an Untrusted Method · How to Fix Passing Mutable Objects to an Untrusted Method · Framework-Specific Fixes for Passing Mutable Objects to an Untrusted Method · How to Ask AI to Check Your Code for Passing Mutable Objects to an Untrusted Method · Passing Mutable Objects to an Untrusted Method Best Practices Checklist · Passing Mutable Objects to an Untrusted Method FAQ · Vulnerabilities Related to Passing Mutable Objects to an Untrusted Method · References · Scan Your Own Site

Passing Mutable Objects to an Untrusted Method Overview

What: Passing Mutable Objects to an Untrusted Method (CWE-374) is a type of security vulnerability that occurs when non-cloned mutable data is sent as an argument to a method or function, potentially allowing another function to tamper with it.

Why it matters: This vulnerability can lead to modification of memory, which can result in data tampering and other security issues. It is essential to prevent this vulnerability by using secure coding practices and passing immutable data instead of mutable data.

Where it occurs: This vulnerability can occur in any application that sends non-cloned mutable data as an argument to a method or function.

Who is affected: Any user who interacts with the vulnerable application may be affected by this vulnerability.

Who is NOT affected: Users who do not interact with the vulnerable application are not affected by this vulnerability.

How Passing Mutable Objects to an Untrusted Method Works

Root Cause

The root cause of this vulnerability is the passing of non-cloned mutable data as an argument to a method or function, potentially allowing another function to tamper with it.

Attack Flow

  1. The attacker sends a request to the vulnerable application.
  2. The vulnerable application receives the request and passes the non-cloned mutable data as an argument to a method or function.
  3. The method or function modifies the memory, potentially leading to data tampering and other security issues.

Prerequisites to Exploit

  • The attacker must be able to send a request to the vulnerable application.
  • The vulnerable application must pass non-cloned mutable data as an argument to a method or function.

Vulnerable Code

def vulnerable_function(data):
    # This code is vulnerable because it passes non-cloned mutable data as an argument to a method or function.
    other_function(data)

Secure Code

def secure_function(data):
    # This code is secure because it clones the mutable data before passing it to another function.
    cloned_data = data.copy()
    other_function(cloned_data)

Business Impact of Passing Mutable Objects to an Untrusted Method

Confidentiality: The confidentiality of sensitive data may be compromised if the vulnerable application passes non-cloned mutable data as an argument to a method or function.

  • Data tampering: An attacker may modify the memory, potentially leading to data tampering and other security issues.
  • Unauthorized access: An attacker may gain unauthorized access to sensitive data.

Integrity: The integrity of sensitive data may be compromised if the vulnerable application passes non-cloned mutable data as an argument to a method or function.

  • Data modification: An attacker may modify the memory, potentially leading to data tampering and other security issues.
  • Unauthorized changes: An attacker may make unauthorized changes to sensitive data.

Availability: The availability of sensitive data may be compromised if the vulnerable application passes non-cloned mutable data as an argument to a method or function.

  • Data loss: An attacker may delete or modify sensitive data, potentially leading to data loss and other security issues.
  • Downtime: A vulnerable application may experience downtime due to repeated attacks.

Passing Mutable Objects to an Untrusted Method Attack Scenario

  1. The attacker sends a request to the vulnerable application.
  2. The vulnerable application receives the request and passes the non-cloned mutable data as an argument to a method or function.
  3. The method or function modifies the memory, potentially leading to data tampering and other security issues.

How to Detect Passing Mutable Objects to an Untrusted Method

Manual Testing

  • Review the code for potential vulnerabilities.
  • Test the application with malicious input to identify potential vulnerabilities.

Automated Scanners (SAST/DAST)

  • Use automated scanners to identify potential vulnerabilities in the code.
  • These scanners can help identify potential CWE-374 vulnerabilities.

PenScan Detection

  • PenScan’s scanner engines actively test for this issue and provide detailed reports on potential vulnerabilities.

False Positive Guidance

  • Be cautious when interpreting results from automated scanners, as false positives may occur.
  • Review the code manually to confirm any identified vulnerabilities.

How to Fix Passing Mutable Objects to an Untrusted Method

  • Clone mutable data before passing it to an external function or use immutable data instead of mutable data.
  • Use secure coding practices to prevent CWE-374 vulnerabilities.

Framework-Specific Fixes for Passing Mutable Objects to an Untrusted Method

Java

public void secureFunction(List<String> data) {
    List<String> clonedData = new ArrayList<>(data);
    otherFunction(clonedData);
}

Node.js

function secureFunction(data) {
    const clonedData = [...data];
    otherFunction(clonedData);
}

Python/Django

def secure_function(data):
    cloned_data = data.copy()
    other_function(cloned_data)

How to Ask AI to Check Your Code for Passing Mutable Objects to an Untrusted Method

You can use a copy-pasteable prompt with an AI coding assistant to review your code and identify potential CWE-374 vulnerabilities.

Copy-paste prompt

Review the following [language] code block for potential CWE-374 Passing Mutable Objects to an Untrusted Method vulnerabilities and rewrite it using cloning mutable data before passing it to an external function:

...

Passing Mutable Objects to an Untrusted Method Best Practices Checklist

✅ Clone mutable data before passing it to an external function. ✅ Use immutable data instead of mutable data. ✅ Review the code for potential CWE-374 vulnerabilities. ✅ Test the application with malicious input to identify potential CWE-374 vulnerabilities.

Passing Mutable Objects to an Untrusted Method FAQ

How do I define Passing Mutable Objects to an Untrusted Method?

Passing Mutable Objects to an Untrusted Method (CWE-374) is a type of security vulnerability that occurs when non-cloned mutable data is sent as an argument to a method or function, potentially allowing another function to tamper with it.

What are the potential consequences of passing mutable objects to an untrusted method?

The potential consequences include modification of memory, which can lead to data tampering and other security issues.

How do I detect Passing Mutable Objects to an Untrusted Method in my code?

You can use manual testing, automated scanners (SAST/DAST), or PenScan’s detection capabilities to identify this vulnerability.

What are the best practices for preventing Passing Mutable Objects to an Untrusted Method?

The best practices include passing immutable data instead of mutable data, cloning mutable data before passing it to an external function, and using secure coding practices.

Can you provide some examples of vulnerable code that demonstrates Passing Mutable Objects to an Untrusted Method?

Yes, we can provide some examples in the “How Passing Mutable Objects to an Untrusted Method Works” section below.

How do I ask AI to check my code for Passing Mutable Objects to an Untrusted Method vulnerabilities?

You can use a copy-pasteable prompt with an AI coding assistant to review your code and identify potential CWE-374 vulnerabilities.

What are some common mistakes that can lead to Passing Mutable Objects to an Untrusted Method vulnerabilities?

Some common mistakes include passing mutable data instead of immutable data, not cloning mutable data before passing it to an external function, and using insecure coding practices.

CWE Name Relationship
CWE-668 Exposure of Resource to Wrong Sphere ChildOf

References

Scan Your Own Site

Manual code review catches what you know to look for. An automated scan catches what you didn’t. Scan your own website using PenScan to find Passing Mutable Objects to an Untrusted Method and other risks before an attacker does.