1616import csharp
1717import semmle.code.csharp.frameworks.System
1818import semmle.code.csharp.security.dataflow.flowsinks.Remote
19- import semmle.code.csharp.dataflow.DataFlow :: DataFlow :: PathGraph
19+ import ExceptionInformationExposure :: PathGraph
2020
2121/**
2222 * A taint-tracking configuration for reasoning about stack traces that flow to web page outputs.
2323 */
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 ) {
2826 exists ( Expr exceptionExpr |
2927 // Writing an exception directly is bad
3028 source .asExpr ( ) = exceptionExpr
@@ -40,7 +38,7 @@ class TaintTrackingConfiguration extends TaintTracking::Configuration {
4038 )
4139 }
4240
43- override predicate isAdditionalTaintStep ( DataFlow:: Node source , DataFlow:: Node sink ) {
41+ predicate isAdditionalFlowStep ( DataFlow:: Node source , DataFlow:: Node sink ) {
4442 sink .asExpr ( ) =
4543 any ( MethodCall mc |
4644 source .asExpr ( ) = mc .getQualifier ( ) and
@@ -49,20 +47,25 @@ class TaintTrackingConfiguration extends TaintTracking::Configuration {
4947 )
5048 }
5149
52- override predicate isSink ( DataFlow:: Node sink ) { sink instanceof RemoteFlowSink }
50+ predicate isSink ( DataFlow:: Node sink ) { sink instanceof RemoteFlowSink }
5351
54- override predicate isSanitizer ( DataFlow:: Node sanitizer ) {
52+ predicate isBarrier ( DataFlow:: Node sanitizer ) {
5553 // Do not flow through Message
5654 sanitizer .asExpr ( ) = any ( SystemExceptionClass se ) .getProperty ( "Message" ) .getAnAccess ( )
5755 }
5856
59- override predicate isSanitizerIn ( DataFlow:: Node sanitizer ) {
57+ predicate isBarrierIn ( DataFlow:: Node sanitizer ) {
6058 // Do not flow through Message
6159 sanitizer .asExpr ( ) .getType ( ) .( RefType ) .getABaseType * ( ) instanceof SystemExceptionClass
6260 }
6361}
6462
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 )
6770select sink .getNode ( ) , source , sink , "This information exposed to the user depends on $@." ,
6871 source .getNode ( ) , "exception information"
0 commit comments