From d0b802e09b48ed06c4a273d4129db8ccab26327c Mon Sep 17 00:00:00 2001 From: Uli Kusterer Date: Fri, 4 Dec 2009 09:11:11 +0100 Subject: [PATCH] Added preprocessor defines to SUConstants.h for turning on/off DSA and downgrades. We let users downgrade using our URL scheme, and we warn them beforehand, so the downgrade possible attack paranoia gets in the way. --- SUBasicUpdateDriver.m | 2 +- SUConstants.h | 2 ++ SUPlainInstaller.m | 2 ++ SUUpdater.m | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/SUBasicUpdateDriver.m b/SUBasicUpdateDriver.m index dba63e16..b23eaa8e 100644 --- a/SUBasicUpdateDriver.m +++ b/SUBasicUpdateDriver.m @@ -168,7 +168,7 @@ - (void)downloadDidFinish:(NSURLDownload *)d { - #if 0 // +++ + #if !ENDANGER_USERS_WITH_INSECURE_UPDATES // New in Sparkle 1.5: we're now checking signatures on all non-secure downloads, where "secure" is defined as both the appcast and the download being transmitted over SSL. NSURL *downloadURL = [[d request] URL]; if (!(([[downloadURL scheme] isEqualToString:@"https"] && [[appcastURL scheme] isEqualToString:@"https"]) || diff --git a/SUConstants.h b/SUConstants.h index dcdba8de..fc929f98 100644 --- a/SUConstants.h +++ b/SUConstants.h @@ -10,6 +10,8 @@ #ifndef SUCONSTANTS_H #define SUCONSTANTS_H +#define ENDANGER_USERS_WITH_INSECURE_UPDATES 1 +#define PERMIT_AUTOMATED_DOWNGRADES 1 // ----------------------------------------------------------------------------- // Notifications: diff --git a/SUPlainInstaller.m b/SUPlainInstaller.m index 7a5bef17..dc0a3c1c 100644 --- a/SUPlainInstaller.m +++ b/SUPlainInstaller.m @@ -51,6 +51,7 @@ NSString *SUInstallerErrorKey = @"SUInstallerError"; + (void)performInstallationWithPath:(NSString *)path host:(SUHost *)host delegate:delegate synchronously:(BOOL)synchronously versionComparator:(id )comparator { // Prevent malicious downgrades: + #if !PERMIT_AUTOMATED_DOWNGRADES if ([comparator compareVersion:[host version] toVersion:[[NSBundle bundleWithPath:path] objectForInfoDictionaryKey:@"CFBundleVersion"]] == NSOrderedDescending) { NSString * errorMessage = [NSString stringWithFormat:@"Sparkle Updater: Possible attack in progress! Attempting to \"upgrade\" from %@ to %@. Aborting update.", [host version], [[NSBundle bundleWithPath:path] objectForInfoDictionaryKey:@"CFBundleVersion"]]; @@ -58,6 +59,7 @@ NSString *SUInstallerErrorKey = @"SUInstallerError"; [self _finishInstallationWithResult:NO host:host error:error delegate:delegate]; return; } + #endif NSString *targetPath = [host installationPath]; NSString *tempName = [self temporaryNameForPath:targetPath]; diff --git a/SUUpdater.m b/SUUpdater.m index acc490e6..ff9352a7 100644 --- a/SUUpdater.m +++ b/SUUpdater.m @@ -73,7 +73,7 @@ static NSString *SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaultsObserv host = [[SUHost alloc] initWithBundle:bundle]; [self registerAsObserver]; -#if 0 +#if !ENDANGER_USERS_WITH_INSECURE_UPDATES // Saving-the-developer-from-a-stupid-mistake-check: if (![[[self feedURL] scheme] isEqualToString:@"https"] && ![host publicDSAKey]) NSRunAlertPanel(@"Insecure update error!", @"For security reasons, you need to distribute your appcast over SSL or sign your updates. See Sparkle's documentation for more information.", @"OK", nil, nil);