-
Notifications
You must be signed in to change notification settings - Fork 424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Malicious site protection navigation detection #3707
base: alessandro/malicious-site-protection
Are you sure you want to change the base?
Malicious site protection navigation detection #3707
Conversation
@@ -26,11 +27,14 @@ import Foundation | |||
/// advanced information related to the error. | |||
protocol SpecialErrorPageActionHandler { | |||
/// Handles the action of navigating to the site associated with the error page | |||
func visitSite() | |||
@MainActor | |||
func visitSite(url: URL, errorData: SpecialErrorData) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m a bit on the fence with this.
The idea was to have a generic protocol that all the sub-special error handlers should conform to.
For MaliciousSiteProtectionNavigationHandler
I need to pass the URL and SpecialErrorData but I don’t need them for the SSL handler. So I feel I’m violating the Interface Segregation principle. what do you think?
let response = MaliciousSiteDetectionNavigationResponse(navigationAction: navigationAction, errorData: errorData) | ||
return .navigationHandled(.mainFrame(response)) | ||
} else { | ||
// Extract the URL of the source frame (the iframe) that initiated the navigation action |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will look more into iFrame logic when I integrate with BSK
|
||
@MainActor | ||
func handleMaliciousExemptions(for navigationType: WKNavigationType, url: URL) { | ||
// TODO: check storing redirects |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will address this TODO in upcoming PR
@@ -90,7 +94,7 @@ extension SSLErrorPageNavigationHandler: SpecialErrorPageActionHandler { | |||
Pixel.fire(pixel: .certificateWarningLeaveClicked) | |||
} | |||
|
|||
func visitSite() { | |||
func visitSite(url: URL, errorData: SpecialErrorData) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
8f0b90f
to
b6dbf5c
Compare
Task/Issue URL: https://app.asana.com/0/1206329551987282/1207151848931030
Tech Design URL: https://app.asana.com/0/1206329551987282/1207273224076495/f
Cc: @not-a-rootkit
Description:
This PR adds the navigation logic for detecting a malicious site and navigating to a special error page if the site is malicious.
The original idea in the tech design was to intercept the Request in
decidePolicyForNavigationAction
and check whether a site is malicious cancelling the request accordingly.We noticed that the above approach increases the page load time of websites due to the logic check.
I opted for an approach where in
decidePolicyForNavigationAction
we start the detection task in parallel without waiting and indecidePolicyForNavigationResponse
we evaluate the task’s result.Another approach I thought of was to perform the logic in the background in
didStartProvisionalNavigation
. The problem with this approach is that is called only for navigation that starts from the main frame so it would not be possible to intercept malicious iFrame URLs.NOTE
BSK Threat detection is currently mocked. Its integration and tests will follow in an upcoming PR.
Steps to test this PR:
Scenario 1 - Phishing Website should show special error page
Scenario 2 - Malware Website should show special error page
Scenario 3 - Allow visit a malicious website should not show the error again if navigating back to the site
Scenario 4 - Leave a malicious site should close the Tab
Definition of Done (Internal Only):
Copy Testing:
’
rather than'
Orientation Testing:
Device Testing:
OS Testing:
Theme Testing:
Internal references:
Software Engineering Expectations
Technical Design Template