Skip to content

Commit 30cfbb8

Browse files
committed
Add UncaughtServletException
1 parent 5594e7f commit 30cfbb8

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

java/ql/src/experimental/Security/CWE/CWE-600/UncaughtServletException.ql

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import semmle.code.java.dataflow.FlowSources
1818
import semmle.code.java.dataflow.TaintTracking
1919
import semmle.code.java.frameworks.Servlets
2020
import semmle.code.xml.WebXML
21-
import DataFlow::PathGraph
21+
import UncaughtServletExceptionFlow::PathGraph
2222

2323
/** Holds if a given exception type is caught. */
2424
private predicate exceptionIsCaught(TryStmt t, RefType exType) {
@@ -66,15 +66,15 @@ class UncaughtServletExceptionSink extends DataFlow::ExprNode {
6666
}
6767

6868
/** Taint configuration of uncaught exceptions caused by user provided data from `RemoteFlowSource` */
69-
class UncaughtServletExceptionConfiguration extends TaintTracking::Configuration {
70-
UncaughtServletExceptionConfiguration() { this = "UncaughtServletException" }
69+
module UncaughtServletExceptionConfig implements DataFlow::ConfigSig {
70+
predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }
7171

72-
override predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }
73-
74-
override predicate isSink(DataFlow::Node sink) { sink instanceof UncaughtServletExceptionSink }
72+
predicate isSink(DataFlow::Node sink) { sink instanceof UncaughtServletExceptionSink }
7573
}
7674

77-
from DataFlow::PathNode source, DataFlow::PathNode sink, UncaughtServletExceptionConfiguration c
78-
where c.hasFlowPath(source, sink) and not hasErrorPage()
75+
module UncaughtServletExceptionFlow = TaintTracking::Global<UncaughtServletExceptionConfig>;
76+
77+
from UncaughtServletExceptionFlow::PathNode source, UncaughtServletExceptionFlow::PathNode sink
78+
where UncaughtServletExceptionFlow::flowPath(source, sink) and not hasErrorPage()
7979
select sink.getNode(), source, sink, "This value depends on a $@ and can throw uncaught exception.",
8080
source.getNode(), "user-provided value"

0 commit comments

Comments
 (0)