mirror of
https://github.com/github/codeql.git
synced 2026-04-29 02:35:15 +02:00
Consider taint through bitwise operations on PendingIntent flags
This commit is contained in:
@@ -85,9 +85,11 @@ private class MutablePendingIntentFlowStep extends ImplicitPendingIntentAddition
|
||||
// unless it is at least sometimes explicitly marked immutable and never marked mutable.
|
||||
// Note: for API level < 31, PendingIntents were mutable by default, whereas since then
|
||||
// they are immutable by default.
|
||||
not TaintTracking::localExprTaint(any(ImmutablePendingIntentFlag flag).getAnAccess(), flagArg)
|
||||
not bitwiseLocalTaintStep*(DataFlow::exprNode(any(ImmutablePendingIntentFlag flag)
|
||||
.getAnAccess()), DataFlow::exprNode(flagArg))
|
||||
or
|
||||
TaintTracking::localExprTaint(any(MutablePendingIntentFlag flag).getAnAccess(), flagArg)
|
||||
bitwiseLocalTaintStep*(DataFlow::exprNode(any(MutablePendingIntentFlag flag).getAnAccess()),
|
||||
DataFlow::exprNode(flagArg))
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -124,3 +126,12 @@ private class PendingIntentSentSinkModels extends SinkModelCsv {
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if taint can flow from `source` to `sink` in one local step,
|
||||
* including bitwise operations.
|
||||
*/
|
||||
private predicate bitwiseLocalTaintStep(DataFlow::Node source, DataFlow::Node sink) {
|
||||
TaintTracking::localTaintStep(source, sink) or
|
||||
source.asExpr() = sink.asExpr().(BitwiseExpr).(BinaryExpr).getAnOperand()
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ public class ImplicitPendingIntentsTest {
|
||||
PendingIntent pi = PendingIntent.getActivity(ctx, 0, baseIntent, flag); // Sanitizer
|
||||
Intent fwdIntent = new Intent();
|
||||
fwdIntent.putExtra("fwdIntent", pi);
|
||||
ctx.startActivity(fwdIntent); // $ SPURIOUS: $ hasImplicitPendingIntent
|
||||
ctx.startActivity(fwdIntent); // Safe
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user