CWE-374: Passing Mutable Objects to an Untrusted Method

BaseDraftExploit Likelihood: Medium

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

View on MITRE
Back to CWE Lookup

Extended Description

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.

Technical Details

Structure
Simple

Applicable To

Languages
CC++JavaC#
Platforms

Frequently Asked Questions

What is CWE-374: Passing Mutable Objects to an Untrusted Method?+

CWE-374: Passing Mutable Objects to an Untrusted Method is a Common Weakness Enumeration (CWE) entry maintained by MITRE. The product sends non-cloned mutable data as an argument to a method or function. 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.

What are the security consequences of Passing Mutable Objects to an Untrusted Method?+

If exploited, CWE-374 (Passing Mutable Objects to an Untrusted Method) it can compromise Integrity, leading to outcomes such as Modify Memory.

How do you prevent or mitigate Passing Mutable Objects to an Untrusted Method?+

Recommended mitigations for CWE-374 include: Pass in data which should not be altered as constant or immutable. 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.

Which programming languages are affected by Passing Mutable Objects to an Untrusted Method?+

CWE-374 commonly affects C, C++, Java and C#. Note that weaknesses are often language-agnostic patterns, so secure coding practices apply broadly.

What is the difference between a CWE and a CVE?+

A CWE (Common Weakness Enumeration) like CWE-374 describes a category of software weakness — the underlying flaw type. A CVE (Common Vulnerabilities and Exposures) identifies a specific, real-world vulnerability in a particular product. In short, a CWE is the kind of mistake, and a CVE is an instance of that mistake being found in software.

Learn More

CWE-374: Passing Mutable Objects to an Untrusted Method | CWE Lookup | InventiveHQ