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

Base Draft Simple

CWE版本: 4.18

更新日期: 2025-09-09

弱点描述

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

扩展描述

In situations where functions return references to mutable data, it is possible that the external code which called the function may make changes to the data sent. If this data was not previously cloned, the class will then be using modified data which may violate assumptions about its internal state.

常见后果

影响范围: Access Control Integrity

技术影响: Modify Memory

说明: Potentially data could be tampered with by another function which should not have been tampered with.

潜在缓解措施

阶段: 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.

引入模式

阶段 说明
Implementation -

适用平台

编程语言
C (Undetermined) C++ (Undetermined) Java (Undetermined) C# (Undetermined)

分类映射

分类名称 条目ID 条目名称 映射适配度
CLASP - Mutable object returned -
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 -
The CERT Oracle Secure Coding Standard for Java (2011) OBJ05-J Defensively copy private mutable class members before returning their references -
SEI CERT Perl Coding Standard EXP34-PL Do not modify $_ in list or sorting functions Imprecise
Software Fault Patterns SFP23 Exposed Data -
关键信息

CWE ID: CWE-375

抽象级别: Base

结构: Simple

状态: Draft

利用可能性: Medium

相关弱点