This vulnerability occurs when a class exposes a public or protected static final field that points to a changeable object. Because the field's reference is constant but the object itself is not, malicious code or even accidental code in other packages can modify the object's contents, violating the intended immutability.
The core issue is a misunderstanding of the `final` keyword in Java and similar languages. When applied to an object reference, `final` only guarantees that the reference itself cannot be reassigned to point to a different object. It does not protect the internal state of the object that the reference points to. If that object is mutable—like an array, a collection, or a custom class with public setters—its data can be freely altered, even through the `static final` field. To prevent this, developers must ensure true immutability. This involves either assigning the static final field to an inherently immutable object (like a `String` or a boxed primitive) or defensively wrapping mutable objects. For collections, use `Collections.unmodifiableList()`, `Map.copyOf()`, or similar methods to create an unmodifiable view or a deep copy before assignment. This practice encapsulates the mutable data and enforces the read-only intent of the public static field.
Impact: Modify Application Data
java