//nefariousplan

CVE-2026-0023: Android's PackageInstaller Scrubs Eight Caller-Controlled Install Flags. INSTALL_FROM_MANAGED_USER_OR_PROFILE Was The Ninth.

vendor

pattern

cve

proof of concept

Android's PackageInstaller.SessionParams is a Parcelable that carries a 32-bit installFlags field across Binder into system_server. The first thing PackageInstallerService.createSessionInternal does with that field is walk down a list of system-only flags and clear them off the caller's value with params.installFlags &= ~PackageManager.INSTALL_X before the install proceeds. The list, before the March 2026 patch, was eight flags long: INSTALL_FROM_ADB, INSTALL_ALL_USERS, INSTALL_ARCHIVED, INSTALL_ALLOW_TEST, INSTALL_ALLOW_DOWNGRADE, INSTALL_DISABLE_VERIFICATION, INSTALL_DISABLE_ALLOWED_APEX_UPDATE_CHECK, INSTALL_BYPASS_LOW_TARGET_SDK_BLOCK. CVE-2026-0023 is the ninth flag in the same class. INSTALL_FROM_MANAGED_USER_OR_PROFILE is what the same function read from the caller's Parcel without scrubbing for two release cycles.

The ninth &= is what the patch adds

Android's PackageInstaller.SessionParams is a Parcelable that carries a 32-bit installFlags field across Binder into system_server. The first thing PackageInstallerService.createSessionInternal does with that field, on AOSP android-15.0.0_r36 (services/core/java/com/android/server/pm/PackageInstallerService.java), is walk down a list of system-only flags and clear them off the caller's value before the install proceeds:

params.installFlags &= ~PackageManager.INSTALL_FROM_ADB;
params.installFlags &= ~PackageManager.INSTALL_ALL_USERS;
params.installFlags &= ~PackageManager.INSTALL_ARCHIVED;
...
params.installFlags &= ~PackageManager.INSTALL_ALLOW_TEST;
...
params.installFlags &= ~PackageManager.INSTALL_ALLOW_DOWNGRADE;
...
params.installFlags &= ~PackageManager.INSTALL_DISABLE_VERIFICATION;
...
params.installFlags &= ~PackageManager.INSTALL_DISABLE_ALLOWED_APEX_UPDATE_CHECK;
...
params.installFlags &= ~PackageManager.INSTALL_BYPASS_LOW_TARGET_SDK_BLOCK;

Eight &= lines, scattered through the prelude of one function. Each one is the server saying: this bit is system-only, you do not get to set it from a regular app, I am erasing it before the rest of this code reads installFlags. The list is the trust boundary between caller-controlled bits and system semantics.

Several hundred lines down in the same function, after the package source is checked, after the verifier is resolved, after device-policy state is loaded, the pre-patch code asked Device Policy Manager whether the user is organization-managed and conditionally set a ninth flag:

final var dpmi = LocalServices.getService(DevicePolicyManagerInternal.class);
if (dpmi != null && dpmi.isUserOrganizationManaged(userId)) {
    params.installFlags |= PackageManager.INSTALL_FROM_MANAGED_USER_OR_PROFILE;
}

A |= with no matching &= above it. If dpmi.isUserOrganizationManaged(userId) returns false, the conditional does nothing. Whatever value the caller put in that bit before Binder rides through unchanged.

Sanjana Sunil's patch (09055276288a68cf35b0f84ba32e28822f74ecf9, March 2026 Android Security Bulletin, bug A-459461121) adds the ninth &=:

 final var dpmi = LocalServices.getService(DevicePolicyManagerInternal.class);

+// Only the system should be able to set this flag - so ensure it is unset when not needed.
+params.installFlags &= ~PackageManager.INSTALL_FROM_MANAGED_USER_OR_PROFILE;

 if (dpmi != null && dpmi.isUserOrganizationManaged(userId)) {
     params.installFlags |= PackageManager.INSTALL_FROM_MANAGED_USER_OR_PROFILE;
 }

The commit message states the model in one sentence: "If the flag is not explicitly unset, an app could set this flag, leading to unexpected behaviour if the install is not actually from a managed user or profile." The model was correct from the day the flag was introduced. The implementation of the model arrived two release cycles later.

