Bug 245236

Summary: Content Blocking Rules `if-domain` mismatch when using URLScheme handler
Product: WebKit Reporter: Bartosz Waresiak <bwaresiak>
Component: Page LoadingAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: achristensen, beidson, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: Mac (Apple Silicon)   
OS: macOS 12   
Attachments:
Description Flags
Test cases demonstrating the issue none

Description Bartosz Waresiak 2022-09-15 12:09:28 PDT
Created attachment 462361 [details]
Test cases demonstrating the issue

Overview

We are using URLScheme handler to test Content Blocking rule generation locally, without need for network connection. Since macOS 12 (and corresponding iOS release) we are running into an issue that some tests are consistently failing - Common point is ignore-previous-rules action with trigger that uses if-domain matching.

Steps to Reproduce

See attached file for a test case with an example: there are 4 combinations that should result in the same outcome: test page loading 3rd party resource through preconfigured scheme handler, but in one of the cases test fails (content blocker blocks the request).

Details of configuration:

Content blocking rules (made to block all traffic from otherhost.com but allow one certain resource on a certain website):
        [ {
            "action": { "type": "block" },
            "trigger": { "url-filter": "testscheme://otherhost.com/.*" }
        },
        {
            "action": { "type": "ignore-previous-rules" },
            "trigger": { "url-filter": "testscheme://otherhost.com/img.png", "if-domain": [ "testhost.com" ] }
        } ]

Static website embedding `<img src='testscheme://otherhost.com/img.png'>` resource.

If main page is set to testscheme://testhost.com test blocks img request (unexpected).
If main page is set to testscheme://testhost.com/index.html test allows img request (correct).

If we remove `"if-domain"` from trigger, both above cases allow img request (expected).

Build Date & Hardware

Happens on macOS 12 and recent iOS releases. Tested on revision 833c22ec9c71.
Comment 1 Radar WebKit Bug Importer 2022-09-22 12:10:19 PDT
<rdar://problem/100287336>