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)
committerVasyl Gello <vasek.gello@gmail.com>
Sun, 16 Dec 2018 17:43:12 +0000 (19:43 +0200)
commitb98c5a953421ec5b691d801741aad634827231d9
tree4e21c6ff23e4c33bb94ef78483e84d9f99ccd4a3
parent019a7eab17b95bfec7a192436601cb7d3e05af51
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