...
In this noncompliant example, security manager checks are used within the constructor but are not replicated throughout, specifically, within the readObject
and writeObject
methods that are used in the serialization-deserialization process. This allows an attacker to maliciously create instances of the class that bypass security manager checks when deserialization is performed.
...
The compliant solution correctly implements security manager checks in all constructors, methods that can modify internal state and methods that retrieve internal state. As a result, an attacker cannot create an instance of the object with modified state (using deserialization) and cannot simply or read the serialized byte stream to uncover sensitive data (using serialization).
...