The vulnerability is a bypass of the PolymorphicTypeValidator (PTV) in jackson-databind, which is used to prevent deserialization of untrusted data. The analysis of the patch reveals two key weaknesses that contribute to this bypass.
The primary issue lies in the com.fasterxml.jackson.databind.DatabindContext._resolveAndValidateGeneric method. Before the fix, this method would only validate the top-level class of a generic type string. For a type like java.util.ArrayList<com.evil.Gadget>, it would correctly validate java.util.ArrayList against the PTV, but it would completely ignore the com.evil.Gadget type parameter. The patch rectifies this by introducing a new recursive helper method, _validateTypeParameter, which is called to validate each generic type parameter and array element type, ensuring all parts of the type signature are checked against the PTV.
Secondly, a related flaw existed in com.fasterxml.jackson.databind.jsontype.BasicPolymorphicTypeValidator.validateSubType. This method did not correctly apply name-based PTV rules (e.g., allowIfSubType("com.example.")) to the element types of arrays. This meant that even if the validation was called for an array's element type, it would fail to apply the intended name-based policies. The patch corrects this by explicitly calling validateSubClassName for the array's element type, ensuring name-based rules are enforced.
An attacker can exploit these flaws by crafting a JSON payload with a malicious type identifier. This identifier would use an allowed class (like java.util.ArrayList) as a container for a denied gadget class, either as a generic type parameter or as an array element type. This would bypass the PTV checks, leading to the deserialization and instantiation of the malicious gadget, which could result in arbitrary code execution.