First version of the query

This commit is contained in:
Tony Torralba
2021-07-27 12:39:29 +02:00
parent 5216bbab93
commit d006db9d20
2 changed files with 47 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
/**
* @name Android Intent redirect
* @description xxx
* @kind path-problem
* @problem.severity error
* @security-severity xx
* @precision high
* @id java/android/unsafe-android-webview-fetch
* @tags security
* external/cwe/cwe-926
* external/cwe/cwe-940
*/
import java
import semmle.code.java.dataflow.DataFlow
import semmle.code.java.security.AndroidIntentRedirectQuery
import DataFlow::PathGraph
from DataFlow::PathNode source, DataFlow::PathNode sink, IntentRedirectConfiguration conf
where conf.hasFlowPath(source, sink)
select sink.getNode(), source, sink,
"Arbitrary Android activities or services can be started from $@.", source.getNode(),
"this user input"

View File

@@ -0,0 +1,24 @@
/** Provides taint tracking configurations to be used in Android Intent Redirect queries. */
import java
import semmle.code.java.dataflow.FlowSources
import semmle.code.java.dataflow.TaintTracking
/**
* A taint tracking configuration for user-provided Intents being used to start Android components.
*/
class IntentRedirectConfiguration extends TaintTracking::Configuration {
IntentRedirectConfiguration() { this = "IntentRedirectConfiguration" }
override predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }
override predicate isSink(DataFlow::Node sink) {
exists(MethodAccess ma |
ma.getMethod() instanceof StartActivityMethod or
ma.getMethod() instanceof StartServiceMethod or
ma.getMethod() instanceof SendBroadcastMethod
|
ma.getArgument(0) = sink.asExpr()
)
}
}