Java: CWE-400 - Query to detect uncontrolled thread resource consumption#6717
Java: CWE-400 - Query to detect uncontrolled thread resource consumption#6717smowton merged 13 commits intogithub:mainfrom
Conversation
80bb663 to
2dc38ae
Compare
|
Thanks @Marcono1234 and @intrigus-lgtm for reviewing this PR. I've made requested changes. |
Marcono1234
left a comment
There was a problem hiding this comment.
Thanks for considering the review comments!
I have had a closer look at the implementation of this query now; hopefully these comments are useful as well.
Though as usual, feel free to consider them only as suggestions because I am not a member of this project.
|
I've also added a new test case to detect remote source from an HTTP request header such as |
|
I've updated the query to handle the scenario of Apache Commons File Upload, which is the case of the referenced |
|
I think there is something wrong with the additional taint step. Could you check why it flags https://github.com/apache/struts/blob/3352d65d6cbef54a1813c7c5d8a21a6f8d6897a1/apps/showcase/src/main/java/org/apache/struts2/showcase/wait/LongProcessAction.java#L35? The class is not derived from |
Thanks @JarLob for reviewing this PR. I think it has nothing to do with the additional taint step. |
|
The query doesn't show any path in that case. Where is the taint source? Why does it think the |
The taint source is |
atorralba
left a comment
There was a problem hiding this comment.
I added a couple of suggestions to the qhelp and the QLDocs.
Also, now that a second query has been added there's a lot of duplicated code. I'd suggest moving the additional taint steps, the sanitizer, and the barrier guard to a shared library (maybe to ThreadPauseSink.qll after renaming it to something like ThreadResourceAbuse.qll?) and importing them in both queries.
smowton
left a comment
There was a problem hiding this comment.
Made a few inline edits. Over to you to add the missing local-input tests.
|
Thanks @smowton a lot for all your help with this PR. |
Thread.sleepmethod is used to pause the execution of current thread for specified time. When it is used to keep several relevant tasks in synchronization and the sleep time is user-controlled data, especially in the web application context, it can be abused to cause all of a server's threads to sleep, leading to denial of service.The query detects uncontrolled thread resource consumption in Java EE web applications, which checks:
javaxandjakartapackagesPlease consider to merge the PR. Thanks.