OSDN Git Service

RESTRICT AUTOMERGE: Recover shady content:// paths.
authorJeff Sharkey <jsharkey@android.com>
Mon, 24 Sep 2018 19:23:57 +0000 (13:23 -0600)
committerRohit Yengisetty <rngy@google.com>
Tue, 16 Oct 2018 23:21:09 +0000 (16:21 -0700)
commitc3a113e87c880ac0e7913b13b634b6d8b729493e
tree512a441515bdbfc03dae6efc2fcf8aa23053b23d
parent7334c95f01b36158188485a21e056faa30c2b985
RESTRICT AUTOMERGE: Recover shady content:// paths.

The path-permission element offers prefix or regex style matching of
paths, but most providers internally use UriMatcher to decide what
to do with an incoming Uri.

This causes trouble because UriMatcher uses Uri.getPathSegments(),
which quietly ignores "empty" paths.  Consider this example:

    <path-permission android:pathPrefix="/private" ... />

    uriMatcher.addURI("com.example", "/private", CODE_PRIVATE);

    content://com.example//private

The Uri above will pass the security check, since it's not
technically a prefix match.  But the UriMatcher will then match it
as CODE_PRIVATE, since it ignores the "//" zero-length path.

Since we can't safely change the behavior of either path-permission
or UriMatcher, we're left with recovering these shady paths by
trimming away zero-length paths.

Bug: 112555574
Test: cts-tradefed run cts -m CtsAppSecurityHostTestCases -t android.appsecurity.cts.AppSecurityTests
Change-Id: Ibadbfa4fc904ec54780c8102958735b03293fb9a
(cherry picked from commit a1ec7b115cc378f0547f10cf1074a5248d42d94f)
core/java/android/content/ContentProvider.java
core/java/android/content/ContentProviderOperation.java