Skip to content

Commit 6fe0b78

Browse files
committed
Remove PendingIntentAsField step and add SliceProviderLifecycle step
1 parent fede7dd commit 6fe0b78

File tree

2 files changed

+31
-15
lines changed

2 files changed

+31
-15
lines changed

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,36 @@ private import semmle.code.java.dataflow.DataFlow
55
private import semmle.code.java.dataflow.FlowSteps
66
private import semmle.code.java.dataflow.ExternalFlow
77

8+
/** The class `androidx.slice.SliceProvider`. */
9+
class SliceProvider extends Class {
10+
SliceProvider() { this.hasQualifiedName("androidx.slice", "SliceProvider") }
11+
}
12+
13+
/**
14+
* An additional value step for modeling the lifecycle of a `SliceProvider`.
15+
* It connects the `PostUpdateNode` of any update done to the provider object in
16+
* `onCreateSliceProvider` to the instance parameter of `onBindSlice`.
17+
*/
18+
private class SliceProviderLifecycleStep extends AdditionalValueStep {
19+
override predicate step(DataFlow::Node node1, DataFlow::Node node2) {
20+
exists(Method onCreate, Method onBind, RefType declaringClass |
21+
declaringClass.getASupertype*() instanceof SliceProvider and
22+
onCreate.getDeclaringType() = declaringClass and
23+
onCreate.hasName("onCreateSliceProvider") and
24+
onBind.getDeclaringType() = declaringClass and
25+
onBind.hasName("onBindSlice")
26+
|
27+
node1
28+
.(DataFlow::PostUpdateNode)
29+
.getPreUpdateNode()
30+
.(DataFlow::InstanceAccessNode)
31+
.isOwnInstanceAccess() and
32+
node1.getEnclosingCallable() = onCreate and
33+
node2.(DataFlow::InstanceParameterNode).getEnclosingCallable() = onBind
34+
)
35+
}
36+
}
37+
838
private class SliceActionsInheritTaint extends DataFlow::SyntheticFieldContent,
939
TaintInheritingContent {
1040
SliceActionsInheritTaint() { this.getField().matches("androidx.slice.Slice.action") }

java/ql/lib/semmle/code/java/security/ImplicitPendingIntents.qll

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -68,21 +68,7 @@ private class SendPendingIntent extends ImplicitPendingIntentSink {
6868
override predicate hasState(DataFlow::FlowState state) { state = "MutablePendingIntent" }
6969
}
7070

71-
/**
72-
* Propagates taint from any tainted object to reads from its `PendingIntent`-typed fields.
73-
*/
74-
private class PendingIntentAsFieldAdditionalTaintStep extends ImplicitPendingIntentAdditionalTaintStep {
75-
override predicate step(DataFlow::Node node1, DataFlow::Node node2) {
76-
exists(Field f |
77-
f.getType() instanceof PendingIntent and
78-
node1.(DataFlow::PostUpdateNode).getPreUpdateNode() =
79-
DataFlow::getFieldQualifier(f.getAnAccess().(FieldWrite)) and
80-
node2.asExpr().(FieldRead).getField() = f
81-
)
82-
}
83-
}
84-
85-
private class MutablePendingIntentFlowStep extends PendingIntentAsFieldAdditionalTaintStep {
71+
private class MutablePendingIntentFlowStep extends ImplicitPendingIntentAdditionalTaintStep {
8672
override predicate step(
8773
DataFlow::Node node1, DataFlow::FlowState state1, DataFlow::Node node2,
8874
DataFlow::FlowState state2

0 commit comments

Comments
 (0)