-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add abstraction for ClassNameValidator
, for default typing, @JsonTypeInfo
#21
Comments
I think we should also provide a way to supply a white list, in addition to a blacklist. Similar to the JEP-290 approach for the JDK. |
@jasinner it might be possible to add a default implementation that could do that. I am bit ambivalent on white-listing because it seems to go against the only real use case for default typing -- that is, open-ended "support anything" functionality -- and it seems to me that instead of white-listing, one should just use explicit base class other than Having said that I am not against adding functionality, or at very least making it easy to implement. |
Move to: FasterXML/jackson-databind#2195 |
Due to multiple CVEs for possible exploits via "default typing" (or,
@JsonTypeInfo
with base type ofjava.lang.Object
) AND a small set of common "serialization gadgets", we have added blacklist of such gadgets. Blacklist is a moving target, with steady trickle of new types, and fundamentally can never be 100% complete.Inclusion of black list is then problematic in a few ways:
jackson-databind
(for now at least), update requires new release, update by app/service developersAs to (3), it is worth noting that:
BeanDeserializerFactory
(used by databind itself for applying blacklist)Module
(beforeDeserializerFactory
is invoked)com.fasterxml.jackson.databind.jsontype.impl.ClassNameIdResolver
, even before deserializer, when resolving polymorphic type id as a classcan all be used for protection; but are either not module (sub-classing of deserializer factory), or otherwise cumbersome (module, type id resolver).
But it should be possible to take another approach: define a new small handler API, to be invoked when:
This would allow many things, like:
one use of which is security check.
Callback(s) could then:
In theory it might even be possible to perhaps allow some special handling like "always deserialize as null"; but at this point this is speculation.
After defining such handler interface, it should be applied in two ways:
@JsonTypeInfo
approach, a new property, with default choice, should suffice. Here defaulting should be ok since exploit only applies to case ofjava.lang.Object
(and perhapsjava.io.Serializable
,java.util.Comparable
?)java.lang.Object
et al?and then polymorphic handler would need to be passed validator to use.
Net effect of this would be to allow finer-grained control of blocking certain types from polymorphic handling (esp. deserialization).
The text was updated successfully, but these errors were encountered: