Bug 245236 - Content Blocking Rules `if-domain` mismatch when using URLScheme handler
Summary: Content Blocking Rules `if-domain` mismatch when using URLScheme handler
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Page Loading (show other bugs)
Version: WebKit Local Build
Hardware: Mac (Apple Silicon) macOS 12
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-09-15 12:09 PDT by Bartosz Waresiak
Modified: 2022-09-22 12:10 PDT (History)
3 users (show)

See Also:


Attachments
Test cases demonstrating the issue (4.23 KB, patch)
2022-09-15 12:09 PDT, Bartosz Waresiak
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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>