Android安全检测 - 组件导出风险

火山方舟大模型内容安全与风控
市面上有很多的在线Android安全扫描工具,比如梆梆的安全检测平台、360显危镜、爱加密安全检测平台等等,自动化工具出来的结果大多数情况下都是非准确的,都需要人工进行复核。这一章我们来学习组件导出风险。

一、漏洞原理

app的四大组件,Activity,Service,Broadcast Receiver 和Content Provider,如果设置了导出权限,都可能被系统或者第三方的应用程序直接调出并使用。组件导出可能导致本地拒绝服务、越权、恶意调用等风险。

(1)什么是组件导出?

组件的导出具体表现在清单文件中,组件中存在"android:exported"这个属性,其值为true时表示组件存在导出。存在组件导出有以下几种情况


a. 主动设置android:exported为true


b. 组件存在IntentFilter,存在IntentFilter时android:exported属性默认值为true


c. 当minSdkVersion或者targetSdkVersion小于16时,默认为true 大于17时,默认为false








在app上的具体表现是:比如游戏登陆时调用微信的Activity登陆组件,微信的Activity登陆组件就是可被导出的。简单来讲就是导出的组件可以被第三方app调用(唤醒)

(2)组件的导出一般会引起什么风险呢?

a. 本地拒绝服务(未对传递的数据进行校验和异常处理,导出app异常崩溃)


b. 越权(未对调用者的权限进行校验,风险:绕过登陆页面、非法进入app测试环境页面等等)


c. 数据库SQL注入(使用拼接字符串组成SQL语句的形式去查询数据库)


d. 恶意调用

等等...

在这当中最常见的就是"本地拒绝服务""越权"

二、检测手段

这里从两个方面讲检测的手段:

(1)市面上大多数检测引擎的检测方法

(2)自查自检

从这两种检测方法来讲,若是要过一些监管要求,则采用第一种检测方法做对应的修复就行(由于大部分安全检测的厂家,都是采用检测引擎扫描的方式直接出结果,而没有进行人工复核,因为对于批量化的检测来讲人工复核的成本过高),第二种检测方案是人工进行检测(可以采用检测引擎 + 人工复核的方式进行)

(1)市面上大多数检测引擎的检测方法

基本上要过监管的要求采取这种方式进行就可以了,因为这种检测的方式可以认为是一刀切的方式,不管app内部采取了怎么样的校验和拦截,若不把android:exported属性置为false,都会报出这个组件导出的风险。








step1. 反编译app的AndroidManifest.xml文件








step2. 扫描组件中是否显示的存在android:exported属性,属性值是否为true,若为true则存在组件导出风险,若为false则进入step3。








step3. 扫描组件中是否存在IntentFilter,若存在IntentFilter并且没有显示的设置android:exproted的属性值为false,那么android:exported的默认值为true,存在组件导出风险

(2)自查自检

由于某些情况下业务的需要,组件是必须要导出的,比如:微信和QQ给其它app提供的三方登陆功能、 安全认证校验功能等等。所以组件导出只有必要和非必要,那么不需要提供给其它三方使用时最好将android:exported属性置为false,以避免引起漏洞,若确实需要给三方提供某些功能时在app内部要做好权限校验和异常拦截处理保证app的使用安全。








那么自查自检最好采用检测引擎 + 人工复核的方式进行,这里推荐一款检测的工具Drozer,这个工具用来检测组件导出相当优秀,再结合人工的复核,能够极大的解决组件导出的隐患。


在这里我们来了解Drozer的使用命令,具体的安装和使用在网上进行查询就行了。

          
app.activity.info           Gets information about exported activities.         
          
app.activity.start          Start an Activity                                   
          
app.broadcast.info          Get information about broadcast receivers           
          
app.broadcast.send          Send broadcast using an intent                      
          
app.broadcast.sniff         Register a broadcast receiver that can sniff        
          
                            particular intents                                  
          
app.package.attacksurface   Get attack surface of package                       
          
app.package.backup          Lists packages that use the backup API (returns true
          
                            on FLAG_ALLOW_BACKUP)                               
          
