|
12 | 12 | import com.fasterxml.jackson.databind.deser.std.ThrowableDeserializer; |
13 | 13 | import com.fasterxml.jackson.databind.introspect.*; |
14 | 14 | import com.fasterxml.jackson.databind.jsontype.TypeDeserializer; |
| 15 | +import com.fasterxml.jackson.databind.jsontype.impl.SubTypeValidator; |
15 | 16 | import com.fasterxml.jackson.databind.util.ArrayBuilders; |
16 | 17 | import com.fasterxml.jackson.databind.util.ClassUtil; |
17 | 18 | import com.fasterxml.jackson.databind.util.SimpleBeanPropertyDefinition; |
@@ -40,44 +41,6 @@ public class BeanDeserializerFactory |
40 | 41 |
|
41 | 42 | private final static Class<?>[] NO_VIEWS = new Class<?>[0]; |
42 | 43 |
|
43 | | - /** |
44 | | - * Set of well-known "nasty classes", deserialization of which is considered dangerous |
45 | | - * and should (and is) prevented by default. |
46 | | - */ |
47 | | - protected final static Set<String> DEFAULT_NO_DESER_CLASS_NAMES; |
48 | | - static { |
49 | | - Set<String> s = new HashSet<String>(); |
50 | | - // Courtesy of [https://github.com/kantega/notsoserial]: |
51 | | - // (and wrt [databind#1599]) |
52 | | - s.add("org.apache.commons.collections.functors.InvokerTransformer"); |
53 | | - s.add("org.apache.commons.collections.functors.InstantiateTransformer"); |
54 | | - s.add("org.apache.commons.collections4.functors.InvokerTransformer"); |
55 | | - s.add("org.apache.commons.collections4.functors.InstantiateTransformer"); |
56 | | - s.add("org.codehaus.groovy.runtime.ConvertedClosure"); |
57 | | - s.add("org.codehaus.groovy.runtime.MethodClosure"); |
58 | | - s.add("org.springframework.beans.factory.ObjectFactory"); |
59 | | - s.add("com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl"); |
60 | | - s.add("org.apache.xalan.xsltc.trax.TemplatesImpl"); |
61 | | - // [databind#1680]: may or may not be problem, take no chance |
62 | | - s.add("com.sun.rowset.JdbcRowSetImpl"); |
63 | | - // [databind#1737]; JDK provided |
64 | | - s.add("java.util.logging.FileHandler"); |
65 | | - s.add("java.rmi.server.UnicastRemoteObject"); |
66 | | - // [databind#1737]; 3rd party |
67 | | - s.add("org.springframework.aop.support.AbstractBeanFactoryPointcutAdvisor"); |
68 | | - s.add("org.springframework.beans.factory.config.PropertyPathFactoryBean"); |
69 | | - s.add("com.mchange.v2.c3p0.JndiRefForwardingDataSource"); |
70 | | - s.add("com.mchange.v2.c3p0.WrapperConnectionPoolDataSource"); |
71 | | - // [databind#1855]: more 3rd party |
72 | | - s.add("org.apache.tomcat.dbcp.dbcp2.BasicDataSource"); |
73 | | - s.add("com.sun.org.apache.bcel.internal.util.ClassLoader"); |
74 | | - DEFAULT_NO_DESER_CLASS_NAMES = Collections.unmodifiableSet(s); |
75 | | - } |
76 | | - |
77 | | - /** |
78 | | - * Set of class names of types that are never to be deserialized. |
79 | | - */ |
80 | | - protected Set<String> _cfgIllegalClassNames = DEFAULT_NO_DESER_CLASS_NAMES; |
81 | 44 |
|
82 | 45 | /* |
83 | 46 | /********************************************************** |
@@ -179,7 +142,7 @@ public JsonDeserializer<Object> createBeanDeserializer(DeserializationContext ct |
179 | 142 | return null; |
180 | 143 | } |
181 | 144 | // For checks like [databind#1599] |
182 | | - checkIllegalTypes(ctxt, type, beanDesc); |
| 145 | + _validateSubType(ctxt, type, beanDesc); |
183 | 146 | // Use generic bean introspection to build deserializer |
184 | 147 | return buildBeanDeserializer(ctxt, type, beanDesc); |
185 | 148 | } |
@@ -877,19 +840,12 @@ protected boolean isIgnorableType(DeserializationConfig config, BeanDescription |
877 | 840 | } |
878 | 841 |
|
879 | 842 | /** |
880 | | - * @since 2.8.9 |
| 843 | + * @since 2.8.11 |
881 | 844 | */ |
882 | | - protected void checkIllegalTypes(DeserializationContext ctxt, JavaType type, |
| 845 | + protected void _validateSubType(DeserializationContext ctxt, JavaType type, |
883 | 846 | BeanDescription beanDesc) |
884 | 847 | throws JsonMappingException |
885 | 848 | { |
886 | | - // There are certain nasty classes that could cause problems, mostly |
887 | | - // via default typing -- catch them here. |
888 | | - String full = type.getRawClass().getName(); |
889 | | - |
890 | | - if (_cfgIllegalClassNames.contains(full)) { |
891 | | - throw JsonMappingException.from(ctxt, |
892 | | - String.format("Illegal type (%s) to deserialize: prevented for security reasons", full)); |
893 | | - } |
| 849 | + SubTypeValidator.instance().validateSubType(ctxt, type); |
894 | 850 | } |
895 | 851 | } |
0 commit comments