Consider taint through bitwise operations on PendingIntent flags

This commit is contained in:
Tony Torralba
2022-11-21 10:10:38 +01:00
parent ef270232dc
commit 43f4dd8bc4
2 changed files with 14 additions and 3 deletions

View File

@@ -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()
}

View File

@@ -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
}
}