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()) 设置了一个返回值并且finish了Activity ,这里可能会造成信息泄露。根据官方对于
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_PERMISSION 和Intent.FLAG_GRANT_WRITE_URI_PERMISSION的情况下授予接收结果的 Activity 访问 Intent 中指定的 URI 的权限,权限将一直保持直到Activity结束。二、攻击APP构造
1. 攻击方案
根据上面的分析,其实攻击方案很明了,在通过Intent打开被攻击APP的MainActivity时设置好
Intent.FLAG_GRANT_READ_URI_PERMISSION 和Intent.FLAG_GRANT_WRITE_URI_PERMISSION 两个标志,当接收到返回时攻击APP已经有了读FileProvider的权限,就可以读flag文件2. 攻击结果

三、总结
- 主要考察
setResult和onActivityResult可能造成的数据泄露问题,更多的知识可以看参考2
- 考察
FileProvider的权限问题
参考
- 作者:LLeaves
- 链接:https://lleavesg.top//article/ByteCTF-2022-BronzeDroid
- 声明:本文采用 CC BY-NC-SA 4.0 许可协议,转载请注明出处。
相关文章






