你所不知道的权限-Custom permission issue

本文探讨了在GMS认证测试中遇到的权限问题,涉及代码安全,具体表现为某些权限可能导致恶意第三方应用执行组件逻辑。问题起源于Lolipop系统后不允许重复定义自定义权限。解决方案是利用Android Framework来避免此类问题。

问题来源:手机厂商在进行GMS认证测试时测试出的问题,比如如下代码会产生权限安全问题

<receiver
    android:name=".wxapi.WXRegister"
    android:permission="com.tencent.mm.plugin.permission.SEND" >
    <intent-filter>
        <action android:name="com.tencent.mm.plugin.openapi.Intent.ACTION_REFRESH_WXAPP" />
    </intent-filter>
</receiver>

com.sohu.newsclient.wxapi.WXRegister (com.tencent.mm.plugin.permission.SEND)

问题分析:

      1.任何具有com.tencent.mm.plugin.permission.SEND权限的代码可能会执行你组件(如BroadCastReceiver)中的逻辑。

      2.如果第三方危害性的应用首先安装已经注册了这com.tencent.mm.plugin.permission.SEND权限


,并且设置android:protectionLevel="signature",那咱们的应用就会应为签名不同而无法安装,如
<uses-permission android:name="com.master.me.CUSTOM_PERMISSION_TEST"    android:protectionLevel="signature"/>

问题根源:At the beginning Lolipop OS, Basically, Duplicated custom permission definition is not allowed.  (If A App defines Permission P and is installed, B App which defines Permission P can not be installed if A app and B App's signature is different.)


解决方法:

1.利用Android FrameWork来规避此问题

manifest>
...
    <activity
        android:name=".InternalActivity"
        android:permission="com.hiqes.sample.frm_enf_perm"
        android:exported="false" >

        <intent-filter>
            <action android:name="com.hiqes.sample.INTERNAL_ACTION1" />
            <category android:name="android.category.DEFAULT" />
        </intent-filter>
        <intent-filter>
            <action android:name="com.hiqes.sample.INTERNAL_ACTION2" />
            <category android:name="android.category.DEFAULT" />
        </intent-filter>
        ...
    </activity>
....
</manifest>

Duplicate framework API(s) and permission(s) affecting BinderService;,getDeviceLockICCID() Future instances of this issue will be treated as an alert on 2025-10-14. AFAP/BTS has detected that the following framework files (framework.jar and/or services.jar) may have introduced violative customizations to the framework involving custom APIs. The following duplicated platform API(s) Lcom/android/server/engineer/OppoEngineerService$BinderService;,getDeviceLockICCID()Ljava/lang/String, Lcom/android/server/engineer/OppoEngineerService;,checkPermission()Z returns Device Lock ICC ID of a device. These custom API(s) were either not protected by any permissions, or protected by permissions other than android.permission.READ_PRIVILEGED_PHONE_STATE (including other AOSP permission or custom permission). These behaviors violate GMS policy 12.4 Custom system permissions, UIDs, and APIs which states: "Platform APIs gated by system permissions MUST NOT be duplicated by custom APIs and there MUST NOT be a mechanism to proxy or bypass the protection level of platform permissions." and "User data access that's protected by AOSP permissions MUST ONLY be protected by AOSP permissions and there MUST NOT be alternate means (for example, custom system permissions, APIs, UIDs) to get the same data" To address this finding, please take one of the following actions: (1) Remove the duplicated custom API in the framework, and use AOSP standard APIs instead, or (2) Protect the custom APIs with AOSP defined signature permissions If you believe this finding is incorrect please reach out to your TAM / Google point of contact and provide details that help us to validate inaccuracies and improve detection. More information is available at
06-25
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值