publication logo
post cover

Chromium Deep Dive: Fixing CRX_REQUIRED_PROOF_MISSING

How to fix the CRX_REQUIRED_PROOF_MISSING error on Chromium Browsers -- a deep dive into the Chromium Source Code

author profile

Stefan Aleksic

Apr 07 2022

10 mins read

I wanted to see if I could load Chrome Extensions without using the official Chrome Web Store. When I tried to download an extension from my webserver, I got an error:CRX_REQUIRED_PROOF_MISSING


Why does CRX_REQUIRED_PROOF_MISSING show up?

By default, Google locks down Chrome Extensions so that they can only be installed from the official Chrome Web Store by checking whether Google signed the extension's CRX file.


So when you see the CRX_REQUIRED_PROOF_MISSING error, Chromium says that the Chrome Webstore hasn't signed the CRX file with its private key. Chromium doesn't trust the file as it's not coming from the Chrome Webstore!


Let's dig into this a bit and see if there's a way around this. This article is a deep dive into how Chromium validates and installs extensions, and finding a way around it.


🌩️ If you'd just like to make this error go away, skip to the modifying policies section!


Join me by traversing the Chromium source tree online!


Start but Verify

Let's start at components/crx_file/crx_verifier.cc and the function Verify and see where that takes us. The Verify function is what Chromium runs when looking to ensure everything is fine with a given CRX file.


Chrome checks the standard things:

  • File is readable
  • CRX header is present
  • CRX version is the most up-to-date one (at time of writing, 3)

Once it's happy with these, things get a bit spicier! It calls the VerifyCrx3 function.

One error in the VerifyCrx3 function sticks out: VerifierResult::ERROR_REQUIRED_PROOF_MISSING


This is the CRX_REQUIRED_PROOF_MISSING error we're looking for! But what causes it you ask?


if (public_key_bytes.empty() || !required_key_set.empty())

    return VerifierResult::ERROR_REQUIRED_PROOF_MISSING;

if (require_publisher_key && !found_publisher_key)

    return VerifierResult::ERROR_REQUIRED_PROOF_MISSING;

The second if statement is the one causing the CRX_REQUIRED_PROOF_MISSING error when trying to download extensions from a custom web store.


There are two boolean values here. Let's see what both of them are.


What is require_publisher_key?

bool require_publisher_key =
    format == VerifierFormat::CRX3_WITH_PUBLISHER_PROOF ||
    format == VerifierFormat::CRX3_WITH_TEST_PUBLISHER_PROOF;


If the CRX format passed into Verify is of a particular type, require_publisher_key will return true.


What is found_publisher_key?

constexpr uint8_t kPublisherKeyHash[] = {
    0x61, 0xf7, 0xf2, 0xa6, 0xbf, 0xcf, 0x74, 0xcd, 0x0b, 0xc1, 0xfe,
    0x24, 0x97, 0xcc, 0x9b, 0x04, 0x25, 0x4c, 0x65, 0x8f, 0x79, 0xf2,
    0x14, 0x53, 0x92, 0x86, 0x7e, 0xa8, 0x36, 0x63, 0x67, 0xcf};
std::vector<uint8_t> publisher_key(std::begin(kPublisherKeyHash),
                                   std::end(kPublisherKeyHash));
std::vector<uint8_t> key_hash(crypto::kSHA256Length);
crypto::SHA256HashString(key, key_hash.data(), key_hash.size());

found_publisher_key =
  found_publisher_key || key_hash == publisher_key || ...

General idea:

  • Go through each proof within the CRX header
  • Hash the key in the proof
  • Compare it to the Chrome Web Store's publisher key hash
  • If it's the same, the boolean found publisher key value will be true

Logic

If we can get require_publisher_key to be false, we can get Chrome to load extensions that aren't in the Web Store!


What Are the Different CRX Formats Available?