What the SDK does not let you set, and what installFlags is anyway

The public Android SDK exposes PackageInstaller.SessionParams through a Builder-style API. The Builder has methods like setAppLabel, setAppIcon, setPackageSource, setRequestUpdateOwnership, and roughly twenty others. None of those methods exposes INSTALL_FROM_MANAGED_USER_OR_PROFILE. The constant itself is annotated @hide in frameworks/base and the field it controls, SessionParams.installFlags, is package-private.

The public API surface is the convention. Apps that build SessionParams through the documented setters cannot set the bit because the documented setters do not write to it. That convention held everywhere the public API was the only path.

The QM4RS PoC's Unsafe Mart is the path the convention does not hold on. Its injectManagedProfileInstallFlag() extension, in Unsafe Market/app/src/main/java/com/installer/safemart/MainActivity.kt, reads the hidden constant and writes the private field with two reflective lookups:

private fun PackageInstaller.SessionParams.injectManagedProfileInstallFlag(): Boolean {
    val flagField = PackageManager::class.java
        .getDeclaredField("INSTALL_FROM_MANAGED_USER_OR_PROFILE")
        .apply { isAccessible = true }
    val installFlag = flagField.getInt(null)

    val installFlagsField = PackageInstaller.SessionParams::class.java
        .getDeclaredField("installFlags")
        .apply { isAccessible = true }

    val currentFlags = installFlagsField.getInt(this)
    val updatedFlags = currentFlags or installFlag
    installFlagsField.setInt(this, updatedFlags)
    return true
}

The two getDeclaredField calls read the constant and the field by name from the framework classes the runtime already loaded into the app's process. The apply { isAccessible = true } is the JVM-level access override; the runtime hidden-API blocklist is bypassed with the ChickenHook/RestrictionBypass library the README acknowledges as "implementation detail to access framework interfaces."

The PoC author understood exactly which boundary the bug lives at. The log line they emit after createSession returns says it verbatim:

Log.i(TAG, "createSession(sessionId=$sessionId, mode=${installMode.name}) completed. " +
    "These logs only confirm the app-side SessionParams mutation before Binder. " +
    "They do not prove system_server accepted or retained any requested flags.")

"They do not prove system_server accepted or retained any requested flags." That is the question CVE-2026-0023 answers: yes, it did, for one specific flag, for as long as INSTALL_FROM_MANAGED_USER_OR_PROFILE was in PackageManager and not in createSessionInternal's scrub list.

The Parcel does not know which Builder method set which bit

PackageInstaller.createSession(SessionParams params) packs params into a Binder transaction by calling params.writeToParcel(parcel, flags). The SessionParams.writeToParcel implementation (AOSP core/java/android/content/pm/PackageInstaller.java) writes the 32-bit installFlags field with a single parcel.writeInt(installFlags). The Parcel encoding is one int. There is no per-bit access control on the wire and there is no record of which Builder method, if any, set which bit.

In system_server, SessionParams.CREATOR.createFromParcel reads the int back into a new SessionParams. The server's view of params.installFlags is whatever the client wrote. The Parcel boundary is content-neutral.

createSessionInternal is where the content gets inspected. The eight &= lines are the only place per-bit semantics are enforced. They are an opt-in deny list maintained by hand. Every time a new system-only flag is added to PackageManager, the engineer who adds it has to remember to add the matching &= to createSessionInternal for the deny list to remain complete.

When INSTALL_FROM_MANAGED_USER_OR_PROFILE was added to PackageManager in the Android 14 cycle alongside the Update Ownership APIs, the matching scrub line was not added. The conditional |= was. The CL author who added the conditional knew the flag was system-only; the conditional itself encodes that knowledge by gating the write on dpmi.isUserOrganizationManaged(userId). They asked "should the system set this bit on this install?" and did not ask "could the caller have set it already?"

The eight prior flags answer that second question. Each one of the existing &= lines was added by someone who had the same realization: the bit reads as authoritative inside the server, and the only thing keeping it from being app-controllable is the scrub at the top of the function. The pattern was right there, eight times, in the same method.

What the bit does downstream

