CWE-374: Passing Mutable Objects to an Untrusted Method
CWE版本: 4.18
更新日期: 2025-09-09
弱点描述
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.
常见后果
影响范围: Integrity
技术影响: Modify Memory
说明: Potentially data could be tampered with by another function which should not have been tampered with.
潜在缓解措施
阶段: 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.
引入模式
| 阶段 | 说明 |
|---|---|
| Implementation | - |
适用平台
编程语言
分类映射
| 分类名称 | 条目ID | 条目名称 | 映射适配度 |
|---|---|---|---|
| CLASP | - | Passing mutable objects to an untrusted method | - |
| The CERT Oracle Secure Coding Standard for Java (2011) | OBJ04-J | Provide mutable classes with copy functionality to safely allow passing instances to untrusted code | - |
| Software Fault Patterns | SFP23 | Exposed Data | - |