You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow serialise/deserialise only specific classes - whitelisting #1866
As discussed in #1296 it would be good to allow define a whitelist with allowed classes that can be serialised/deserialised. This gives more control to the users and allows avoid any possible RCE attacks.
Reacted by Raul Santelices, Jericho, Yann Massard, ZanSara, Artem Smotrakov and Alexandre Gallice
I suspect that a simple "provide a white-list of all classes" approach is impractical for most users: there are plenty of types already in JDK. But perhaps ability to specify a class/class-name validator (serialization / deserialization) validation, similar to:
would make sense?
In fact, perhaps that issue could be generalized to apply to all cases, not just polymorphic handling.
Come to think of this it seems unlikely that applying it for all values, even with explicit types defined (as property type or annotation) or passed (as target type argument), would cause problems.
I think any of these will work, giving users an ability to control if a given class can be serialised/deserialised allows to build a whitelist anyway :)
True. And one more thought I had: if the check is only made when a new "POJO" (de)serializer is needed, it would not even apply to "standard" types, for which (de)serializer is already found.
This would mean, for example, that Enums are fine, arrays (element handlers are separate), numbers and so on. The only (?) possible concern would be tag types like Iterator.
So whatever validator was used could perhaps have couple of different methods, called at different points. Maybe some of these:
Class name (String) to Class lookup: could even block this just in case a security flaw only required loading of the class
Use of Class for polymorphic case (could block or change)
Actual use for serializer/deserializer access (before any lookups) -- applies to each and every type
Use for "POJO" (aka bean) (de)serializer: only applicable if no standard impl (enum, array, Map, Collection, reference; well-known JDK types; 3rd party types via modules) found
For security purposes, (4) probably really covers most if not all cases. And then user would only need to whitelist actual POJOs, and even those could be annotation based (i.e. user or 3rd party lib/framework defines tag annotation(s) to use, validator can look for that).
@cowtowncoder If I understand correctly this issue (implementing whitelisting) is targeted only to 3.x, and the implementation of the whitelist depends on #2195. I have two questions:
Is there any plan to backport it to 2.x? I think it would be good to have whitelisting in 2.x as well.
Implementation of #2195 is targeted for 2.10; I originally was thinking 3.x but I think it can't really wait that far.
I appreciate your offer to help, but unfortunately limit I have is time, not idea of how to implement this. So I don't think this is something that I can effectively parallelize until I get something working.
However, as soon as I have some pieces scoped I could definitely use help in validating my design and feedback like improvement suggestions.
@lukaszlenart@artem-smotrakov just a quick note: finally implemented most of #2195 so looking for feedback soon. I am reasonably content at design but hoping others to poke holes in it.
@lukaszlenart No, it's still work-in-progress. It will be in 2.10.0; being API addition won't be backported.
But hoping to get the first pre-release (2.10.0.pr1) out within May 2019.
Is there any ETA on this? It looks like there is going to be a continuous stream of CVEs to blacklist classes. The codehaus jackson added a whitelist which protects against any new classes from needing to be blacklisted and also lets the applications know and allow the classes to be deserialized.
@bmaxwell This was implemented via #2195 included in 2.10.0 (which was released 1 week ago) so closing this as dup. Overview of new features, including this one at
Activity
cowtowncoder commentedon Jan 3, 2018
I suspect that a simple "provide a white-list of all classes" approach is impractical for most users: there are plenty of types already in JDK. But perhaps ability to specify a class/class-name validator (serialization / deserialization) validation, similar to:
FasterXML/jackson3-dev#21
would make sense?
In fact, perhaps that issue could be generalized to apply to all cases, not just polymorphic handling.
Come to think of this it seems unlikely that applying it for all values, even with explicit types defined (as property type or annotation) or passed (as target type argument), would cause problems.
EDIT: implemented as #2195, included in 2.10.0.
lukaszlenart commentedon Jan 3, 2018
I think any of these will work, giving users an ability to control if a given class can be serialised/deserialised allows to build a whitelist anyway :)
cowtowncoder commentedon Jan 3, 2018
True. And one more thought I had: if the check is only made when a new "POJO" (de)serializer is needed, it would not even apply to "standard" types, for which (de)serializer is already found.
This would mean, for example, that Enums are fine, arrays (element handlers are separate), numbers and so on. The only (?) possible concern would be
tagtypes likeIterator.So whatever validator was used could perhaps have couple of different methods, called at different points. Maybe some of these:
Classlookup: could even block this just in case a security flaw only required loading of the classClassfor polymorphic case (could block or change)For security purposes, (4) probably really covers most if not all cases. And then user would only need to whitelist actual POJOs, and even those could be annotation based (i.e. user or 3rd party lib/framework defines tag annotation(s) to use, validator can look for that).
lukaszlenart commentedon Jan 4, 2018
nice 💯
artem-smotrakov commentedon Apr 10, 2019
@cowtowncoder If I understand correctly this issue (implementing whitelisting) is targeted only to 3.x, and the implementation of the whitelist depends on #2195. I have two questions:
PolymorphicTypeValidator, for limiting subtypes allowed by default typing,@JsonTypeInfo#2195? I can offer some help.cowtowncoder commentedon Apr 18, 2019
Implementation of #2195 is targeted for 2.10; I originally was thinking 3.x but I think it can't really wait that far.
I appreciate your offer to help, but unfortunately limit I have is time, not idea of how to implement this. So I don't think this is something that I can effectively parallelize until I get something working.
However, as soon as I have some pieces scoped I could definitely use help in validating my design and feedback like improvement suggestions.
cowtowncoder commentedon May 2, 2019
@lukaszlenart @artem-smotrakov just a quick note: finally implemented most of #2195 so looking for feedback soon. I am reasonably content at design but hoping others to poke holes in it.
lukaszlenart commentedon May 6, 2019
Nice, thanks a lot @cowtowncoder :) Is this already included in a released version?
cowtowncoder commentedon May 6, 2019
@lukaszlenart No, it's still work-in-progress. It will be in 2.10.0; being API addition won't be backported.
But hoping to get the first pre-release (2.10.0.pr1) out within May 2019.
lukaszlenart commentedon May 7, 2019
Great!
bmaxwell commentedon Oct 7, 2019
Is there any ETA on this? It looks like there is going to be a continuous stream of CVEs to blacklist classes. The codehaus jackson added a whitelist which protects against any new classes from needing to be blacklisted and also lets the applications know and allow the classes to be deserialized.
cowtowncoder commentedon Oct 7, 2019
@bmaxwell This was implemented via #2195 included in 2.10.0 (which was released 1 week ago) so closing this as dup. Overview of new features, including this one at
https://medium.com/@cowtowncoder/jackson-2-10-features-cd880674d8a2
but I hope to find time to blog about Safe Default Typing feature in bit more detail.