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
Copy file name to clipboardExpand all lines: java/ql/src/experimental/Security/CWE/CWE-522-DecompressionBombs/DecompressionBomb.qhelp
+11-11Lines changed: 11 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -3,26 +3,26 @@
3
3
"qhelp.dtd">
4
4
<qhelp>
5
5
<overview>
6
-
<p>Extracting Compressed files with any compression algorithm like gzip can cause to denial of service attacks.</p>
7
-
<p>Attackers can compress a huge file which created by repeated similiar byte and convert it to a small compressed file.</p>
6
+
<p>Extracting Compressed files with any compression algorithm like gzip can cause a denial of service attacks.</p>
7
+
<p>Attackers can create a huge file by just repeating a single byte and compress it to a small file.</p>
8
8
9
9
</overview>
10
10
<recommendation>
11
11
12
-
<p>When you want to decompress a user-provided compressed file you must be careful about the decompression ratio or read these files within a loop byte by byte to be able to manage the decompressed size in each cycle of the loop.</p>
12
+
<p>When decompressing a user-provided compressed file, verify the decompression ratio or decompress the files within a loop byte by byte to be able to manage the decompressed size in each cycle of the loop.</p>
13
13
14
14
</recommendation>
15
15
<example>
16
16
17
17
<p>
18
-
Reading uncompressed ZipFile within a loop and check for a Threshold size in each cycle.
19
-
</p>
20
-
<samplesrc="example_good.java"/>
18
+
In the following example, the decompressed file size is not checked before decompression, exposing the application to a denial of service.
19
+
</p>
20
+
<samplesrc="example_bad.java" />
21
21
22
-
<p>
23
-
An Unsafe Approach can be this example which we don't check for uncompressed size.
24
-
</p>
25
-
<samplesrc="example_bad.java" />
22
+
<p>
23
+
A better approach is shown in the following example, where a ZIP file is read within a loop and a size threshold is checked every cicle.
24
+
</p>
25
+
<samplesrc="example_good.java"/>
26
26
27
27
</example>
28
28
<references>
@@ -31,7 +31,7 @@ An Unsafe Approach can be this example which we don't check for uncompressed siz
0 commit comments