mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-23 04:34:27 +00:00
Allow but deprecate serving download without DSA signature
This allows for a better transitioning period. In the future, this should be removed.
This commit is contained in:
1 parent
6bfdd18d9e
commit
1663a822c8
2 files changed
+42
-19
No files matched your search
@@ -25,22 +25,25 @@
|
||||
SUHost *newHost = [[SUHost alloc] initWithBundle:newBundle];
|
||||
NSString *newPublicDSAKey = newHost.publicDSAKey;
|
||||
|
||||
if (newPublicDSAKey == nil) {
|
||||
SULog(@"No public DSA key is found in the update. For security reasons, the update will be rejected.");
|
||||
NSString *publicDSAKey = host.publicDSAKey;
|
||||
|
||||
// Downgrade in DSA security should not be possible
|
||||
if (publicDSAKey != nil && newPublicDSAKey == nil) {
|
||||
SULog(@"A public DSA key is found in the old bundle but no public DSA key is found in the new update. For security reasons, the update will be rejected.");
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSString *publicDSAKey = host.publicDSAKey;
|
||||
|
||||
BOOL dsaKeysMatch = (publicDSAKey == nil) ? NO : [publicDSAKey isEqualToString:newPublicDSAKey];
|
||||
BOOL dsaKeysMatch = (publicDSAKey == nil || newPublicDSAKey == nil) ? NO : [publicDSAKey isEqualToString:newPublicDSAKey];
|
||||
|
||||
// If the new DSA key differs from the old, then this check is not a security measure, because the new key is not trusted.
|
||||
// In that case, the check ensures that the app author has correctly used DSA keys, so that the app will be updateable in the next version.
|
||||
// However if the new and old DSA keys are the same, then this is a security measure.
|
||||
if (![SUDSAVerifier validatePath:archivePath 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;
|
||||
if (newPublicDSAKey != nil) {
|
||||
if (![SUDSAVerifier validatePath:archivePath 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:newBundlePath];
|
||||
|
||||
Vendored
+30
-10
@@ -52,6 +52,9 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
@property (nonatomic, copy) void (^preStartedScheduledUpdateBlock)(void);
|
||||
@property (nonatomic, nullable) SUDownloadedUpdate *resumableUpdate;
|
||||
|
||||
@property (nonatomic) BOOL loggedATSWarning;
|
||||
@property (nonatomic) BOOL loggedDSAWarning;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SPUUpdater
|
||||
@@ -69,6 +72,8 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
@synthesize startedUpdater = _startedUpdater;
|
||||
@synthesize preStartedScheduledUpdateBlock = _preStartedScheduledUpdateBlock;
|
||||
@synthesize resumableUpdate = _resumableUpdate;
|
||||
@synthesize loggedATSWarning = _loggedATSWarning;
|
||||
@synthesize loggedDSAWarning = _loggedDSAWarning;
|
||||
|
||||
#ifdef DEBUG
|
||||
+ (void)load
|
||||
@@ -169,14 +174,6 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
return NO;
|
||||
}
|
||||
|
||||
BOOL hasPublicDSAKey = [self.host publicDSAKey] != nil;
|
||||
if (!hasPublicDSAKey) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUNoPublicDSAFoundError userInfo:@{ NSLocalizedDescriptionKey: @"For security reasons, updates need to be signed with a DSA key. See Sparkle's documentation for more information." }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
BOOL servingOverHttps = [[[feedURL scheme] lowercaseString] isEqualToString:@"https"];
|
||||
if (!servingOverHttps) {
|
||||
BOOL foundXPCTemporaryDownloaderService = NO;
|
||||
@@ -202,8 +199,31 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
}
|
||||
|
||||
if (foundATSTemporaryIssue || foundATSPersistentIssue || foundATSMainBundleIssue) {
|
||||
// Just log a warning. Don't outright fail in case we are wrong (eg: app is linked on an old SDK where ATS doesn't take effect)
|
||||
SULog(@"The feed URL (%@) may need to change to use HTTPS.\nFor more information: https://sparkle-project.org/documentation/app-transport-security", [feedURL absoluteString]);
|
||||
if (!self.loggedATSWarning) {
|
||||
// Just log a warning. Don't outright fail in case we are wrong (eg: app is linked on an old SDK where ATS doesn't take effect)
|
||||
SULog(@"The feed URL (%@) may need to change to use HTTPS.\nFor more information: https://sparkle-project.org/documentation/app-transport-security", [feedURL absoluteString]);
|
||||
|
||||
self.loggedATSWarning = YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BOOL hasPublicDSAKey = [self.host publicDSAKey] != nil;
|
||||
if (!hasPublicDSAKey) {
|
||||
if (!servingOverHttps) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUNoPublicDSAFoundError userInfo:@{ NSLocalizedDescriptionKey: @"For security reasons, updates need to be signed with a DSA key. See Sparkle's documentation for more information." }];
|
||||
}
|
||||
return NO;
|
||||
} else {
|
||||
if (!self.loggedDSAWarning) {
|
||||
// Deprecated because we pass the downloaded archive to the installer and the installer has no way of knowing where the download came from.
|
||||
// Even if it did, the server and the download on it could still be compromised. But if a DSA signature was used, the private key should
|
||||
// not be stored on the server serving the update
|
||||
SULog(@"DEPRECATION: Serving updates without a DSA key is now deprecated and may be removed from a future release. See Sparkle's documentation for more information.");
|
||||
|
||||
self.loggedDSAWarning = YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user