From 724427aac95eb2b1fe7a66374892623db287cbc0 Mon Sep 17 00:00:00 2001 From: Sumedh Sen Date: Mon, 27 Feb 2023 11:10:47 -0800 Subject: [PATCH] Remove the resolved path of session's APK from user confirmation intent Intent sent to the user for install confirmation includes the resolved path of the session's base apk. A malicious app can modify this path, resulting in the installer activity to show a different app icon and label in the confirmation dialog. To fix this, expose a @hide API for getting the resolved path and permission protect it with a privileged permission. Since @hide API is used, have PackageInstaller app depend on platform_apis Bug: 269728874 Bug: 279028637 Test: Adding a @hide API in UDC. No CTS test required for the API. Performed manual test by installing an apk and verifying UI elements of the installation dialog. Test: Test: atest CtsPackageInstallTestCases:SessionTest (To verify contents of user confirmation intent) Merged-In: Ibe7fe3ab5e74e3e910d9f7bd5b6f3f2e3c0ca658 Change-Id: Ibe7fe3ab5e74e3e910d9f7bd5b6f3f2e3c0ca658 (cherry picked from commit 7623ac966ee0a8fd94925f14527565325ee9dbd8) --- core/java/android/content/pm/PackageInstaller.java | 12 ++++++++++++ core/res/AndroidManifest.xml | 9 +++++++++ packages/PackageInstaller/Android.bp | 9 +++------ packages/PackageInstaller/AndroidManifest.xml | 1 + .../packageinstaller/PackageInstallerActivity.java | 7 +++---- .../android/server/pm/PackageInstallerSession.java | 14 +++++++------- 6 files changed, 35 insertions(+), 17 deletions(-) diff --git a/core/java/android/content/pm/PackageInstaller.java b/core/java/android/content/pm/PackageInstaller.java index 30fd77ca467c8..de66f050c007d 100644 --- a/core/java/android/content/pm/PackageInstaller.java +++ b/core/java/android/content/pm/PackageInstaller.java @@ -3553,6 +3553,18 @@ public class PackageInstaller { return referrerUri; } + /** + * @return the path to the validated base APK for this session, which may point at an + * APK inside the session (when the session defines the base), or it may + * point at the existing base APK (when adding splits to an existing app). + * + * @hide + */ + @RequiresPermission(Manifest.permission.READ_INSTALLED_SESSION_PATHS) + public @Nullable String getResolvedBaseApkPath() { + return resolvedBaseCodePath; + } + /** * Get the value set in {@link SessionParams#setGrantedRuntimePermissions(String[])}. * diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index f6c9fabb7896d..c5bf578b62a82 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -5418,6 +5418,15 @@ + + + +