Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Detect synthetic click types and automatically block them. If this ca…
Browse files Browse the repository at this point in the history
…nnot be done, it's always best to ask the user if they wish to proceed.
  • Loading branch information
Brandon-T committed Mar 22, 2020
1 parent 125b51a commit f244ee7
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,30 @@ extension BrowserViewController: WKNavigationDelegate {
self.tabManager.selectedTab?.alertShownCount = 0
self.tabManager.selectedTab?.blockAllAlerts = false
}

// Prevents synthetically activated links such as: CVE-2017-7089
if ["data", "blob", "file"].contains(url.scheme) {
if let clickType = navigationAction.value(forKey: "syntheticClickType") as? Int {
if clickType == 0 {
decisionHandler(.cancel)
return
}
}

//Fallback.. Asks the user whether or not the url should be opened.. but only for `data`
if navigationAction.navigationType == .linkActivated && url.scheme == "data" {
handleExternalURL(url) { didOpenURL in
if !didOpenURL {
let alert = UIAlertController(title: Strings.unableToOpenURLErrorTitle, message: Strings.unableToOpenURLError, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: Strings.OKString, style: .default, handler: nil))
self.present(alert, animated: true, completion: nil)
}
}
decisionHandler(.cancel)
return
}
}

decisionHandler(.allow)
return
}
Expand Down

0 comments on commit f244ee7

Please sign in to comment.