app.package.debuggable      Find debuggable packages                            
          
app.package.info            Get information about installed packages            
          
app.package.launchintent    Get launch intent of package                        
          
app.package.list            List Packages                                       
          
app.package.manifest        Get AndroidManifest.xml of package                  
          
app.package.native          Find Native libraries embedded in the application.  
          
app.package.shareduid       Look for packages with shared UIDs                  
          
app.provider.columns        List columns in content provider                    
          
app.provider.delete         Delete from a content provider                      
          
app.provider.download       Download a file from a content provider that        
          
                            supports files                                      
          
app.provider.finduri        Find referenced content URIs in a package           
          
app.provider.info           Get information about exported content providers    
          
app.provider.insert         Insert into a Content Provider                      
          
app.provider.query          Query a content provider                            
          
app.provider.read           Read from a content provider that supports files    
          
app.provider.update         Update a record in a content provider               
          
app.service.info            Get information about exported services             
          
app.service.send            Send a Message to a service, and display the reply  
          
app.service.start           Start Service                                       
          
app.service.stop            Stop Service                                        
          
auxiliary.webcontentresolver
          
                            Start a web service interface to content providers. 
          
exploit.jdwp.check          Open @jdwp-control and see which apps connect       
          
exploit.pilfer.general.apnprovider
          
                            Reads APN content provider                          
          
exploit.pilfer.general.settingsprovider
          
                            Reads Settings content provider                     
          
information.datetime        Print Date/Time                                     
          
information.deviceinfo      Get verbose device information                      
          
information.permissions     Get a list of all permissions used by packages on   
          
                            the device                                          
          
scanner.activity.browsable  Get all BROWSABLE activities that can be invoked    
          
                            from the web browser                                
          
scanner.misc.native         Find native components included in packages         
          
scanner.misc.readablefiles  Find world-readable files in the given folder       
          
scanner.misc.secretcodes    Search for secret codes that can be used from the   
          
                            dialer                                              
          
scanner.misc.sflagbinaries  Find suid/sgid binaries in the given folder (default
          
                            is /system).                                        
          
scanner.misc.writablefiles  Find world-writable files in the given folder       
          
scanner.provider.finduris   Search for content providers that can be queried    
          
                            from our context.                                   
          
scanner.provider.injection  Test content providers for SQL injection            
          
                            vulnerabilities.                                    
          
scanner.provider.sqltables  Find tables accessible through SQL injection        
          
                            vulnerabilities.                                    
          
scanner.provider.traversal  Test content providers for basic directory traversal
          
                            vulnerabilities.                                    
          
shell.exec                  Execute a single Linux command.                     
          
shell.send                  Send an ASH shell to a remote listener.             
          
shell.start                 Enter into an interactive Linux shell.              
          
tools.file.download         Download a File                                     
          
tools.file.md5sum           Get md5 Checksum of file                            
          
tools.file.size             Get size of file                                    
          
tools.file.upload           Upload a File                                       
          
tools.setup.busybox         Install Busybox.                                    
          
tools.setup.minimalsu       Prepare 'minimal-su' binary installation on the     
          
                            device.
      

三、修复方法

(1) 不需要导出的组件,设置组件属性android:exported=false

(2) 对于需要导出的组件需要做好:

   a. 权限校验和异常处理,避免应用出现拒绝服务

   b. 建议添加自定义signature或signatureOrSystem级别的私有权限保护


        
            

          原文链接:https://blog.csdn.net/qq\_35993502/article/details/118102715
        
      

查看更多精彩内容,还请关注橘猫学安全:

0
0
0
0
关于作者

文章

0

获赞

0

收藏

0

相关资源
字节跳动客户端性能优化最佳实践
在用户日益增长、需求不断迭代的背景下,如何保证 APP 发布的稳定性和用户良好的使用体验?本次分享将结合字节跳动内部应用的实践案例,介绍应用性能优化的更多方向,以及 APM 团队对应用性能监控建设的探索和思考。
相关产品
评论
未登录
看完啦,登录分享一下感受吧~
暂无评论