Description
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.
Potential Impact
Confidentiality
Read Application Data
Demonstrative Examples
class PatientRecord {private String name;private String socialSecurityNum;public Patient(String name,String ssn) {this.SetName(name);this.SetSocialSecurityNumber(ssn);}}Mitigations & Prevention
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.
Make sure to prevent serialization of your objects.
Detection Methods
- Automated Static Analysis High — Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then sea
Related Weaknesses
Taxonomy Mappings
- 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
Frequently Asked Questions
What is CWE-499?
CWE-499 (Serializable Class Containing Sensitive Data) is a software weakness identified by MITRE's Common Weakness Enumeration. It is classified as a Variant-level weakness. 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.
How can CWE-499 be exploited?
Attackers can exploit CWE-499 (Serializable Class Containing Sensitive Data) to read application data. This weakness is typically introduced during the Implementation phase of software development.
How do I prevent CWE-499?
Key mitigations include: 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.
What is the severity of CWE-499?
CWE-499 is classified as a Variant-level weakness (Low-Medium abstraction). Its actual severity depends on the specific context and how the weakness manifests in your application.