Skip to content

Commit e2a12ec

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 4b2a8cf commit e2a12ec

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
@@ -34,6 +34,10 @@ import com.onesignal.notifications.internal.restoration.INotificationRestoreWork
3434

3535
class BootUpReceiver : BroadcastReceiver() {
3636
override fun onReceive(context: Context, intent: Intent) {
37+
// Return early if the action does not match expected action
38+
if (intent.action != Intent.ACTION_BOOT_COMPLETED){
39+
return
40+
}
3741
if (!OneSignal.initWithContext(context)) {
3842
return
3943
}

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
@@ -38,6 +39,10 @@ class UpgradeReceiver : BroadcastReceiver() {
3839
// TODO: Now that we arent restoring like we use to, think we can remove this? Ill do some
3940
// testing and look at the issue but maybe someone has a answer or rems what directly
4041
// was causing this issue
42+
// Return early if the action does not match expected action
43+
if (intent.action != Intent.ACTION_MY_PACKAGE_REPLACED){
44+
return
45+
}
4146
// Return early if using Android 7.0 due to upgrade restore crash (#263)
4247
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.N) {
4348
return

0 commit comments

Comments
 (0)