Skip to content

Commit ab7ca1d

Browse files
committed
Java: Add parameters of @JavascriptInterface methods as a remote flow sources
1 parent f9b8200 commit ab7ca1d

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

java/ql/lib/semmle/code/java/dataflow/FlowSources.qll

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,3 +298,16 @@ class OnActivityResultIntentSource extends OnActivityResultIncomingIntent, Remot
298298

299299
override string getSourceType() { result = "Android onActivityResult incoming Intent" }
300300
}
301+
302+
/**
303+
* A parameter of a method annotated with the `android.webkit.JavascriptInterface` method
304+
*/
305+
class AndroidJavascriptInterfaceMethodParameter extends RemoteFlowSource {
306+
AndroidJavascriptInterfaceMethodParameter() {
307+
exists(JavascriptInterfaceMethod m | this.asParameter() = m.getAParameter())
308+
}
309+
310+
override string getSourceType() {
311+
result = "Parameter of method with JavascriptInterface annotation"
312+
}
313+
}

java/ql/lib/semmle/code/java/frameworks/android/Android.qll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,10 @@ class CreateFromParcelMethod extends Method {
127127
this.getEnclosingCallable().getDeclaringType().getAnAncestor() instanceof TypeParcelable
128128
}
129129
}
130+
131+
/**
132+
* A method annotated with the `android.webkit.JavascriptInterface` annotation.
133+
*/
134+
class JavascriptInterfaceMethod extends Method {
135+
JavascriptInterfaceMethod() { this.hasAnnotation("android.webkit", "JavascriptInterface") }
136+
}

0 commit comments

Comments
 (0)