Every serializable class that has private
mutable instance variables must defensively copy them in the readObject()
method. An adversary attacker can tamper with the serialized form of such a class, appending extra references to the byte stream. When deserialized, this byte stream could allow the creation of a class instance whose internal variable references are controlled by the attacker. Consequently, this allows the instance of the container class to mutate and violate its class invariants.
...