Android使广播接收器更安全 [英] Android make broadcast receiver secure

查看:86
本文介绍了Android使广播接收器更安全的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试实现一个安全"广播接收器,该接收器仅接收来自特定应用程序的广播.这是因为我想为我的应用制作一个插件,该插件可以通过广播触发操作.由于此操作是(部分)明智的,因此最好检查发件人是否真的是我的应用程序.据我所知,不可能检查发件人包裹?为此定义一个自定义权限是否安全?如果是,我该怎么做?还有什么其他可能性可以实现这一目标?

I'm trying to implement a "secure" broadcast receiver which only receives broadcasts from a specific app. This is because I want to make a plugin to my app which triggers actions via broadcasts. As this actions are (partly) sensible it would be nice to check if the sender is really my application. As far as I have seen it's impossible to check the sender package?? Would it be secure to define a custom permission for that? If yes, how can I do this? What other possibilities are there to achieve this?

提前谢谢!

推荐答案

为此定义自定义权限是否安全?

Would it be secure to define a custom permission for that?

如果应用程序和插件均由您编写,则具有 android:protectionLevel ="signature" 的自定义权限似乎是解决您问题的理想解决方案.如果没有该许可,则任何应用都无法将广播发送到您的接收器,该许可只能由使用相同签名密钥签名的应用来保留.另外,用户不必在安装时同意许可.

If both the app and the plugin are written by you, a custom permission with android:protectionLevel="signature" would seem to be the ideal solution for your problem. No apps will be able to send broadcasts to your receiver without holding that permission, which can only be held by apps signed by the same signing key. As a bonus, users do not have to agree to the permission at install time.

提示:在应用程序和插件中都定义< permission> 元素,因此这两个安装顺序无关紧要.

Pro tip: define the <permission> element in both the app and the plugin, so the install order of those two does not matter.

请注意自定义权限存在安全漏洞Android 5.0之前的版本,并且在Android上5.0+,除非两个应用程序使用相同的签名密钥签名,否则两个应用程序都不能定义相同的权限.

Note that custom permissions have a security flaw prior to Android 5.0, and that on Android 5.0+ no two apps can define the same permission unless they are signed by the same signing key.

这篇关于Android使广播接收器更安全的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