INSTALL_FROM_MANAGED_USER_OR_PROFILE is the server-side signal that the install session originated from a managed-profile installer. That is the enterprise device-policy controller installing into the work-profile user, in Android's enterprise deployment model. Managed-profile installs are exempt from Android's Update Ownership warning because the enterprise installer is presumed to hold authority over its target packages through device policy.

When the bit is set on a session, the install confirmation flow that reaches the user is the generic "Install update?" dialog. When the bit is not set, the flow surfaces the Update Ownership warning: "This app normally receives updates from <Safe Mart>. Allow <Unsafe Mart> to update it?" The warning names the registered update owner of the target package and asks the user to confirm a deviation.

The proof of concept's Safe Mart installs Ownership Inspector through the standard PackageInstaller path with setRequestUpdateOwnership(true), registering Safe Mart as the update owner of com.installer.inspector. Unsafe Mart then runs two installs against the same target. The first is a normal update. Android renders the Update Ownership warning naming Safe Mart. The second sets INSTALL_FROM_MANAGED_USER_OR_PROFILE via the reflective inject and runs the same install. Android renders the generic update dialog instead. The trust signal that names the registered update owner is gone from the flow.

Update Ownership is the trust model Android introduced in Android 14 to give app stores, enterprise installers, and side-loaders a stable signal about who controls updates to a given package. The model's user-facing surface is the warning dialog. The dialog's gate is INSTALL_FROM_MANAGED_USER_OR_PROFILE. The gate's authority is the assumption that only system_server can set the bit. The patch is system_server belatedly enforcing that assumption.

Internal Only By Convention

This is Internal Only By Convention at the Android Binder boundary. The "internal-only" status of INSTALL_FROM_MANAGED_USER_OR_PROFILE was held by three layers of soft enforcement, each of which the PoC steps over without producing anything the runtime is configured to refuse:

  • @hide on the constant. Hidden-API blocklist enforcement is bypassed by ChickenHook/RestrictionBypass, which the PoC adds as a Gradle dependency. The author notes correctly that "Hidden API access is only used as an implementation detail to reach the required framework interfaces from a regular application context."
  • The Builder API surface. The SessionParams.Builder has no setInstallFromManagedProfile() method, so an app following the public API cannot set the bit. Reflection on installFlags is one getDeclaredField lookup.
  • The implicit contract that dpmi.isUserOrganizationManaged(userId) is the only writer of the bit on the server side. That contract is encoded in the conditional |= and was not encoded in a matching unconditional &= until the March 2026 patch.

The Chamilo install.ajax.php exhibit (install-only by filename) is the same shape on a PHP filesystem: every handler in the directory enforced auth one file at a time, the install handler was the one file that didn't, and the convention that nobody would request the install handler post-install was the gate. The Android instance is the same convention at the Binder boundary: every system-only flag was scrubbed one line at a time, the managed-profile flag was the one flag that wasn't, and the convention that nobody could reach the field through reflection was the gate.

The defender's reading is the same in both directions. When the trust boundary's enforcement is "every caller-readable field has its own scrub line in one function," the boundary is one missed scrub away from absent. The deny list does not converge. Every new system-only flag added to PackageManager is a new opportunity for the matching line in createSessionInternal to not get written.

The CVE names one flag

CVE-2026-0023's description names INSTALL_FROM_MANAGED_USER_OR_PROFILE. The patch closes that flag. The patch does not change the architecture that requires a per-flag scrub list to be maintained by hand against an open-ended set of new system-only flags. The next flag in PackageManager annotated @hide and read by system_server with security-relevant authority is one CL away from being the same bug.

The bit's effect is bounded. The consequence is suppression of the Update Ownership warning during an install the user is already approving, not arbitrary code execution. The same architectural shape would carry a different consequence into the system depending on which flag was forgotten. INSTALL_BYPASS_LOW_TARGET_SDK_BLOCK is on the scrub list because the consequence of forgetting it would be apps installing despite targeting a deprecated SDK. INSTALL_DISABLE_VERIFICATION is on it because the consequence would be skipping the package verifier. INSTALL_ALL_USERS is on it because the consequence would be cross-user installation. Each line on the list represents a CVE that was avoided by adding the line.

CVE-2026-0023 represents the line that was not added.

PoC: QM4RS/CVE-2026-0023-Update-Ownership-PoC.

The deny list is the trust boundary. Eight flags were on it. The ninth was on the wire.