@@ -61,10 +61,16 @@ class WebSettingsDisallowContentAccessSink extends DataFlow::Node {
6161 }
6262}
6363
64- class WebViewDisallowContentAccessConfiguration extends TaintTracking:: Configuration {
65- WebViewDisallowContentAccessConfiguration ( ) { this = "WebViewDisallowContentAccessConfiguration" }
64+ private newtype WebViewOrSettings =
65+ IsWebView ( ) or
66+ IsSettings ( )
6667
67- override predicate isSource ( DataFlow:: Node node ) { node instanceof WebViewSource }
68+ private module WebViewDisallowContentAccessConfiguration implements DataFlow:: StateConfigSig {
69+ class FlowState = WebViewOrSettings ;
70+
71+ predicate isSource ( DataFlow:: Node node , FlowState state ) {
72+ node instanceof WebViewSource and state instanceof IsWebView
73+ }
6874
6975 /**
7076 * Holds if the step from `node1` to `node2` is a dataflow step that gets the `WebSettings` object
@@ -73,12 +79,11 @@ class WebViewDisallowContentAccessConfiguration extends TaintTracking::Configura
7379 * This step is only valid when `state1` is empty and `state2` indicates that the `WebSettings` object
7480 * has been accessed.
7581 */
76- override predicate isAdditionalTaintStep (
77- DataFlow:: Node node1 , DataFlow:: FlowState state1 , DataFlow:: Node node2 ,
78- DataFlow:: FlowState state2
82+ predicate isAdditionalFlowStep (
83+ DataFlow:: Node node1 , FlowState state1 , DataFlow:: Node node2 , FlowState state2
7984 ) {
80- state1 instanceof DataFlow :: FlowStateEmpty and
81- state2 = "WebSettings" and
85+ state1 instanceof IsWebView and
86+ state2 instanceof IsSettings and
8287 // settings = webView.getSettings()
8388 // ^node2 = ^node1
8489 exists ( MethodAccess ma |
@@ -88,12 +93,17 @@ class WebViewDisallowContentAccessConfiguration extends TaintTracking::Configura
8893 )
8994 }
9095
91- override predicate isSink ( DataFlow:: Node node , DataFlow :: FlowState state ) {
92- state = "WebSettings" and
96+ predicate isSink ( DataFlow:: Node node , FlowState state ) {
97+ state instanceof IsSettings and
9398 node instanceof WebSettingsDisallowContentAccessSink
9499 }
100+
101+ predicate isBarrier ( DataFlow:: Node node , FlowState state ) { none ( ) }
95102}
96103
104+ module WebViewDisallowContentAccessFlow =
105+ TaintTracking:: MakeWithState< WebViewDisallowContentAccessConfiguration > ;
106+
97107from Expr e
98108where
99109 // explicit: setAllowContentAccess(true)
@@ -106,7 +116,7 @@ where
106116 // implicit: no setAllowContentAccess(false)
107117 exists ( WebViewSource source |
108118 source .asExpr ( ) = e and
109- not any ( WebViewDisallowContentAccessConfiguration cfg ) . hasFlow ( source , _)
119+ not WebViewDisallowContentAccessFlow :: hasFlow ( source , _)
110120 )
111121select e ,
112122 "Sensitive information may be exposed via a malicious link due to access to content:// links being allowed in this WebView."
0 commit comments