There are three total:

  • CRX3
  • CRX3_WITH_TEST_PUBLISHER_PROOF
  • CRX3_WITH_PUBLISHER_PROOF

extensions/common/verifier_formats.cc sheds some light on what each of these means:


crx_file::VerifierFormat GetWebstoreVerifierFormat(
    bool test_publisher_enabled) {
  return test_publisher_enabled
             ? crx_file::VerifierFormat::CRX3_WITH_TEST_PUBLISHER_PROOF
             : crx_file::VerifierFormat::CRX3_WITH_PUBLISHER_PROOF;
}

crx_file::VerifierFormat GetPolicyVerifierFormat() {
  return crx_file::VerifierFormat::CRX3;
}

crx_file::VerifierFormat GetExternalVerifierFormat() {
  return crx_file::VerifierFormat::CRX3;
}

crx_file::VerifierFormat GetTestVerifierFormat() {
  return crx_file::VerifierFormat::CRX3;
}

Chromium enforces that extensions must come from the Web Store through formats with the pattern *_PUBLISHER_PROOF.


If we can figure out a way to get Chromium to call the Verify function with just VerifierFormat::CRX3, require_publisher_key will be false, and it won't error!


Downloading Extensions

We need to figure out how to call Verify with the CRX3 format and determine what calls the Verify function.


When you download a file in Chromium, the ChromeDownloadManagerDelegate::ShouldOpenDownload function runs.


if (download_crx_util::IsExtensionDownload(*item) &&
    !extensions::WebstoreInstaller::GetAssociatedApproval(*item)) {
        scoped_refptr<extensions::CrxInstaller> crx_installer =
            download_crx_util::OpenChromeExtension(profile_, *item);
}

So if it was an extension that got downloaded but wasn't associated with the web store, we should call download_crx_util::OpenChromeExtension.


Looking at OpenChromeExtension:


scoped_refptr<extensions::CrxInstaller> OpenChromeExtension(
    Profile* profile,
    const DownloadItem& download_item) {
  DCHECK_CURRENTLY_ON(BrowserThread::UI);

  scoped_refptr<extensions::CrxInstaller> installer(
      CreateCrxInstaller(profile, download_item));

  if (OffStoreInstallAllowedByPrefs(profile, download_item)) {
    installer->set_off_store_install_allow_reason(
        extensions::CrxInstaller::OffStoreInstallAllowedBecausePref);
  }

  if (extensions::UserScript::IsURLUserScript(download_item.GetURL(),
                                              download_item.GetMimeType())) {
    installer->InstallUserScript(download_item.GetFullPath(),
                                 download_item.GetURL());
  } else {
    DCHECK(!WebstoreInstaller::GetAssociatedApproval(download_item));
    installer->InstallCrx(download_item.GetFullPath());
  }

  return installer;
}


The lines of code that stick out here are:

if (OffStoreInstallAllowedByPrefs(profile, download_item)) {
  installer->set_off_store_install_allow_reason(
      extensions::CrxInstaller::OffStoreInstallAllowedBecausePref);
}

Some preferences allow what Chromium calls an "off store install".


Let's look at this function's implementation.

chrome/browser/download/download_crx_util.cc:


bool OffStoreInstallAllowedByPrefs(Profile* profile, const DownloadItem& item) {
  return g_allow_offstore_install_for_testing ||
         extensions::ExtensionManagementFactory::GetForBrowserContext(profile)
             ->IsOffstoreInstallAllowed(item.GetURL(), item.GetReferrerUrl());
}


The current hypothesis is that if we can get this function to return true, then the format passed into Verify will be of type CRX3, and our extension will load correctly.


I modified the function to always return true, then tested it and confirmed that the hypothesis was valid. Let's dig deeper!


Following the chain, we get to chrome/browser/extensions/extension_management.cc and IsOffStoreInstallAllowed


