@@ -126,10 +126,41 @@ private DataFlow::Node getExceptionTarget(DataFlow::Node pred) {
126126
127127/**
128128 * A taint-tracking configuration for reasoning about XSS with possible exceptional flow.
129- * Flow labels are used to ensure that we only report taint-flow that has been thrown in
129+ * Flow states are used to ensure that we only report taint-flow that has been thrown in
130130 * an exception.
131131 */
132- class Configuration extends TaintTracking:: Configuration {
132+ module ExceptionXssConfig implements DataFlow:: StateConfigSig {
133+ class FlowState = DataFlow:: FlowLabel ;
134+
135+ predicate isSource ( DataFlow:: Node source , DataFlow:: FlowLabel label ) {
136+ source .( Source ) .getAFlowLabel ( ) = label
137+ }
138+
139+ predicate isSink ( DataFlow:: Node sink , DataFlow:: FlowLabel label ) {
140+ sink instanceof XssShared:: Sink and not label instanceof NotYetThrown
141+ }
142+
143+ predicate isBarrier ( DataFlow:: Node node ) { node instanceof XssShared:: Sanitizer }
144+
145+ predicate isAdditionalFlowStep (
146+ DataFlow:: Node pred , DataFlow:: FlowLabel inlbl , DataFlow:: Node succ , DataFlow:: FlowLabel outlbl
147+ ) {
148+ inlbl instanceof NotYetThrown and
149+ ( outlbl .isTaint ( ) or outlbl instanceof NotYetThrown ) and
150+ canThrowSensitiveInformation ( pred ) and
151+ succ = getExceptionTarget ( pred )
152+ }
153+ }
154+
155+ /**
156+ * Taint-tracking for reasoning about XSS with possible exceptional flow.
157+ */
158+ module ExceptionXssFlow = TaintTracking:: GlobalWithState< ExceptionXssConfig > ;
159+
160+ /**
161+ * DEPRECATED. Use the `ExceptionXssFlow` module instead.
162+ */
163+ deprecated class Configuration extends TaintTracking:: Configuration {
133164 Configuration ( ) { this = "ExceptionXss" }
134165
135166 override predicate isSource ( DataFlow:: Node source , DataFlow:: FlowLabel label ) {
@@ -145,12 +176,10 @@ class Configuration extends TaintTracking::Configuration {
145176 override predicate isAdditionalFlowStep (
146177 DataFlow:: Node pred , DataFlow:: Node succ , DataFlow:: FlowLabel inlbl , DataFlow:: FlowLabel outlbl
147178 ) {
148- inlbl instanceof NotYetThrown and
149- ( outlbl .isTaint ( ) or outlbl instanceof NotYetThrown ) and
150- canThrowSensitiveInformation ( pred ) and
151- succ = getExceptionTarget ( pred )
179+ ExceptionXssConfig:: isAdditionalFlowStep ( pred , inlbl , succ , outlbl )
152180 or
153181 // All the usual taint-flow steps apply on data-flow before it has been thrown in an exception.
182+ // Note: this step is not needed in StateConfigSig module since flow states inherit taint steps.
154183 this .isAdditionalFlowStep ( pred , succ ) and
155184 inlbl instanceof NotYetThrown and
156185 outlbl instanceof NotYetThrown
0 commit comments