Skip to content

Commit 48eb818

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 ae8991b commit 48eb818

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ class UpgradeReceiver : BroadcastReceiver() {
4141
// TODO: Now that we arent restoring like we use to, think we can remove this? Ill do some
4242
// testing and look at the issue but maybe someone has a answer or rems what directly
4343
// was causing this issue
44+
// Return early if the action does not match expected action
45+
if (intent.action != Intent.ACTION_MY_PACKAGE_REPLACED) {
46+
return
47+
}
4448
// Return early if using Android 7.0 due to upgrade restore crash (#263)
4549
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.N) {
4650
return

0 commit comments

Comments
 (0)