bool ExtensionManagement::IsOffstoreInstallAllowed(
    const GURL& url,
    const GURL& referrer_url) const {
  // No allowed install sites specified, disallow by default.
  if (!global_settings_->has_restricted_install_sources)
    return false;

  const URLPatternSet& url_patterns = global_settings_->install_sources;

  if (!url_patterns.MatchesURL(url))
    return false;

  // The referrer URL must also be allowlisted, unless the URL has the file
  // scheme (there's no referrer for those URLs).
  return url.SchemeIsFile() || url_patterns.MatchesURL(referrer_url);
}

It checks global_settings_ for install_sources that match the CRX file's download URL and referrer.


What is this install_sources thing?

It's a URLPatternSet, but where is it being populated? The same file!


const char kAllowedInstallSites[] = "extensions.allowed_install_sites";
const base::ListValue* install_sources_pref =
    static_cast<const base::ListValue*>(LoadPreference(
        pref_names::kAllowedInstallSites, true, base::Value::Type::LIST));

It's reading from a config key, extensions.allowed_install_sites, and loading whatever is inside there.


If we can get in there and add our URL, we could get the IsOffStoreInstallAllowed function to return true!


Let's go deeper. What is LoadPreference anyways?


const base::Value* ExtensionManagement::LoadPreference(
    const char* pref_name,
    bool force_managed,
    base::Value::Type expected_type) const {
  if (!pref_service_)
    return nullptr;
  const PrefService::Preference* pref =
      pref_service_->FindPreference(pref_name);
  if (pref && !pref->IsDefaultValue() &&
      (!force_managed || pref->IsManaged())) {
    const base::Value* value = pref->GetValue();
    if (value && value->type() == expected_type)
      return value;
  }
  return nullptr;
}

The gist of this preference stuff is simple - Chrome has an abstraction for thinking about changes, or "preferences." So instead of the code needing to know that the preference came from some custom policy, or some JSON config change, etc., etc., it has a bunch of code that reads from all those various sources and produces the same preference config no matter what the source is.


That way, code further down the chain can think of things like preferences and doesn't have to worry about the source.


The implementation that we're interested in is in components/policy/core/browser/configuration_policy_pref_store.cc


This file is responsible for abstracting policies into preferences. Let's take a look to see how it does so.


PrefValueMap* ConfigurationPolicyPrefStore::CreatePreferencesFromPolicies() {
  std::unique_ptr<PrefValueMap> prefs(new PrefValueMap);
  PolicyMap filtered_policies =
      policy_service_
          ->GetPolicies(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string()))
          .Clone();
  filtered_policies.EraseNonmatching(base::BindRepeating(&IsLevel, level_));

  std::unique_ptr<PolicyErrorMap> errors = std::make_unique<PolicyErrorMap>();

  PoliciesSet deprecated_policies;
  PoliciesSet future_policies;
  handler_list_->ApplyPolicySettings(filtered_policies, prefs.get(),
                                     errors.get(), &deprecated_policies,
                                     &future_policies);

  if (!errors->empty()) {
    if (errors->IsReady()) {
      LogErrors(std::move(errors), std::move(deprecated_policies),
                std::move(future_policies));
    } else if (policy_connector_) {  // May be null in tests.
      policy_connector_->NotifyWhenResourceBundleReady(base::BindOnce(
          &LogErrors, std::move(errors), std::move(deprecated_policies),
          std::move(future_policies)));
    }
  }

  return prefs.release();
}

So it looks at all of the policies that Chrome knows about, removes any that aren't considered MANDATORY (based on the level), and then populates the preferences using ApplyPolicySettings.


Therefore, the solution to get extensions working off-web store is to use Chrome Enterprise policies.


Mo‎difying Policies for Off Store Install

To see a list of policies you can set, out/Debug/gen/components/policy/policy_constants.h or you can go to the Google Chrome Enterprise Policies site.


Specifically, there are two policies we need to change to allow for off-store installation and avoid the CRX_REQUIRED_PROOF_MISSING error:


