Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/actions/spelling/allow.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ curated
CURSORPOSITON
CUSTOMHEADER
cvd
DAICLI
datatelemetry
datetime
dbconn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ namespace AppInstaller::Repository::Microsoft
{
namespace
{
// To use an unsigned source, set AICLI_ALLOW_UNSIGNED_SOURCE and use a debug build.
// Ex: set CL=/DAICLI_ALLOW_UNSIGNED_SOURCE
#if ! defined( AICLI_DISABLE_TEST_HOOKS ) && defined( AICLI_ALLOW_UNSIGNED_SOURCE )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I would rather see this hardened more to prevent what feels like potential for accidental disabling of the security.

I would do that by creating a function on the base class for use in calling ValidateTrustInfo. Then create a derived type from the Desktop version that overrides that virtual with the one that doesn't check (and can do that easily from preprocessor instead of a global bool).

I would also create a separate semantic for using the Desktop version all the time, mostly because we might consider allowing that as choice.

static bool s_AllowUnsignedSource = true;
#else
static bool s_AllowUnsignedSource = false;
#endif

static constexpr std::string_view s_PreIndexedPackageSourceFactory_PackageFileName = "source.msix"sv;
static constexpr std::string_view s_PreIndexedPackageSourceFactory_V2_PackageFileName = "source2.msix"sv;
static constexpr std::string_view s_PreIndexedPackageSourceFactory_PackageVersionHeader = "x-ms-meta-sourceversion"sv;
Expand Down Expand Up @@ -593,7 +601,7 @@ namespace AppInstaller::Repository::Microsoft
Msix::WriteLockedMsixFile indexPackage{ packageLocation };

// Validate index package trust info.
THROW_HR_IF(APPINSTALLER_CLI_ERROR_SOURCE_DATA_INTEGRITY_FAILURE, !indexPackage.ValidateTrustInfo(WI_IsFlagSet(m_details.TrustLevel, SourceTrustLevel::StoreOrigin)));
THROW_HR_IF(APPINSTALLER_CLI_ERROR_SOURCE_DATA_INTEGRITY_FAILURE, !s_AllowUnsignedSource && !indexPackage.ValidateTrustInfo(WI_IsFlagSet(m_details.TrustLevel, SourceTrustLevel::StoreOrigin)));

// Create a temp lock exclusive index file.
auto tempIndexFilePath = Runtime::GetNewTempFilePath();
Expand Down Expand Up @@ -683,7 +691,7 @@ namespace AppInstaller::Repository::Microsoft
THROW_HR_IF(APPINSTALLER_CLI_ERROR_SOURCE_DATA_INTEGRITY_FAILURE,
GetPackageFamilyNameFromDetails(details) != Msix::GetPackageFamilyNameFromFullName(tempMsixInfo.GetPackageFullName()));

if (!tempIndexPackage.ValidateTrustInfo(WI_IsFlagSet(details.TrustLevel, SourceTrustLevel::StoreOrigin)))
if (!s_AllowUnsignedSource && !tempIndexPackage.ValidateTrustInfo(WI_IsFlagSet(details.TrustLevel, SourceTrustLevel::StoreOrigin)))
{
AICLI_LOG(Repo, Error, << "Source update failed. Source package failed trust validation.");
THROW_HR(APPINSTALLER_CLI_ERROR_SOURCE_DATA_INTEGRITY_FAILURE);
Expand Down Expand Up @@ -719,7 +727,7 @@ namespace AppInstaller::Repository::Microsoft

std::unique_ptr<ISourceFactory> PreIndexedPackageSourceFactory::Create()
{
if (Runtime::IsRunningInPackagedContext())
if (!s_AllowUnsignedSource && Runtime::IsRunningInPackagedContext())
{
return std::make_unique<PackagedContextFactory>();
}
Expand Down