Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 63addbd3 authored by Dan Cashman's avatar Dan Cashman
Browse files

Fix security bug: collect certs for non-systemDir apks.

ag/3340390 changed untrusted value to systemDir while going through
code review, flipping the meaning of the variable, but this was not
reflected in the call site.  As a result, systemDir apps are the
only ones being fully verified, which is the opposite of what we want.

Test: Builds, eventually CTS.

Change-Id: I585ac65c957f0d8db6c73f003d3a3eb2b79c8883
parent 1418d5a1
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1559,7 +1559,7 @@ public class PackageParser {
            throws PackageParserException {
        final String apkPath = apkFile.getAbsolutePath();

        boolean untrusted = (parseFlags & PARSE_IS_SYSTEM_DIR) == 0;
        boolean systemDir = (parseFlags & PARSE_IS_SYSTEM_DIR) != 0;
        int minSignatureScheme = ApkSignatureVerifier.VERSION_JAR_SIGNATURE_SCHEME;
        if ((parseFlags & PARSE_IS_EPHEMERAL) != 0 || pkg.applicationInfo.isStaticSharedLibrary()) {
            // must use v2 signing scheme
@@ -1567,7 +1567,7 @@ public class PackageParser {
        }
        try {
            ApkSignatureVerifier.Result verified =
                    ApkSignatureVerifier.verify(apkPath, minSignatureScheme, untrusted);
                    ApkSignatureVerifier.verify(apkPath, minSignatureScheme, systemDir);
            if (pkg.mCertificates == null) {
                pkg.mCertificates = verified.certs;
                pkg.mSignatures = verified.sigs;