From 786d3d4bb6d20463575ede7e0f1f6a179d762700 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sat, 16 Apr 2016 17:24:55 -0400 Subject: [PATCH] Remove support for updating without DSA signing Updating without DSA signing the download is simply not secure. Before, we were keen on allowing no DSA signing as long as https is used. However, under the separate process security model, the installer can't know or trust if the download came over from https. We could move downloading into the installer, but the installer may run with full privileges one day in the future, and this would complicate the installer & updater interaction. Furthermore, this could disallow us from being able to silently download the update in the future if the installer runs at full privileges. An upside is that the validation and configuration checking code is simpler to read through now. Even if we could validate that an update came over https, it is still not as secure as people may like to believe. For example, a hijacked server can choose to manipulate the download (within restrictions), even if it's signed by a developer ID, but not with our DSA support. Changing of DSA keys and Apple code signing identities is still allowed as long as one of these pairs match and are valid. Hence requiring DSA signing is also safer when it comes to losing one of your keys. It's only a bit less convenient. --- Sparkle/Autoupdate/AppInstaller.m | 27 ++++++++++++++------------- Sparkle/SUUpdater.m | 14 ++------------ 2 files changed, 16 insertions(+), 25 deletions(-) diff --git a/Sparkle/Autoupdate/AppInstaller.m b/Sparkle/Autoupdate/AppInstaller.m index 14f39705..304b245e 100644 --- a/Sparkle/Autoupdate/AppInstaller.m +++ b/Sparkle/Autoupdate/AppInstaller.m @@ -160,13 +160,11 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7; } /** - * If the update is a package, then it must be signed using DSA. No other verification is done. + * If the update is a package, then the download must be signed using DSA. No other verification is done. * - * If the update is a bundle, then it must meet any one of: - * - * * old and new DSA public keys are the same and valid (it allows change of Code Signing identity), or - * - * * old and new Code Signing identity are the same and valid + * If the update is a bundle, then the download must also be signed using DSA. + * However, a change of DSA public keys is allowed if the Apple Code Signing identities match and are valid. + * Likewise, a change of Apple Code Signing identities is allowed if the DSA public keys match and the update is valid. * */ #warning - This might be better part of SUInstaller protocol since validation between app & packages differ @@ -205,14 +203,17 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7; SUHost *newHost = [[SUHost alloc] initWithBundle:newBundle]; NSString *newPublicDSAKey = newHost.publicDSAKey; - BOOL dsaKeysMatch = (publicDSAKey == nil || newPublicDSAKey == nil) ? NO : [publicDSAKey isEqualToString:newPublicDSAKey]; + if (newPublicDSAKey == nil) { + SULog(@"No public DSA key is found in the update. For security reasons, the update will be rejected."); + return NO; + } - if (newPublicDSAKey != nil) { - if (![SUDSAVerifier validatePath:downloadedPath withEncodedDSASignature:DSASignature withPublicDSAKey:newPublicDSAKey]) { - SULog(@"DSA signature validation failed. The update has a public DSA key and is signed with a DSA key, but the %@ doesn't match the signature. The update will be rejected.", - dsaKeysMatch ? @"public key" : @"new public key shipped with the update"); - return NO; - } + BOOL dsaKeysMatch = (publicDSAKey == nil) ? NO : [publicDSAKey isEqualToString:newPublicDSAKey]; + + if (![SUDSAVerifier validatePath:downloadedPath withEncodedDSASignature:DSASignature withPublicDSAKey:newPublicDSAKey]) { + SULog(@"DSA signature validation failed. The update has a public DSA key and is signed with a DSA key, but the %@ doesn't match the signature. The update will be rejected.", + dsaKeysMatch ? @"public key" : @"new public key shipped with the update"); + return NO; } BOOL updateIsCodeSigned = [SUCodeSigningVerifier bundleAtPathIsCodeSigned:installSourcePath]; diff --git a/Sparkle/SUUpdater.m b/Sparkle/SUUpdater.m index aca8ffa0..502a5acf 100644 --- a/Sparkle/SUUpdater.m +++ b/Sparkle/SUUpdater.m @@ -147,24 +147,14 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification } BOOL hasPublicDSAKey = [self.host publicDSAKey] != nil; - BOOL isAppBundle = [self.hostBundle.bundlePath.pathExtension.lowercaseString isEqualToString:@"app"]; - BOOL hostIsCodeSigned = [SUCodeSigningVerifier bundleAtPathIsCodeSigned:self.host.bundle.bundlePath]; - - BOOL servingOverHttps = [[[feedURL scheme] lowercaseString] isEqualToString:@"https"]; - if (!isAppBundle && !hasPublicDSAKey) { + if (!hasPublicDSAKey) { if (error != NULL) { *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUNoPublicDSAFoundError userInfo:@{ NSLocalizedDescriptionKey: @"For security reasons, you need to sign your updates with a DSA key. See Sparkle's documentation for more information." }]; } return NO; - } else if (isAppBundle && !(hasPublicDSAKey || hostIsCodeSigned)) { - if (error != NULL) { - *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInsufficientSigningError userInfo:@{ NSLocalizedDescriptionKey: @"For security reasons, you need to code sign your application and/or sign your updates with a DSA key. See Sparkle's documentation for more information." }]; - } - return NO; - } else if (isAppBundle && !hasPublicDSAKey && !servingOverHttps) { - SULog(@"WARNING: Serving updates over HTTP without signing them with a DSA key is deprecated and may not be possible in a future release. Please serve your updates over https, or sign them with a DSA key, or do both. See Sparkle's documentation for more information."); } + BOOL servingOverHttps = [[[feedURL scheme] lowercaseString] isEqualToString:@"https"]; BOOL allowsArbitraryHTTPLoads = SPARKLE_ALLOW_ARBITRARY_HTTP_LOADS; if (!allowsArbitraryHTTPLoads && !servingOverHttps) { if (error != NULL) {