Content Provider Hacking
Overview
Content Providers manage access to a structured set of data in Android applications. They encapsulate data and provide mechanisms for defining data security. They can be targeted for various vulnerabilities such as SQL Injection and Path-Traversal attacks.
Key Areas of Focus
Exported Content Providers
SQL Injection Vulnerabilities
Path-Traversal Vulnerabilities
1. Exported Content Providers
What to Look For:
Exported Providers: Check if the Content Provider is exported in the
AndroidManifest.xmlfile. An exported provider can be accessed by other applications.Permissions: Examine if the Content Provider is protected by permissions. If the
protectionLevelis not set tosignature, it might be circumvented.
<provider
android:name="com.example.provider"
android:authorities="com.example.provider"
android:exported="true"
android:permission="com.example.provider.READ_WRITE" />
Code Exploit
AndroidManifest.xml in all exploits should have those lines
Case 1: Permission Bypass
Bypassing the custom user permission, because of the missing regex regarding to the PATH
Simply appending ///// at the end of our content URI will bypass it.
Code Exploit
2. SQL Injection Vulnerabilities

Steps to Identify:
Check Query Methods: Look at the
querymethod to see if user inputs are properly sanitized.Identify Tables: Locate the tables used within the Content Provider by searching for
content://URIs in the code.

Example Code to Identify SQL Injection Points:
Now we need to identify the tables in the Java code. We can look for the keyword “content://“.

Case 1
We need to query the Passwords table to insert our own SQL statement
SQL statement will be inserted via the projection
SQL syntax is sth like:
SELECT * FROM Passwords WHERE ....projection -->
SELECT '* FROM Key--;' (ignored .... FROM Passwords WHERE)
Exploit
Case 2
Granting the custom permissions of the sieve application to query the Key table.
consider:
Define them in the Manifest
We need to ask for them during runtime.
Example SQL Injection Attack:
Extract All Entries:
Inserting Data:
Updating Data:
Deleting Data:
3. Path-Traversal Vulnerabilities
Steps to Identify:
Check Exported Providers: Again, ensure the Content Provider is exported.
ParcelFileDescriptor: Look for
ParcelFileDescriptor openFilemethod and ensure the URI input is sanitized.
Example Path-Traversal Attack:
Reading Arbitrary Files:
Code Exploit
Summary
When pentesting Content Providers in Android applications, focus on:
Ensuring Content Providers are not improperly exported.
Checking for SQL Injection vulnerabilities by examining how inputs are handled in query methods.
Identifying and exploiting Path-Traversal vulnerabilities by verifying how file URIs are processed.
By thoroughly investigating these areas, you can identify and exploit significant vulnerabilities in Android applications' Content Providers.
Last updated
Was this helpful?