android中通用拒绝服务漏洞

该漏洞的描述见链接文章:http://www.cnxhacker.com/2015/01/07/5603.html
主要的原因是使用了Intent中
getSerializableExtra() 的API,如果攻击程序使用了app未定义的序列化类,该方法抛出异常,如果未捕获该异常,则导致应用不断crash。如果Activity不需要对外暴漏,则将exported置为false即可。此外,就是针对API的所有使用都加入try catch。

但在上周的发布中,差点因为这个改动导致线上问题。当使用pendingIntent建立的notification拉起Activity时,如果将其设置为false,则该Activity不会响应,因为pendingIntent为系统application。


Android下Activity通过UI总线对外暴露的三个层次



1
. 不对外暴露:应设置android:exported="false",如:
 
<activity android:name=".HomeActivity" android:exported="false">
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <data android:scheme="http" android:host="m.taobao.com" android:path="/index.htm" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</activity>
 
2. 对外部暴露:需要从非本app的其它App(含二方、三方)中通过URL方式唤起。应设置android:exported="true",且含有配置了URL规则的<intent-filter>,如:
 
<activity android:name=".HomeActivity" android:exported="true">
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <data android:scheme="http" android:host="m.example.com" android:path="/index.htm" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</activity>
 
3. 浏览器可跳入:在浏览器中访问到与URL规则匹配的网址时,浏览器将弹出选择提示,用户可选择使用本App或是继续用浏览器打开。由于存在一定的用户叨扰,所以须慎用,控制在尽可能小的范围内。
设置 android:exported="true",并在URL规则 的<intent-filter> 中添加BROWSABLE这个category,如:
 
<activity android:name=".HomeActivity" android:exported="true">
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <data android:scheme="http" android:host="m.example.com" android:path="/index.htm" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
    </intent-filter>
</activity>




  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值