Challenges
Search…
Insecure Content Provider
The Content Provider com.insecureshop.contentProvider.InsecureShopProvider is exported due to the presence of flag android:exported="true".
1
<provider android:name="com.insecureshop.contentProvider.InsecureShopProvider" android:readPermission="com.insecureshop.permission.READ" android:exported="true" android:authorities="com.insecureshop.provider"/>
Copied!
The content provider com.insecureshop.contentProvider.InsecureShopProvider contains the following code:
1
public boolean onCreate() {
2
android.content.UriMatcher uriMatcher2 = new android.content.UriMatcher(-1);
3
uriMatcher = uriMatcher2;
4
if (uriMatcher2 == null) {
5
return true;
6
}
7
uriMatcher2.addURI("com.insecureshop.provider", "insecure", 100);
8
return true;
9
}
10
11
public android.database.Cursor query(android.net.Uri uri, java.lang.String[] projection, java.lang.String selection, java.lang.String[] selectionArgs, java.lang.String sortOrder) {
12
kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull(uri, "uri");
13
android.content.UriMatcher uriMatcher2 = uriMatcher;
14
if (uriMatcher2 == null || uriMatcher2.match(uri) != 100) {
15
return null;
16
}
17
android.database.MatrixCursor cursor = new android.database.MatrixCursor(new java.lang.String[]{"username", "password"});
18
java.lang.String[] strArr = new java.lang.String[2];
19
java.lang.String username = com.insecureshop.util.Prefs.INSTANCE.getUsername();
20
if (username == null) {
21
kotlin.jvm.internal.Intrinsics.throwNpe();
22
}
23
strArr[0] = username;
24
java.lang.String password = com.insecureshop.util.Prefs.INSTANCE.getPassword();
25
if (password == null) {
26
kotlin.jvm.internal.Intrinsics.throwNpe();
27
}
28
strArr[1] = password;
29
cursor.addRow(strArr);
30
return cursor;
31
}
32
Copied!
If the content provider matches the URI insecure, then it allows us to access username and password of the logged-in user.
Exploiting this is not really straightforward. You need to create an android app as it cannot be exploited using adb or drozer. The reason is that the Content provider can only be accessed with the defined permission "android:readPermission". You need to add this permission in Attacker's "AndroidManifest.xml" file in order to access the Content Provider.
Last modified 4mo ago
Copy link