ExtensionInstallAllowlist

Setting the policy specifies which extensions are not subject to the blocklist.
Google Enterprise Policy Documentation


Chrome enables the extension blocklist by default, which blocks specific extensions from being installed outside the Chrome Web Store. This policy allows you to specify which extensions are not subject to the blocklist. The list of extensions is composed of extension IDs, and you must explicitly allow the extensions you'd like to use in your off-store installs.


💡 The format is extension id(;<update url>) where the part in the parenthesis is optional.


If you don't specify this allowlist value, Chrome will show you the following error message:


This extension is not listed in the Chrome Web Store and may have been added without your knowledge. Learn more


Custom Web Store Error

This is different from the CRX_REQUIRED_PROOF_MISSING but it will disable your extension nonetheless.

ExtensionInstallSources

Setting the policy specifies which URLs may install extensions, apps, and themes. Before Google Chrome 21, users could click on a link to a \*.crx file, and Google Chrome would offer to install the file after a few warnings. Afterward, such files must be downloaded and dragged to the Google Chrome settings page. This setting allows specific URLs to have the old, easier installation flow.

Google Enterprise Policy Documentation


The description here, from my experimentation, is wrong. Even if you download a CRX file and then drag and drop it over to the chrome://extensions page, VerifyCrx3 will still look for the publisher key and give you CRX_REQUIRED_PROOF_MISSING.


💡 This policy file where this value is stored must be of MANDATORY type for you to be able to install extensions off-web store. (See Appendix to learn more about mandatory policies)


Appendix

Locations of Policies


Policy Locations

For easy copy/paste:

HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google

HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Chromium

*\SOFTWARE\Policies\Microsoft\Edge

~/Library/Preferences/com.google.Chrome.plist

~/Library/Preferences/org.chromium.Chromium.plist

~/Library/Preferences/com.microsoft.Edge.plist

/etc/opt/chrome/policies/managed

/etc/chromium/policies/managed


Mandatory

Chrome treats recommended preferences differently from mandatory ones, so it's essential to learn the difference and how you can get Chrome to read your policy as you intend. Otherwise, you will get the CRX_REQUIRED_PROOF_MISSING error.


From my research, Chrome will throw out most policies that aren't considered mandatory.


How can you make a Chrome policy be considered mandatory? The heuristic Chrome tries to use is: "is this policy only writeable by a user with elevated privileges?" The trouble is sometimes, this is ambiguous.


Windows

Setting policies via GPOs, or by modifying registry keys of HKLM (further testing is required to see whether Chrome reads keys from HKCU, etc.) will make them mandatory. Only a user with elevated privileges can modify the Windows Registry HKLM hive.


macOS

Properties written by an MDM tool will be considered mandatory. Chromium considers the rest recommended. Chromium uses the Core Foundation function CFPreferencesAppValueIsForced, which checks whether an MDM solution wrote a property, and thus a user can't change it.


They do not check file privileges as they do on Linux. You can set the com.google.Chrome.plist not to be world writeable, but it's useless.


Linux

Chromium checks file permissions of the policies file to see if it's world writeable. If it isn't world writeable, the policies will be considered mandatory.


Conclusion

Chrome is very shy in explaining what the CRX_REQUIRED_PROOF_MISSING is all about. I hope this article helps answer any questions you had about it, and hope you learned a bit more about the mysterious world of extension validation!



At Plasmo, we're an early-stage team excited about automation, open-source, and especially the browser extension ecosystem.

As you can see in this article on diving deep into Chromium and unraveling CRX_REQUIRED_PROOF, we're building tools to make browser extension development as easy as possible, from end to end. We're going to be building a lot more awesome stuff in this space. If this sounds interesting to you, subscribe to our mailing list!

Read more posts like this in your inbox

Subscribe to the newsletter

chromiumbrowser extensionchrome extension