type
status
date
slug
summary
tags
category
icon
password
 
 

一、漏洞APP分析

 

1. AndroidManifest.xml

AndroidManifest 主要声明了一个MainActivity,一个FlagReceiver 和一个FileProvider ,剩下的无需分析,初步判断攻击点应该在FileProvider 。这里关于FileProvider 的细节就不再细说,前面的文章 ByteCTF2021 BabyDroid复现 已经详细说明过。
 

2.MainActivity

MainActivity 内容很少,获取到intent后判断action并且setResult(-1, getIntent()) 设置了一个返回值并且finishActivity ,这里可能会造成信息泄露。
根据官方对于setResult的说明:
Call this to set the result that your activity will return to its caller.
As of Build.VERSION_CODES.GINGERBREAD, the Intent you supply here can have Intent.FLAG_GRANT_READ_URI_PERMISSION and/or Intent.FLAG_GRANT_WRITE_URI_PERMISSION set. This will grant the Activity receiving the result access to the specific URIs in the Intent. Access will remain until the Activity has finished (it will remain across the hosting process being killed and other temporary destruction) and will be added to any existing set of URI permissions it already holds.
也就是说setResult 可以在原本intent设置 Intent.FLAG_GRANT_READ_URI_PERMISSIONIntent.FLAG_GRANT_WRITE_URI_PERMISSION的情况下授予接收结果的 Activity 访问 Intent 中指定的 URI 的权限,权限将一直保持直到Activity结束。

二、攻击APP构造

 

1. 攻击方案

根据上面的分析,其实攻击方案很明了,在通过Intent打开被攻击APP的MainActivity时设置好Intent.FLAG_GRANT_READ_URI_PERMISSIONIntent.FLAG_GRANT_WRITE_URI_PERMISSION 两个标志,当接收到返回时攻击APP已经有了读FileProvider的权限,就可以读flag文件
 

2. 攻击结果

notion image

三、总结

  • 主要考察setResultonActivityResult 可能造成的数据泄露问题,更多的知识可以看参考2
  • 考察FileProvider 的权限问题
 
 

参考

  1. ByteCTF 2022 官方writeup - 飞书云文档 (feishu.cn)
  1. Activity到底在什么情况下才会造成信息泄露-CSDN博客
  1. ByteCTF2021 BabyDroid复现 | LLeaves Blog (lleavesg.top)
  1. 终端安全 | setResult是怎么让你的隐私被泄露的 - 知乎 (zhihu.com)
 
 
 
ByteCTF2022 SilverDroid复现ByteCTF2021 HardDroid复现
  • Twikoo