AdGuardHome icon indicating copy to clipboard operation
AdGuardHome copied to clipboard

$badfilter rules with collisions break the filtering engime

Open Metrokoto opened this issue 1 year ago • 4 comments

Prerequisites

Platform (OS and CPU architecture)

Linux, AMD64 (aka x86_64)

Installation

GitHub releases or script from README

Setup

On one machine

AdGuard Home version

0.107.52

Action

I am using ShadowWhisperer's TLD list which was recently formatted to work with AdGuard Home, however, I am also using whitelist based filtering for all Microsoft domains, meaning github.io is filtered as well.

As I wished for my filtering to exclude the top 100 TLDs, I created rules like

||*.io^badfilter

-to prevent the rule blocking .io and the other top TLDs from executing.

The issue I found is that when you have a domain blocked two or more ways, doing something like

||*.io^badfilter
||github.io^badfilter

-does not act as it should, and github.io and all subdomains remain blocked.

Image

I could whitelist github.io explicitly, but due to it being a UGC domain, I would much rather the bug be fixed to avoid such broad whitelists.

Expected result

The expected result is that both rules should be deactivated, as this is how it works in, eg; uBlock Origin.

Actual result

All other .io domains minus github.io are affected by the badfilter rule for .io

Image

Additional information and/or screenshots

No response

Metrokoto avatar Jun 07 '25 12:06 Metrokoto

See: https://adguard-dns.io/kb/general/dns-filtering-syntax/#badfilter-modifier Use ||*.io^$badfilter ;)

hagezi avatar Feb 14 '26 20:02 hagezi

Thanks for the report. The examples need a $ before the modifier:\n\ntext\n||*.io^$badfilter\n||github.io^$badfilter\n\n\nAfter correcting that syntax, I reproduced the underlying collision on current AdGuard Home master with the pinned urlfilter v0.23.4. A single blocking rule and its exact $badfilter counterpart work correctly. When two blocking rules match the same hostname and both have exact $badfilter counterparts, the current nested filtering loop can re-add a rule that another $badfilter removed, so the hostname remains blocked.\n\nThe dependency-level fix and regression tests are in AdguardTeam/urlfilter#50. I independently verified the failure against v0.23.4, then ran the focused collision/duplication tests 20 times and the full urlfilter suite under the race detector against the proposed fix; all passed.\n\nAfter that PR is merged and released, AdGuard Home will need one focused urlfilter dependency update with an integration regression. This also explains #7873.

Sil3ntVip3r avatar Aug 03 '26 15:08 Sil3ntVip3r

Hello. Could you please tell me if the solution suggested by @hagezi helped you?

sofvaskina avatar Aug 27 '26 15:08 sofvaskina

Closed due not reply

GulnazSalakhova avatar Sep 07 '26 14:09 GulnazSalakhova