Skip to content

Commit 2627632

Browse files
committed
Java: Fix duplicate IDs
1 parent 5b040a9 commit 2627632

File tree

3 files changed

+53
-1
lines changed

3 files changed

+53
-1
lines changed

config/identical-files.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,5 +580,9 @@
580580
"IncompleteMultiCharacterSanitization JS/Ruby": [
581581
"javascript/ql/lib/semmle/javascript/security/IncompleteMultiCharacterSanitizationQuery.qll",
582582
"ruby/ql/lib/codeql/ruby/security/IncompleteMultiCharacterSanitizationQuery.qll"
583+
],
584+
"ThreadResourceAbuse help": [
585+
"java/ql/src/experimental/Security/CWE/CWE-400/LocalThreadResourceAbuse.qhelp",
586+
"java/ql/src/experimental/Security/CWE/CWE-400/ThreadResourceAbuse.qhelp"
583587
]
584588
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<!DOCTYPE qhelp PUBLIC
2+
"-//Semmle//qhelp//EN"
3+
"qhelp.dtd">
4+
<qhelp>
5+
6+
7+
<overview>
8+
<p>The <code>Thread.sleep</code> method is used to pause the execution of current thread for
9+
specified time. When the sleep time is user-controlled, especially in the web application context,
10+
it can be abused to cause all of a server's threads to sleep, leading to denial of service.</p>
11+
</overview>
12+
13+
<recommendation>
14+
<p>To guard against this attack, consider specifying an upper range of allowed sleep time or adopting
15+
the producer/consumer design pattern with <code>Object.wait</code> method to avoid performance
16+
problems or even resource exhaustion. For more information, refer to the concurrency tutorial of Oracle
17+
listed below or <code>java/ql/src/Likely Bugs/Concurrency</code> queries of CodeQL.</p>
18+
</recommendation>
19+
20+
<example>
21+
<p>The following example shows a bad situation and a good situation respectively. In the bad situation,
22+
a thread sleep time comes directly from user input. In the good situation, an upper
23+
range check on the maximum sleep time allowed is enforced.</p>
24+
<sample src="ThreadResourceAbuse.java" />
25+
</example>
26+
27+
<references>
28+
<li>
29+
Snyk:
30+
<a href="https://snyk.io/vuln/SNYK-JAVA-COMGOOGLECODEGWTUPLOAD-569506">Denial of Service (DoS)
31+
in com.googlecode.gwtupload:gwtupload</a>.
32+
</li>
33+
<li>
34+
gwtupload:
35+
<a href="https://github.com/manolo/gwtupload/issues/33">[Fix DOS issue] Updating the
36+
AbstractUploadListener.java file</a>.
37+
</li>
38+
<li>
39+
The blog of a gypsy engineer:
40+
<a href="https://blog.gypsyengineer.com/en/security/cve-2019-17555-dos-via-retry-after-header-in-apache-olingo.html">
41+
CVE-2019-17555: DoS via Retry-After header in Apache Olingo</a>.
42+
</li>
43+
<li>
44+
Oracle:
45+
<a href="https://docs.oracle.com/javase/tutorial/essential/concurrency/guardmeth.html">The Java Concurrency Tutorials</a>
46+
</li>
47+
</references>
48+
</qhelp>

java/ql/src/experimental/Security/CWE/CWE-400/LocalThreadResourceAbuse.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @description Using user input directly to control a thread's sleep time could lead to
44
* performance problems or even resource exhaustion.
55
* @kind path-problem
6-
* @id java/thread-resource-abuse
6+
* @id java/local-thread-resource-abuse
77
* @problem.severity recommendation
88
* @tags security
99
* external/cwe/cwe-400

0 commit comments

Comments
 (0)