Serialization of inner classes (including local and anonymous classes) is error prone. The following postulates have been reproduced from \[[Sun 06|AA. Java References#Sun 06]\], Serialization specification: |
None of the issues listed above, however, apply to static member classes.
In this non compliant code example, the fields contained within the outer class are also serialized when the inner class is serialized.
public class OuterSer implements Serializable {
private int ssn;
class InnerSer implements Serializable {
protected String name;
//...
}
}
|
Attempting to serialize inner classes can cause instances of the outer class to be serialized and also discourage platform independence.
Rule |
Severity |
Likelihood |
Remediation Cost |
Priority |
Level |
|---|---|---|---|---|---|
SER33-J |
medium |
unlikely |
low |
P6 |
L2 |
TODO
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
\[[API 06|AA. Java References#API 06]\] \[[Sun 06|AA. Java References#Sun 06]\] "Serialization specification: \[[Bloch 08|AA. Java References#Bloch 08]\] Item 74: "Implement serialization judiciously" |
SER32-J. Do not allow serialization and deserialization to bypass the Security Manager 11. Serialization (SER) 11. Serialization (SER)