summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/users
diff options
context:
space:
mode:
authorFyodor Kupolov <fkupolov@google.com>2014-11-18 15:08:12 -0800
committerFyodor Kupolov <fkupolov@google.com>2014-11-18 17:12:54 -0800
commit07ab95c43e49facb0fc4dd11d68645b4fe8d4c88 (patch)
tree1101c987d2696fb39d991f5c8ea7205c9e7d846c /src/com/android/settings/users
parentc88cdea2bb6f830abb8f1fe3b422368d3275f88c (diff)
downloadpackages_apps_Settings-07ab95c43e49facb0fc4dd11d68645b4fe8d4c88.zip
packages_apps_Settings-07ab95c43e49facb0fc4dd11d68645b4fe8d4c88.tar.gz
packages_apps_Settings-07ab95c43e49facb0fc4dd11d68645b4fe8d4c88.tar.bz2
Added a check if a custom activity can be started
AppRestrictionsFragment starts an activity using an intent provided by the receiver. A check was added to prevent an app from starting an activity that it does not own. Bug: 14441412 Change-Id: Ia6820b1daf3783d605b92976c78cb522b17dc8f2
Diffstat (limited to 'src/com/android/settings/users')
-rw-r--r--src/com/android/settings/users/AppRestrictionsFragment.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/com/android/settings/users/AppRestrictionsFragment.java b/src/com/android/settings/users/AppRestrictionsFragment.java
index 6fa5a79..38cdc42 100644
--- a/src/com/android/settings/users/AppRestrictionsFragment.java
+++ b/src/com/android/settings/users/AppRestrictionsFragment.java
@@ -23,6 +23,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.RestrictionEntry;
+import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.IPackageManager;
import android.content.pm.PackageInfo;
@@ -905,6 +906,7 @@ public class AppRestrictionsFragment extends SettingsPreferenceFragment implemen
} else if (restrictionsIntent != null) {
preference.setRestrictions(restrictions);
if (invokeIfCustom && AppRestrictionsFragment.this.isResumed()) {
+ assertSafeToStartCustomActivity(restrictionsIntent);
int requestCode = generateCustomActivityRequestCode(
RestrictionsResultReceiver.this.preference);
AppRestrictionsFragment.this.startActivityForResult(
@@ -912,6 +914,25 @@ public class AppRestrictionsFragment extends SettingsPreferenceFragment implemen
}
}
}
+
+ private void assertSafeToStartCustomActivity(Intent intent) {
+ // Activity can be started if it belongs to the same app
+ if (intent.getPackage() != null && intent.getPackage().equals(packageName)) {
+ return;
+ }
+ // Activity can be started if intent resolves to multiple activities
+ List<ResolveInfo> resolveInfos = AppRestrictionsFragment.this.mPackageManager
+ .queryIntentActivities(intent, 0 /* no flags */);
+ if (resolveInfos.size() != 1) {
+ return;
+ }
+ // Prevent potential privilege escalation
+ ActivityInfo activityInfo = resolveInfos.get(0).activityInfo;
+ if (!packageName.equals(activityInfo.packageName)) {
+ throw new SecurityException("Application " + packageName
+ + " is not allowed to start activity " + intent);
+ };
+ }
}
private void onRestrictionsReceived(AppRestrictionsPreference preference, String packageName,