Skip to content

Commit 8064a47

Browse files
committed
LatinIME: Fix Implicit PendingIntent Vulnerability
* checkTimeAndMaybeSetupUpdateAlarm method created an Implicit PendingIntent vulnerability, which may cause security threats in the form of denial-of-service, private data theft, and privilege escalation. * PendingIntents are Intents delegated to another app to be delivered at some future time. Creating an implicit intent wrapped under a PendingIntent is a security vulnerability that might lead to denial-of-service, private data theft, and privilege escalation. * We've used FLAG_IMMUTABLE (added in SDK 23) to create PendingIntents for SDK > 23, This prevents apps that receive the PendingIntent from filling in unpopulated properties & Ensures that PendingIntent is only delivered to trusted components. Test: m Change-Id: I68a1f3f2d81138e42092cc201d36e5d29853a86e Signed-off-by: techyminati <[email protected]>
1 parent 974aaeb commit 8064a47

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

java/src/com/android/inputmethod/dictionarypack/DictionaryService.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,14 @@ private static void checkTimeAndMaybeSetupUpdateAlarm(final Context context) {
229229
final long now = System.currentTimeMillis();
230230
final long alarmTime = now + new Random().nextInt(MAX_ALARM_DELAY_MILLIS);
231231
final Intent updateIntent = new Intent(DictionaryPackConstants.UPDATE_NOW_INTENT_ACTION);
232+
// Set the package name to ensure the PendingIntent is only delivered to trusted components
233+
updateIntent.setPackage(context.getPackageName());
234+
int pendingIntentFlags = PendingIntent.FLAG_CANCEL_CURRENT;
235+
if (android.os.Build.VERSION.SDK_INT >= 23) {
236+
pendingIntentFlags |= PendingIntent.FLAG_IMMUTABLE;
237+
}
232238
final PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0,
233-
updateIntent, PendingIntent.FLAG_CANCEL_CURRENT);
239+
updateIntent, pendingIntentFlags);
234240

235241
// We set the alarm in the type that doesn't forcefully wake the device
236242
// from sleep, but fires the next time the device actually wakes for any

0 commit comments

Comments
 (0)