项目作者: cketti

项目描述 :
A replacement for Android's ContentResolver that protects against the Surreptitious Sharing attack
高级语言: Java
项目地址: git://github.com/cketti/SafeContentResolver.git
创建时间: 2016-02-29T05:32:31Z
项目社区:https://github.com/cketti/SafeContentResolver

开源协议:Apache License 2.0

下载


SafeContentResolver

A replacement for Android’s ContentResolver
that protects against the Surreptitious Sharing attack.

Surreptitious Sharing

Read all about it in the corresponding blog post.

Usage

Replace all occurrences of ContentResolver.openInputStream())
where URIs provided by other apps are opened with SafeContentResolver.openInputStream().

SafeContentResolver will refuse to open file:// URIs pointing to files belonging to your app and content:// URIs
belonging to content providers of your app.
If you wish to allow access to certain content providers, add the following <meta-data> element to the appropriate
<provider> entries in your manifest:

  1. <provider>
  2. <meta-data
  3. android:name="de.cketti.safecontentresolver.ALLOW_INTERNAL_ACCESS"
  4. android:value="true" />
  5. </provider>

The library comes in two flavors safe-content-resolver-v14 and safe-content-resolver-v21. The former includes
native code to be able to invoke the fstat system call that is used to retrieve the owner of a file. Starting with
Lollipop (API 21) the framework includes the class Os
to access this functionality. So safe-content-resolver-v21 is free of native code and thus much smaller.

To retrieve an instance of SafeContentResolver use:

  1. SafeContentResolver safeContentResolver = SafeContentResolverCompat.newInstance(context);

If your minSdkVersion is 21 or higher you only need to include safe-content-resolver-v21 and use the following code:

  1. SafeContentResolver safeContentResolver = SafeContentResolver.newInstance(context);

Include the library

  1. implementation 'de.cketti.safecontentresolver:safe-content-resolver-v14:1.0.0'

Or, if you’re using minSdkVersion 21 or higher:

  1. implementation 'de.cketti.safecontentresolver:safe-content-resolver-v21:1.0.0'

Native code

safe-content-resolver-v14 contains native code for the following ABIs:

  • armeabi-v7a
  • arm64-v8a
  • x86
  • x86_64

If you don’t want to include all of them in your APK you might want to look into
ABIs Splits.

License

  1. Licensed under the Apache License, Version 2.0 (the "License");
  2. you may not use this file except in compliance with the License.
  3. You may obtain a copy of the License at
  4. http://www.apache.org/licenses/LICENSE-2.0
  5. Unless required by applicable law or agreed to in writing, software
  6. distributed under the License is distributed on an "AS IS" BASIS,
  7. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  8. See the License for the specific language governing permissions and
  9. limitations under the License.