CWE-499 可序列化的类中包含敏感信息

Serializable Class Containing Sensitive Data

结构: Simple

Abstraction: Variant

状态: Draft

被利用可能性: High

基本描述

The code contains a class with sensitive data, but the class does not explicitly deny serialization. The data can be accessed by serializing the class through another class.

扩展描述

Serializable classes are effectively open classes since data cannot be hidden in them. Classes that do not explicitly deny serialization can be serialized by any other class, which can then in turn use the data stored inside it.

相关缺陷

  • cwe_Nature: ChildOf cwe_CWE_ID: 664 cwe_View_ID: 1000 cwe_Ordinal: Primary

  • cwe_Nature: CanPrecede cwe_CWE_ID: 200 cwe_View_ID: 1000

  • cwe_Nature: CanPrecede cwe_CWE_ID: 200 cwe_View_ID: 699

适用平台

Language: {'cwe_Name': 'Java', 'cwe_Prevalence': 'Undetermined'}

常见的影响

范围 影响 注释
Confidentiality Read Application Data an attacker can write out the class to a byte stream, then extract the important data from it.

可能的缓解方案

Implementation

策略:

In Java, explicitly define final writeObject() to prevent serialization. This is the recommended solution. Define the writeObject() function to throw an exception explicitly denying serialization.

Implementation

策略:

Make sure to prevent serialization of your objects.

示例代码

This code creates a new record for a medical patient:

bad Java

class PatientRecord {
private String name;
private String socialSecurityNum;
public Patient(String name,String ssn) {
this.SetName(name);
this.SetSocialSecurityNumber(ssn);
}
}

This object does not explicitly deny serialization, allowing an attacker to serialize an instance of this object and gain a patient's name and Social Security number even though those fields are private.

分类映射

映射的分类名 ImNode ID Fit Mapped Node Name
CLASP Information leak through serialization
The CERT Oracle Secure Coding Standard for Java (2011) SER03-J Do not serialize unencrypted, sensitive data
The CERT Oracle Secure Coding Standard for Java (2011) SER05-J Do not serialize instances of inner classes
Software Fault Patterns SFP23 Exposed Data