Google 就 ContentProvider 中的路径遍历漏洞发出警告\n https://support.google.com/faqs/answer/7496913
\n\n\n\n
openFile如果导出的和openAssetFile导出的实现ContentProviders没有正确验证传入Uri参数,则它们可能容易受到攻击。恶意应用程序可以提供精心设计的文件Uri(例如,包含 \xe2\x80\x9c/../\xe2\x80\x9d)来欺骗您的应用程序返回ParcelFileDescriptor目标目录之外的文件,从而允许恶意应用程序访问您的应用程序可访问的任何文件。
他们的例子(来自上面的链接):
\npublic ParcelFileDescriptor openFile (Uri uri, String mode)\n throws FileNotFoundException {\n File f = new File(DIR, uri.getLastPathSegment());\n if (!f.getCanonicalPath().startsWith(DIR)) {\n throw new IllegalArgumentException();\n }\n return ParcelFileDescriptor.open(f, ParcelFileDescriptor.MODE_READ_ONLY);\n}\nRun Code Online (Sandbox Code Playgroud)\nDIR指的是什么?我如何实施正确的修复?
\n