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)
committerAtanas Kirilov <akirilov@google.com>
Fri, 5 Oct 2018 20:39:03 +0000 (20:39 +0000)
commita1ec7b115cc378f0547f10cf1074a5248d42d94f
tree5b769cff103b4bea15eefc14de2d028f8e00d649
parent3afd4aed423d33680f9ef63f54592f6b7b1fa52a
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
core/java/android/content/ContentProvider.java
core/java/android/content/ContentProviderOperation.java