Skip to content

Commit b7364f5

Browse files
atorralbaJLLeitschuh
authored andcommitted
Update UnsafeDeserialization.qhelp
Move the table under <recommendation>, minor fixes.
1 parent 3fa11c2 commit b7364f5

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

java/ql/src/Security/CWE/CWE-502/UnsafeDeserialization.qhelp

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -28,37 +28,20 @@ for example JSON or XML. However, these formats should not be deserialized
2828
into complex objects because this provides further opportunities for attack.
2929
For example, XML-based deserialization attacks
3030
are possible through libraries such as XStream and XmlDecoder.
31-
31+
</p>
32+
<p>
3233
Alternatively, a tightly controlled whitelist can limit the vulnerability of code, but be aware
3334
of the existence of so-called Bypass Gadgets, which can circumvent such
3435
protection measures.
3536
</p>
36-
</recommendation>
37-
38-
<example>
3937
<p>
40-
The following example calls <code>readObject</code> directly on an
41-
<code>ObjectInputStream</code> that is constructed from untrusted data, and is
42-
therefore inherently unsafe.
38+
Fixes by framework:
4339
</p>
44-
<sample src="UnsafeDeserializationBad.java" />
45-
46-
<p>
47-
Rewriting the communication protocol to only rely on reading primitive types
48-
from the input stream removes the vulnerability.
49-
</p>
50-
<sample src="UnsafeDeserializationGood.java" />
51-
52-
</example>
53-
54-
<p>
55-
56-
Fixes by framework
5740
<table>
5841
<tbody>
5942
<tr>
6043
<th>Project</th>
61-
<th>Maven Cordinates</th>
44+
<th>Maven Coordinates</th>
6245
<th>Secure by Default</th>
6346
<th>Fix</th>
6447
</tr>
@@ -72,18 +55,18 @@ Fixes by framework
7255
<td>ObjectInputStream</td>
7356
<td>Java Standard Library</td>
7457
<td>No</td>
75-
<td>Leverage a validating input stream like <code>org.apache.commons.io.serialization.ValidatingObjectInputStream</code></td>
58+
<td>Leverage a validating input stream like <code>org.apache.commons.io.serialization.ValidatingObjectInputStream</code>.</td>
7659
</tr>
7760
<tr>
7861
<td>FastJson</td>
7962
<td>com.alibaba:fastjson</td>
8063
<td>Partially</td>
81-
<td>Call <code>com.alibaba.fastjson.parser.ParserConfig#setSafeMode</code> with the argument <code>true</code></td>
64+
<td>Call <code>com.alibaba.fastjson.parser.ParserConfig#setSafeMode</code> with the argument <code>true</code>.</td>
8265
</tr>
8366
<tr>
8467
<td>SnakeYAML</td>
8568
<td>org.yaml:snakeyaml</td>
86-
<td><a href="https://bitbucket.org/snakeyaml/snakeyaml/wiki/CVE%20&amp;%20NIST.md">No</a>. <a href="https://bitbucket.org/snakeyaml/snakeyaml/issues/561/cve-2022-1471-vulnerability-in">Maintainer response</a>.</td>
69+
<td><a href="https://bitbucket.org/snakeyaml/snakeyaml/wiki/CVE%20&amp;%20NIST.md">No</a> (<a href="https://bitbucket.org/snakeyaml/snakeyaml/issues/561/cve-2022-1471-vulnerability-in">maintainer response</a>)</td>
8770
<td>Instantiate the <code>org.yaml.snakeyaml.Yaml</code> instance explicitly with an instance of <code>org.yaml.snakeyaml.constructor.SafeConstructor</code> as an argument.</td>
8871
</tr>
8972
<tr>
@@ -98,11 +81,28 @@ Fixes by framework
9881
<tr>
9982
<td>Kryo</td>
10083
<td>com.esotericsoftware:kryo and com.esotericsoftware:kryo5</td>
101-
<td>com.esotericsoftware:kryo versions including &amp; after 5.0.0 Yes; com.esotericsoftware:kryo5 Yes</td>
84+
<td>com.esotericsoftware:kryo >= 5.0.0 and com.esotericsoftware:kryo5 Yes</td>
10285
<td>Don't call <code>com.esotericsoftware.kryo(5).Kryo#setRegistrationRequired</code> with the argument <code>false</code>.</td>
10386
</tr>
10487
</tbody>
10588
</table>
89+
</recommendation>
90+
91+
<example>
92+
<p>
93+
The following example calls <code>readObject</code> directly on an
94+
<code>ObjectInputStream</code> that is constructed from untrusted data, and is
95+
therefore inherently unsafe.
96+
</p>
97+
<sample src="UnsafeDeserializationBad.java" />
98+
99+
<p>
100+
Rewriting the communication protocol to only rely on reading primitive types
101+
from the input stream removes the vulnerability.
102+
</p>
103+
<sample src="UnsafeDeserializationGood.java" />
104+
105+
</example>
106106

107107
<references>
108108

0 commit comments

Comments
 (0)