CWE-499: Serializable Class Containing Sensitive Data
Serializable Class Containing Sensitive Data
Weakness ID: 499 (Weakness Variant)
Status: Draft
Description
Description Summary
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.
Extended Description
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.
Time of Introduction
Implementation
Applicable Platforms
Languages
Java
Common Consequences
Scope
Effect
Confidentiality
an attacker can write out the class to a byte stream, then extract the
important data from it.
Likelihood of Exploit
High
Demonstrative Examples
Example 1
(Bad Code)
Java
class Teacher {
private String name;
private String clas;
public Teacher(String name,String clas) {
//...
//Check the database for the name and address
this.SetName() = name;
this.Setclas() = clas;
}
}
Potential Mitigations
Phase
Description
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.