Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UtilsFileProvider导致的隐私合规问题 #1782

Open
AndrewShen812 opened this issue Jul 27, 2023 · 0 comments
Open

UtilsFileProvider导致的隐私合规问题 #1782

AndrewShen812 opened this issue Jul 27, 2023 · 0 comments
Assignees
Labels

Comments

@AndrewShen812
Copy link

utilcode版本:1.29.0
工具库aar包中的Manifest文件有一个UtilsFileProvider声明:

<provider
            android:name="com.blankj.utilcode.util.UtilsFileProvider"
            android:authorities="${applicationId}.utilcode.provider"
            android:exported="false"
            android:grantUriPermissions="true" >
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/util_code_provider_paths" />
        </provider>

其关联的xml paths声明文件util_code_provider_paths.xml中有一个块:

...
<external-path
        name="external_path"
        path="." />
...

这个路径对应的是外部存储器的根目录。UtilsFileProvider是一个ContentProvider,我们知道ContentProvider的初始化是在Application的onCreate之前的,上面这个external-path的声明会触发系统调用android.os.Environment.getExternalStorageDirectory。这个调用是早于任何用户可见的交互确认操作的。

这里问题就来了,getExternalStorageDirectory通常是被列为隐私敏感API的,在用户授权之前就调用,在安全检测中会被检测为违规调用。以下是以我司应用为例,通过Frida在root设备上抓到的启动调用堆栈:

WX20230727-112509@2x

基于以上的排查思路,我尝试了将utilcode-1.29.0.aar改为zip后缀解压后,注释掉util_code_provider_paths.xml中的external-path声明块,再重新压缩改后缀为aar。经过验证,这样就不会在UtilsFileProvider的初始化阶段触发getExternalStorageDirectory调用了。

我查看了UtilsFileProvider的源码,看起来作者的意图只是想利用Provider的执行时机来获取ApplicationContext,实现Utils类的无感初始化。
如果确实只是出于这样的目的,建议作者大大可以考虑去掉util_code_provider_paths.xml中的external-path声明块,以规避国内使用可能遇到的隐私合规问题。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants