Merge pull request #11628 from egregius313/egregius313/android-webview-addjavascriptinterface-dataflow

Java: Add parameters of methods annotated @JavascriptInterface as remote flow sources
This commit is contained in:
Edward Minnix III
2023-01-10 12:41:52 -05:00
committed by GitHub
5 changed files with 42 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
---
category: minorAnalysis
---
* Added an external flow source for the parameters of methods annotated with `android.webkit.JavascriptInterface`.

View File

@@ -298,3 +298,16 @@ class OnActivityResultIntentSource extends OnActivityResultIncomingIntent, Remot
override string getSourceType() { result = "Android onActivityResult incoming Intent" }
}
/**
* A parameter of a method annotated with the `android.webkit.JavascriptInterface` annotation.
*/
class AndroidJavascriptInterfaceMethodParameter extends RemoteFlowSource {
AndroidJavascriptInterfaceMethodParameter() {
exists(JavascriptInterfaceMethod m | this.asParameter() = m.getAParameter())
}
override string getSourceType() {
result = "Parameter of method with JavascriptInterface annotation"
}
}

View File

@@ -85,3 +85,10 @@ class ShouldOverrideUrlLoading extends Method {
this.hasName("shouldOverrideUrlLoading")
}
}
/**
* A method annotated with the `android.webkit.JavascriptInterface` annotation.
*/
class JavascriptInterfaceMethod extends Method {
JavascriptInterfaceMethod() { this.hasAnnotation("android.webkit", "JavascriptInterface") }
}

View File

@@ -0,0 +1,11 @@
import android.webkit.JavascriptInterface;
public class AndroidExposedObject {
public void sink(Object o) {
}
@JavascriptInterface
public void test(String arg) {
sink(arg); // $hasRemoteValueFlow
}
}

View File

@@ -0,0 +1,7 @@
package android.webkit;
import java.lang.annotation.Annotation;
public abstract @interface JavascriptInterface {
}