Skip to content

Commit 72ee108

Browse files
committed
Add intent verification to BroadcastReceiver classes
Update onReceive methods to check for correct action before proceeding. This prevents potential risk of third-party applications to send explicit intents to this receiver to cause a denial of service.
1 parent 9a32cf7 commit 72ee108

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

OneSignalSDK/onesignal/notifications/src/main/java/com/onesignal/notifications/receivers/BootUpReceiver.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ class BootUpReceiver : BroadcastReceiver() {
3737
context: Context,
3838
intent: Intent,
3939
) {
40+
// Return early if the action does not match expected action
41+
if (intent.action != Intent.ACTION_BOOT_COMPLETED){
42+
return
43+
}
4044
if (!OneSignal.initWithContext(context)) {
4145
return
4246
}

OneSignalSDK/onesignal/notifications/src/main/java/com/onesignal/notifications/receivers/UpgradeReceiver.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
*/
2727
package com.onesignal.notifications.receivers
2828

29+
import android.app.Notification.Action
2930
import android.content.BroadcastReceiver
3031
import android.content.Context
3132
import android.content.Intent
@@ -41,6 +42,10 @@ class UpgradeReceiver : BroadcastReceiver() {
4142
// TODO: Now that we arent restoring like we use to, think we can remove this? Ill do some
4243
// testing and look at the issue but maybe someone has a answer or rems what directly
4344
// was causing this issue
45+
// Return early if the action does not match expected action
46+
if (intent.action != Intent.ACTION_MY_PACKAGE_REPLACED){
47+
return
48+
}
4449
// Return early if using Android 7.0 due to upgrade restore crash (#263)
4550
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.N) {
4651
return

0 commit comments

Comments
 (0)