From 70f6929ac766b404e8e0d28d5cbda7872dc2ee3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kornel=20Lesi=C5=84ski?= Date: Tue, 19 Jan 2016 00:40:13 +0000 Subject: [PATCH 1/2] Disable redirects to non-HTTP URLs in release notes webview --- Sparkle/SUUpdateAlert.m | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Sparkle/SUUpdateAlert.m b/Sparkle/SUUpdateAlert.m index bd1ebf0d..a1e9f7a4 100644 --- a/Sparkle/SUUpdateAlert.m +++ b/Sparkle/SUUpdateAlert.m @@ -236,8 +236,17 @@ - (void)webView:(WebView *)__unused sender decidePolicyForNavigationAction:(NSDictionary *)__unused actionInformation request:(NSURLRequest *)request frame:(WebFrame *)__unused frame decisionListener:(id)listener { + NSURL *requestURL = request.URL; + NSString *scheme = requestURL.scheme; + BOOL whitelistedSafe = [@"http" isEqualToString:scheme] || [@"https" isEqualToString:scheme] || [@"about:blank" isEqualToString:requestURL.absoluteString]; + + // Do not allow redirects to dangerous protocols such as file:// + if (!whitelistedSafe) { + [listener ignore]; + return; + } + if (self.webViewFinishedLoading) { - NSURL *requestURL = request.URL; if (requestURL) { [[NSWorkspace sharedWorkspace] openURL:requestURL]; } From a6e9c8aff644f0cf5314c9f10e039c34cd350561 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kornel=20Lesi=C5=84ski?= Date: Tue, 19 Jan 2016 01:11:19 +0000 Subject: [PATCH 2/2] Prevent inclusion of local files via file:// XML entities --- Sparkle/SUAppcast.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sparkle/SUAppcast.m b/Sparkle/SUAppcast.m index dced1da7..42254148 100644 --- a/Sparkle/SUAppcast.m +++ b/Sparkle/SUAppcast.m @@ -102,7 +102,7 @@ if (self.downloadFilename) { NSUInteger options = 0; - options = NSXMLNodeLoadExternalEntitiesSameOriginOnly; + options = NSXMLNodeLoadExternalEntitiesNever; // Prevent inclusion from file:// document = [[NSXMLDocument alloc] initWithContentsOfURL:[NSURL fileURLWithPath:self.downloadFilename] options:options error:&error]; [[NSFileManager defaultManager] removeItemAtPath:self.downloadFilename error:nil];