AdguardTeam / AdGuardHome

Network-wide ads & trackers blocking DNS server
https://adguard.com/adguard-home.html
GNU General Public License v3.0
25.16k stars 1.81k forks source link

Blocking rules completely fail to block subdomains if the subdomain contains a backwards slash #1835

Closed DandelionSprout closed 4 years ago

DandelionSprout commented 4 years ago

Prerequisites

Please answer the following questions for yourself before submitting an issue. YOU MAY DELETE THE PREREQUISITES SECTION.

Issue Details

While looking into the usual useless spam requests that my AGH server gets, I noticed to my surprise that two particular requests had not been blocked, despite them being almost identical with most of the other requests: torsk2

From the looks of it, it appears that AdGuard Home is currently completely unable to block domains with backwards slashes through ||-type entries, in my case t\\.t.a.cnamedot.d7e8406fdirect.bakeryfun.ml: image

I presume this is something that should be fixed somehow.

Expected Behavior

Domains containing backwards slashes are blocked if they are covered by a ||-type blocking rule.

Actual Behavior

Domains containing backwards slashes are not blocked, even if they are covered by a ||-type blocking rule.

Screenshots

Shown above in order to explain the context better.

Additional Information

I was able to rule out that it was my list setup's use of ||ml^ that had been flawed, since the "Check the filtering" feature confirmed this also applied to ||bakeryfun.ml^.

ammnt commented 4 years ago

I have exactly the same issue: https://github.com/AdguardTeam/AdGuardHome/issues/1698.

ameshkov commented 4 years ago

The thing is that this is not a valid domain name, and it's surprising that it is resolved.

To block it you should use a regexp rule.

ameshkov commented 4 years ago

Hmm, it seems that the resolver discards invalid character, you can check it with dig g\oogle.com

We'd better do the same

DandelionSprout commented 4 years ago

It was surprising to me too that the requests were resolved. Though after all, spambots on cloud hosting servers who consistently use ml addresses, constantly surprise me with their scummy strategies.

szolin commented 4 years ago

Use /bakeryfun.ml$/ rule - it works for domain names with backslash characters.

I'm not sure if it's a good idea to process on our side the backslash characters in host name in request. The way we currently match ||hostname^ rules via regexp ^(http|https|ws|wss)://([a-z0-9-_.]+\\.)? in urlfilter isn't so reliable for such cases. For example, what if the host name contains # character - we won't match it either!

szolin commented 4 years ago

UI may use regexp rules e.g. /bakeryfun.ml$/ instead of ||bakeryfun.ml^ for the domain names that contain invalid characters.

ameshkov commented 4 years ago

Wait, the UI seems to do okay after all: https://uploads.adguard.com/up04_AdGuard_Home_6hbv3.png