diff --git a/java/ql/src/Security/CWE/CWE-502/UnsafeDeserialization.qhelp b/java/ql/src/Security/CWE/CWE-502/UnsafeDeserialization.qhelp index d1933ad4ac25..6806527e442d 100644 --- a/java/ql/src/Security/CWE/CWE-502/UnsafeDeserialization.qhelp +++ b/java/ql/src/Security/CWE/CWE-502/UnsafeDeserialization.qhelp @@ -28,11 +28,52 @@ for example JSON or XML. However, these formats should not be deserialized into complex objects because this provides further opportunities for attack. For example, XML-based deserialization attacks are possible through libraries such as XStream and XmlDecoder. - +
+Alternatively, a tightly controlled whitelist can limit the vulnerability of code, but be aware of the existence of so-called Bypass Gadgets, which can circumvent such protection measures.
++Recommendations specific to particular frameworks supported by this query: +
+FastJson - com.alibaba:fastjson
com.alibaba.fastjson.parser.ParserConfig#setSafeMode
with the argument true
before deserializing untrusted data.FasterXML - com.fasterxml.jackson.core:jackson-databind
com.fasterxml.jackson.databind.ObjectMapper#enableDefaultTyping
and don't annotate any object fields with com.fasterxml.jackson.annotation.JsonTypeInfo
passing either the CLASS
or MINIMAL_CLASS
values to the annotation.
+ Read this guide.Kryo - com.esotericsoftware:kryo
and com.esotericsoftware:kryo5
com.esotericsoftware:kryo5
and for com.esotericsoftware:kryo
>= v5.0.0com.esotericsoftware.kryo(5).Kryo#setRegistrationRequired
with the argument false
on any Kryo
instance that may deserialize untrusted data.ObjectInputStream - Java Standard Library
org.apache.commons.io.serialization.ValidatingObjectInputStream
.SnakeYAML - org.yaml:snakeyaml
org.yaml.snakeyaml.constructor.SafeConstructor
to org.yaml.snakeyaml.Yaml
's constructor before using it to deserialize untrusted data.XML Decoder - Standard Java Library