Skip to content

Commit b94e0d3

Browse files
authored
Merge pull request #10251 from atorralba/atorralba/implicit-pendingintent-sinks
Java: Add new AlarmManager sinks to Use of implicit PendingIntents
2 parents 6674e07 + 5d9f366 commit b94e0d3

File tree

4 files changed

+90
-1
lines changed

4 files changed

+90
-1
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,15 @@ private class PendingIntentSentSinkModels extends SinkModelCsv {
106106
"android.app;PendingIntent;false;send;(Context,int,Intent,OnFinished,Handler,String);;Argument[2];pending-intent-sent;manual",
107107
"android.app;PendingIntent;false;send;(Context,int,Intent,OnFinished,Handler);;Argument[2];pending-intent-sent;manual",
108108
"android.app;PendingIntent;false;send;(Context,int,Intent);;Argument[2];pending-intent-sent;manual",
109-
"android.app;Activity;true;setResult;(int,Intent);;Argument[1];pending-intent-sent;manual"
109+
"android.app;Activity;true;setResult;(int,Intent);;Argument[1];pending-intent-sent;manual",
110+
"android.app;AlarmManager;true;set;(int,long,PendingIntent);;Argument[2];pending-intent-sent;manual",
111+
"android.app;AlarmManager;true;setAlarmClock;;;Argument[1];pending-intent-sent;manual",
112+
"android.app;AlarmManager;true;setAndAllowWhileIdle;;;Argument[2];pending-intent-sent;manual",
113+
"android.app;AlarmManager;true;setExact;(int,long,PendingIntent);;Argument[2];pending-intent-sent;manual",
114+
"android.app;AlarmManager;true;setExactAndAllowWhileIdle;;;Argument[2];pending-intent-sent;manual",
115+
"android.app;AlarmManager;true;setInexactRepeating;;;Argument[3];pending-intent-sent;manual",
116+
"android.app;AlarmManager;true;setRepeating;;;Argument[3];pending-intent-sent;manual",
117+
"android.app;AlarmManager;true;setWindow;(int,long,long,PendingIntent);;Argument[3];pending-intent-sent;manual",
110118
]
111119
}
112120
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* Added new sinks related to Android's `AlarmManager` to the query `java/android/implicit-pendingintents`.

java/ql/test/query-tests/security/CWE-927/ImplicitPendingIntentsTest.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.io.FileNotFoundException;
44
import android.app.Activity;
5+
import android.app.AlarmManager;
56
import android.app.Notification;
67
import android.app.NotificationManager;
78
import android.app.PendingIntent;
@@ -217,6 +218,28 @@ public static void testPendingIntentInANotification(Context ctx)
217218

218219
}
219220

221+
public static void testPendingIntentInAnAlarm(Context ctx) {
222+
AlarmManager aManager = (AlarmManager) ctx.getSystemService(Context.ALARM_SERVICE);
223+
{
224+
Intent baseIntent = new Intent();
225+
PendingIntent pi = PendingIntent.getActivity(ctx, 0, baseIntent, 0);
226+
aManager.set(0, 0, pi); // $hasImplicitPendingIntent
227+
aManager.setAlarmClock(null, pi); // $hasImplicitPendingIntent
228+
aManager.setAndAllowWhileIdle(0, 0, pi); // $hasImplicitPendingIntent
229+
aManager.setExact(0, 0, pi); // $hasImplicitPendingIntent
230+
aManager.setExactAndAllowWhileIdle(0, 0, pi); // $hasImplicitPendingIntent
231+
aManager.setInexactRepeating(0, 0, 0, pi); // $hasImplicitPendingIntent
232+
aManager.setRepeating(0, 0, 0, pi); // $hasImplicitPendingIntent
233+
aManager.setWindow(0, 0, 0, pi); // $hasImplicitPendingIntent
234+
}
235+
{
236+
Intent baseIntent = new Intent();
237+
PendingIntent pi =
238+
PendingIntent.getActivity(ctx, 0, baseIntent, PendingIntent.FLAG_IMMUTABLE); // Sanitizer
239+
aManager.set(0, 0, pi); // Safe
240+
}
241+
}
242+
220243
static class TestActivity extends Activity {
221244
@Override
222245
public void onCreate(Bundle bundle) {

java/ql/test/stubs/google-android-9.0.0/android/app/AlarmManager.java

Lines changed: 54 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)