uBlock Origin (and uMatrix) DoS with strict-blocking filter and crafted URL
github.com
github.com
It's a basic, excessive-recursion flaw that is noteworthy because uBO is installed on millions of devices and because it affects uMatrix, which is still used by many security-conscious users despite being unmaintained.
I was surprised that the issue had gone unnoticed for so long and was hoping my write-up would encourage other developers to take a closer look at the uBO codebase. I also wanted to make uMatrix users aware of the bug, which does not seem like it will be patched.
The uBO and uMatrix ecosystem is quite large: some shared code between the two extensions years ago turned into present-day vulnerabilities in uBO, uBO (Legacy), uMatrix, ηMatrix, nuTensor, AdNauseam, and many other lesser-known forks.
I had initially included some mitigation steps for uMatrix in my post, but I later realized they were incomplete and removed them. I will probably not make similar recommendations in the future, especially now that the steps have been quoted elsewhere and I cannot easily correct them (whoops).
I have decided to migrate away from uMatrix after my latest findings, but other users will have to make their own judgment calls.
The concern iirc was mainly that a Firefox update might require some change to keep it functional.
I have struggled to use it in the past because I was trying to directly map uMatrix rules to uBO dynamic rules, which isn't really possible due to syntax differences. I've realized now that I'll have to embrace both uBO's dynamic rules and uBO's static filters to truly replace uMatrix.
For example, I like to block all XHR requests by default. In uMatrix, the rule `* * xhr block` handled this for me. While uBO's dynamic-rule syntax does have an "xmlhttprequest" keyword, it cannot be used in a blanket rule like `* * xmlhttprequest block`. I had to use the static filter `*$xhr` to accomplish the same blocking instead.
This was a bit awkward at first because I had to compartmentalize rules for different request types based on the limitations of the dynamic-rule syntax. I've been using the uBO wiki on GitHub and r/uBlockOrigin as references to help me understand the differences.
I've also been using uBO's logger to help me generate rules and filters. Clicking on a blocked request will pop up a dialog that can be used for pretty fine-grained blocking. Seeing rules change on the fly is also nice for learning the intricacies of uBO's filtering capabilities.
* * * block * 1st-party * allow * facebook.com * block * facebook.net * block * fbstatic-a.akamaihd.net * block * instagram.com * block * whatsapp.com * block
and think I'm not affected – correct?
You will also be affected if you have any of the filter lists enabled on the "Assets" tab in the uMatrix dashboard.
There may be other ways of triggering the bug, too--those are just two of the more obvious ones.
The ηMatrix patch would require slight modifications due to stylistic differences between the uMatrix and ηMatrix codebases.
If the nuTensor PR gets applied and releases are made, then switching extensions might be a reasonable migration path for some users. You can also try to sideload a patched version of uMatrix, but sideloading procedures have become more onerous over time and may be annoying to deal with.
Unless I'm missing something it sounds like a denial of service attack?
PS Youtube Premium is not available in my country.
It may be worth billions in total, but that's only because Google have billions of users. If they don't show you ads, I don't think your personal data is worth more than pennies. And YouTube is expensive.
You don't really "pay with your data". You pay by buying products you see on ads. Your data is mostly used to show you products you are most likely to pay for. But if you remove the ads, then your data is mostly worthless.
To go with your analogy, YouTube is gold, your data is baubles. And sure enough, your data may be worth a lot to you, like a bauble with great sentimental value, but with almost no resale value.
Serving you with the small number of videos you watch is not expensive.
Doing this for billions of other people so it can hoover up large aomunts of personal data and serve ads, thats expensive.
When data, e.g., video, is shared peer-to-peer (the original design of the internet) without ad-supported middlemen, the expense is borne by the peers. They each pay for their internet connection and the bandwidth they use. Much more efficient and less costly.
Thats why people do video calls over peer-to-peer links.
Screen recording as proof: https://ufile.io/8upqzbci
What you say is accurate but that's not an explanation of why I see no ads. I use a local proxy in a unique, customised configuration that improves my UX.
If I use third party DNS such as Google and stop using a proxy, I too will see those annoying Grammarly ads. Thats why I come up with workarounds.
Not GP, but if it reliably blocks YouTube ads I think a lot of people would be interested in doing that?
As you say it's not possible via DNS; so can only be achieved in the browser, and in browsers with uBO.
(I.e. not mobile apps, Android TV app, mobile browsers other than FF on Android, desktop browsers other than FF/Chrome/derivatives.)
TBH, I am not convinced that I have a solution that works on every video. This is why I ask for examples. However I never see ads with the videos I watch, so it does work on some. I generally do not watch stuff that is heavily commercialised. Also I normally download the entire video before watching; I dislike so-called "streaming" and Javascript video players.
I need more examples I can test. All the videos submitted to HN seem to work. I need other examples.
DOM/content manipulation.
> Also I normally download the entire video before watching; I dislike so-called "streaming" and Javascript video players.
How do you do that? It's probably that.
(That's also unfortunately a browser / 'use a different app' solution rather than something that'll work for the YouTube app on iOS/Android/TV devices.)
When I am testing people's claims that YouTube ads cannot be "blocked" except with uBlock, I am using the same graphical browser that most people use. I do not believe these claims. I can prove there are other ways to retrieve videos without retrieving ads.
When I am not disproving those claims, I use the commandline (netcat + TLS proxy + ftp) to download video. This is the fastest and easiest way to use YouTube for me. It is extremely simple. No python required. Just some simple URL decoding and a little grep. I see no reason to use the graphical browser to download video. Thats overkill. Thats why people end up seeing ads, IMO. I may use the browser for playing media files offline but not for making HTTP requests.
> I can prove there are other ways to retrieve videos without retrieving ads.
Go ahead? There is no technical reason why Google can't serve you ads. You are not using DOM filters and we've already established that your DNS filter has no effect on YouTube. Google is choosing not to show you ads
> I use the commandline (netcat + TLS proxy + ftp) to download video
> URL decoding and a little grep
Eww, that'll break every time YouTube changes their ui. None of that is necessary. youtube-dl works with pretty much every video site, does not require a wacky setup, and it tracks YouTube changes pretty much instantly. It also works with playlists, entire channels, etc. You'll spend years replicating all the little features like quality selection, subtitles, etc if you use shell scripting for that.
Funny, that's the reaction I have to python and youtube-dl.
Aesthetics play a role in our perception, I guess.
If youtube-dl were smaller, faster and less brittle than a few lines of shell script, I might use it. However it fails on all three counts. I have only had to make changes to scripts twice in the history of YouTube. youtube-dl is constantly breaking and being updated; an incredible amount of size and churn for something so simple. I never have to wait for someone else because I can fix a script and be downloading again in the same day.
When I am testing people's claims that YouTube ads cannot be "blocked" except with uBlock, I am using the same graphical browser that most people use. I do not believe these claims. I can prove there are other ways to retrieve videos without retrieving ads.
But normally I use the commandline (netcat + TLS proxy) to download video. It is extremely simple. No python required. Just some simple URL decoding and a little grep. I see no reason to use the graphical browser to download video. Thats overkill. I may use it for playing media files offline though.
I'm guessing you don't use any websites that are owned by ad companies? That's a pretty big chunk of the internet