user.js icon indicating copy to clipboard operation
user.js copied to clipboard

task: update wiki [CSP clashes eg 1xCB setting & uM]

Open theWalkingDuck opened this issue 8 years ago • 40 comments

Is it possible to block the Canvas API with FF prefs ?

theWalkingDuck avatar Sep 09 '18 12:09 theWalkingDuck

Canvas Blocker: https://github.com/ghacksuserjs/ghacks-user.js/wiki/4.1-Extensions

Atavic avatar Sep 09 '18 15:09 Atavic

RFP is always on so I have to rely on it. Unfortunately I can't use CanvasBlocker becouse I'm using uMatrix which is indispensable for me.

theWalkingDuck avatar Sep 10 '18 11:09 theWalkingDuck

CanvasBlocker like uMatrix, uses CSP-Headers to filter contents. In cases where both extensions add there own CSP-Headers, only one extension works properly. There is no way to aggregate those CSP headers. This is the downside of WebExtensions. Modifications made by one extension can be overwritten by other extensions which is dumb by design.

theWalkingDuck avatar Sep 10 '18 11:09 theWalkingDuck

CSP in CanvasBlocker is only used for blocking data: URIs. You can disable that part and still have the canvas blocking functionality.

earthlng avatar Sep 10 '18 11:09 earthlng

No, I'm talking about "Block data URL pages" under "Misc" - uncheck that and CB doesn't interfere with other CSP modifying extensions like uBO, uMatrix, NoScript etc

earthlng avatar Sep 10 '18 12:09 earthlng

CSP in CanvasBlocker is only used for blocking data: URIs.

That's weird. I made some tests in the past and I found out that CanvasBlocker uses CSP Header if the document contains inline-scripts. That's why I came to the conclusion not to use it with uMatrix.

but I will run some tests and get back to you.

theWalkingDuck avatar Sep 10 '18 20:09 theWalkingDuck

@earthlng let's take this simple inline script. uMatrix is set to block scripts and CanvasBlocker is set to default.

<script>
	document.write(window.navigator.userAgent);
</script>

result: CanvasBlocker interferes with uMatrix.

WebExtension                              Script
---------------------------------------------------
uMatrix                                   blocked
uMatrix(reload page)                      blocked
        ... clear cache ...
uMatrix + CanvasBlocker                   not blocked
uMatrix + CanvasBlocker(reload page)      blocked
        ... clear cache ...
uMatrix + CanvasBlocker                   not blocked
uMatrix + CanvasBlocker(reload page)      blocked
.
.

uMatrix 1.3.14 CanvasBlocker 0.5.3 FF 61.0.1 Linux

theWalkingDuck avatar Sep 11 '18 13:09 theWalkingDuck

and CanvasBlocker is set to default.

that's the problem. see https://github.com/ghacksuserjs/ghacks-user.js/issues/497#issuecomment-419897172

earthlng avatar Sep 11 '18 16:09 earthlng

Indeed, that's the solution but correct me if I am wrong ... I thought that setting is for data URIs like

data:text/html,<script>document.write(window.navigator.userAgent);</script>

Why is that setting propagate to inline scripts ? maybe I'm simply wrong.

theWalkingDuck avatar Sep 11 '18 22:09 theWalkingDuck

Is it possible to block the Canvas API with FF prefs ?

No, but More than one extension does it. And this raises issues that Mozilla folks will never solve IMHO.

In cases where both extensions add there own CSP-Headers, only one extension works properly.

Both extensions do work properly, but the outcome respects the 2nd extension (that overwrites the modification of the 1st one).

Atavic avatar Sep 12 '18 15:09 Atavic

Is it possible to block the Canvas API with FF prefs ?

contrary to what @Atavic claims, AFAIK no it's not possible to block Canvas API with FF prefs. Maybe he can enlighten us with what those prefs are ... ?

Both extensions do work properly

well, if uBO for example suddenly allows inline javascript when it should actually block it, I wouldn't say "Both extensions do work properly" but maybe that's just me

I thought that setting is for data URIs like data:text/html,...

it is.

Why is that setting propagate to inline scripts ?

it's not. 1 extension uses CSP to block inline scripts and the other uses CSP to block data URIs - only 1 can win

earthlng avatar Sep 12 '18 16:09 earthlng

Edited the previous reply.

To me these are chained issues e.g. the last extension wins, while both extensions do work.

Atavic avatar Sep 12 '18 16:09 Atavic

That means CanvasBlocker adds the CSP header by default, without scanning the document for data URIs . That makes sense ... why wasting time..? I guess that was my blind spot.

I'm sure that many of those who are using CanvasBlocker are also using some sort of content filters like uMatrix. So using Block data URL pages as a default setting is really a bad idea.

Isn't that a case for the Wiki ?

theWalkingDuck avatar Sep 12 '18 19:09 theWalkingDuck

Well it's not that easy and I don't think you can explain the issue in 2 sentences. And a lot of people will have no idea which addons can interfere with each other. Do we really want to go there and risk getting tons of questions from people about which of their addons might interfere? In some cases it also depends on addon settings. Even uBO + uMatrix interfere with each other. I use a customized version of uBO to make sure the 2 work nicely together but that only works with the way I use them

earthlng avatar Oct 23 '18 13:10 earthlng

disable then enable CB, and suddenly uM will win

AFAIK you need to disable and enable the one you want to win, not the other way around. btw NoScript has some code to make sure it always wins which is nice but if other extensions start using similar code the issue will only get worse. It's not great atm to say the least and hopefully mozilla will do something about it but I won't hold my breath

earthlng avatar Oct 23 '18 13:10 earthlng

The order is

  • install time
  • updates change that order
  • heavy webext (or webext that have issues like uBo while loading blocklists) are queued on the bottom of the chain.

So, if you have an ESR version with updates disabled the order is static. If you update, the last updates webext goes on the bottom of the chain (overwriting previous modifications). If uBo has issues while loading blacklists, it is available at a later time and is queued on bottom.

Atavic avatar Oct 23 '18 13:10 Atavic

I don't know if the order is fixed. AFAIK all extensions are started in parallel and whichever takes the longest to load will win. Unless of course they use some workaround to make sure they always win like NoScript does for example.

earthlng avatar Oct 23 '18 13:10 earthlng

Order varies with updates and is set by install time.

Atavic avatar Oct 23 '18 14:10 Atavic

try https://1337x.to/home/ - if you see the content, chances are inline script wasn't blocked.

If you block everything in uBO AND uMatrix then it's probably not an issue but I prefer to do all my JS blocking with uMatrix only for simplicity because I don't want to unblock everything twice.

Font blocking is better done with Request Control for example - that eliminates one of the potential CSP interferences that uBO can cause. But again, if you want to allow fonts on a bunch of sites it's getting a bit annoying to configure that with RC. Since I don't do that it's fine for me.

and the whole issue is not just affecting CSP. fe blocking cookies with uM or something else will also interfere with WebAPI Manager. I'm sure there are countless other problematic combinations as well

earthlng avatar Oct 23 '18 14:10 earthlng

Font blocking is better done with Request Control

Why don't you use uBlocks static filter ?

block third party font *$font,third-party

block third party fonts / exclude aaa.com, bbb.com...etc *$font,third-party,domain=~aaa.com|~bbb.com|~ccc.com

theWalkingDuck avatar Oct 23 '18 15:10 theWalkingDuck