Skip to content

Commit fe2755c

Browse files
atorralbasmowton
andauthored
Apply suggestions from code review
Co-authored-by: Chris Smowton <[email protected]>
1 parent cde7a35 commit fe2755c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ 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+
*/
7174
private class PendingIntentAsFieldAdditionalTaintStep extends ImplicitPendingIntentAdditionalTaintStep {
7275
override predicate step(DataFlow::Node node1, DataFlow::Node node2) {
7376
exists(Field f |
@@ -91,10 +94,11 @@ private class MutablePendingIntentFlowStep extends PendingIntentAsFieldAdditiona
9194
node2.asExpr() = pic and
9295
flagArg = pic.getFlagsArg()
9396
|
94-
// API < 31, PendingIntents are mutable by default
97+
// We err on the side of false positives here, assuming a PendingIntent may be mutable unless it is at
98+
// least sometimes explicitly marked immutable and never marked mutable.
99+
// Note for API level < 31, PendingIntents were mutable by default, whereas since then they are immutable by default.
95100
not TaintTracking::localExprTaint(any(ImmutablePendingIntentFlag flag).getAnAccess(), flagArg)
96101
or
97-
// API >= 31, PendingIntents need to explicitly set mutability
98102
TaintTracking::localExprTaint(any(MutablePendingIntentFlag flag).getAnAccess(), flagArg)
99103
)
100104
}

0 commit comments

Comments
 (0)