16
16
import csharp
17
17
import semmle.code.csharp.frameworks.System
18
18
import semmle.code.csharp.security.dataflow.flowsinks.Remote
19
- import semmle.code.csharp.dataflow.DataFlow :: DataFlow :: PathGraph
19
+ import ExceptionInformationExposure :: PathGraph
20
20
21
21
/**
22
22
* A taint-tracking configuration for reasoning about stack traces that flow to web page outputs.
23
23
*/
24
- class TaintTrackingConfiguration extends TaintTracking:: Configuration {
25
- TaintTrackingConfiguration ( ) { this = "StackTrace" }
26
-
27
- override predicate isSource ( DataFlow:: Node source ) {
24
+ module ExceptionInformationExposureConfig implements DataFlow:: ConfigSig {
25
+ predicate isSource ( DataFlow:: Node source ) {
28
26
exists ( Expr exceptionExpr |
29
27
// Writing an exception directly is bad
30
28
source .asExpr ( ) = exceptionExpr
@@ -40,7 +38,7 @@ class TaintTrackingConfiguration extends TaintTracking::Configuration {
40
38
)
41
39
}
42
40
43
- override predicate isAdditionalTaintStep ( DataFlow:: Node source , DataFlow:: Node sink ) {
41
+ predicate isAdditionalFlowStep ( DataFlow:: Node source , DataFlow:: Node sink ) {
44
42
sink .asExpr ( ) =
45
43
any ( MethodCall mc |
46
44
source .asExpr ( ) = mc .getQualifier ( ) and
@@ -49,20 +47,25 @@ class TaintTrackingConfiguration extends TaintTracking::Configuration {
49
47
)
50
48
}
51
49
52
- override predicate isSink ( DataFlow:: Node sink ) { sink instanceof RemoteFlowSink }
50
+ predicate isSink ( DataFlow:: Node sink ) { sink instanceof RemoteFlowSink }
53
51
54
- override predicate isSanitizer ( DataFlow:: Node sanitizer ) {
52
+ predicate isBarrier ( DataFlow:: Node sanitizer ) {
55
53
// Do not flow through Message
56
54
sanitizer .asExpr ( ) = any ( SystemExceptionClass se ) .getProperty ( "Message" ) .getAnAccess ( )
57
55
}
58
56
59
- override predicate isSanitizerIn ( DataFlow:: Node sanitizer ) {
57
+ predicate isBarrierIn ( DataFlow:: Node sanitizer ) {
60
58
// Do not flow through Message
61
59
sanitizer .asExpr ( ) .getType ( ) .( RefType ) .getABaseType * ( ) instanceof SystemExceptionClass
62
60
}
63
61
}
64
62
65
- from TaintTrackingConfiguration c , DataFlow:: PathNode source , DataFlow:: PathNode sink
66
- where c .hasFlowPath ( source , sink )
63
+ /**
64
+ * A taint-tracking module for reasoning about stack traces that flow to web page outputs.
65
+ */
66
+ module ExceptionInformationExposure = TaintTracking:: Global< ExceptionInformationExposureConfig > ;
67
+
68
+ from ExceptionInformationExposure:: PathNode source , ExceptionInformationExposure:: PathNode sink
69
+ where ExceptionInformationExposure:: flowPath ( source , sink )
67
70
select sink .getNode ( ) , source , sink , "This information exposed to the user depends on $@." ,
68
71
source .getNode ( ) , "exception information"
0 commit comments