The vulnerability exists in BasicPolymorphicTypeValidator and is caused by an incomplete check when array subtypes are allowed. The Builder.allowIfSubTypeIsArray() method originally added a rule that approved any class that is an array, without inspecting the array's element type. This created a security bypass.
During deserialization, the validateSubType method would use this rule and incorrectly approve a malicious type if it was wrapped in an array (e.g., EvilGadget[]). Jackson would then proceed to instantiate the elements of the array, bypassing the intended security validation and leading to the instantiation of non-allowlisted "gadget" types.
The patch rectifies this by modifying allowIfSubTypeIsArray() to simply set a flag. The validateSubType method is then enhanced to check for this flag. When the flag is active and an array type is encountered, validateSubType now recursively unwraps the array down to its innermost non-array element type and performs the validation against that element type. This ensures that the component type of an array is properly validated against the configured security policy, closing the vulnerability.