Skip to content
This repository has been archived by the owner on Oct 24, 2020. It is now read-only.

Scriptlet injection banned by CSP #26

Open
DrIT2016 opened this issue Aug 2, 2019 · 13 comments
Open

Scriptlet injection banned by CSP #26

DrIT2016 opened this issue Aug 2, 2019 · 13 comments
Labels
Browser Bug Browser issue just place for remind wontfix This will not be worked on

Comments

@DrIT2016
Copy link

DrIT2016 commented Aug 2, 2019

Describe the issue (Required)

Extra resources of nano (e.g. nanop-click-elements-onready.js) mostly don't work when using it in own filters (and setting advanced setting ""). While the exact same rules do work in chrome. So looks like problem with firefox version to use these extra resources correctly?

Screenshots (Required)

Screenshot of console (Required, press F12 to open the console)

gelderlander

URLs where this issue occurs (Required if applicable)

https://radar.avrotros.nl/
https://www.gelderlander.nl

Reproduction Steps (Optional if trivial)

Go to site and see cookie wall/cookie message not getting clicked. Do it in chrome and the button will get clicked.

Anything else you believe to be useful (Optional)

Environment (Required)

  • Operating System and Version: Win 7
  • Browser and Version: Firefox/Waterfox latest
  • Nano Adblocker Version: latest
  • Nano Defender Version (Optional if you are not using it): lateset

Your filter lists (Required)

ootb

Your custom filters (Required if you have any)

avrotros.nl##+js(nanop-click-elements-onload.js, button.ccm_btn:nth-child(1))
myprivacy.persgroep.net##+js(nanop-click-elements-onready.js, button.button:nth-child(3))

@LiCybora LiCybora added the bug Something isn't working label Aug 3, 2019
@LiCybora
Copy link
Owner

LiCybora commented Aug 3, 2019

My guess is race condition. Because your rules works for me when I clicking into another site. It just not works with refreshing page.

Edit: I tried Chromium (not Chrome) and it also not click the button sometimes.

@LiCybora LiCybora added the WIP Work in Progress label Aug 3, 2019
@LiCybora
Copy link
Owner

LiCybora commented Aug 3, 2019

Possibly related: LiCybora/NanoDefenderFirefox@a8c12d6

@jspenguin2017
Copy link

If onready is too early, try onload.

@LiCybora
Copy link
Owner

LiCybora commented Aug 3, 2019

The first one is already onload but still fail.
The second one will not work due to the CSP block all inline script, not sure how it can work on Chrome.
image

image

Btw, @jspenguin2017 how about add optional third argument for delay the click execution in the snippet?

@jspenguin2017
Copy link

Inline scripts injected by extensions should bypass CSP.

@jspenguin2017
Copy link

Allowing timeout would allow complex operations, which has security implications. Although privileged script snippets are suppose to be powerful, they should not be too dangerous. I'll need to think about it.

@LiCybora
Copy link
Owner

LiCybora commented Aug 3, 2019

Inline scripts injected by extensions should bypass CSP.

Yes if they are injected via Content Script (that's why ND activation console is not affected). However, snippet injection is via creation of <script> node to the document, which is therefore inline(?). But it works on Chromium, I may need to check documentation.

Edit: See https://bugzilla.mozilla.org/show_bug.cgi?id=1267027

Allowing timeout ...

The reason I ask for setTimeout is because the button is created by xhr via script, not the document itself. This cause the button not available during document ready state claimed as complete, and thus the clicking script not always work.

In worst situation, consider fixing in ND...

@LiCybora LiCybora added Browser Bug Browser issue just place for remind and removed bug Something isn't working labels Aug 3, 2019
@jspenguin2017
Copy link

jspenguin2017 commented Aug 3, 2019

You can try this: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Sharing_objects_with_page_scripts

I'm not sure why gorhill didn't do it that way, there may be gotchas along the way.

@jspenguin2017
Copy link

jspenguin2017 commented Aug 3, 2019

I know the script snippets don't always work, and I have never claimed that they do. As I said, allowing custom timeout may have security implications, and I have to think about it.

I will not add annoyance fixes to ND.

@LiCybora LiCybora added wontfix This will not be worked on and removed WIP Work in Progress labels Aug 3, 2019
@LiCybora
Copy link
Owner

LiCybora commented Aug 3, 2019

1st site will not be fixed due to limitation of snippets.
2nd site is affected by browser bug. Issue will keep open until workaround is done or Mozilla fix it. I may try the workaround if I have time.

@LiCybora LiCybora changed the title Extra resources not working correctly Scriptlet injection banned by CSP Aug 3, 2019
@DrIT2016
Copy link
Author

DrIT2016 commented Aug 3, 2019

So if i understand correctly, some sites do not work with these snippets because of limitation? Strange i got it working with NB on Vivaldi (i said chrome, but tested with Vivaldi).
Other sites work fine like f.e hardware.info##+js(nanop-click-elements-onload.js, #decision), that's because these sites don't have this limitation?
Is there something i can do myself to get it working? Don't want to go back to i don't care about cookies addon, so hopefully there's something (maybe an other script click mechanism with addon or greasyfork or something)?

@jspenguin2017
Copy link

jspenguin2017 commented Aug 3, 2019

The first site is a won't fix as per Filters Policy: https://github.com/NanoAdblocker/NanoFilters

I'll land a fix for the second site for Chromium.

jspenguin2017 added a commit to NanoAdblocker/NanoFilters that referenced this issue Aug 3, 2019
@jspenguin2017
Copy link

jspenguin2017 commented Aug 3, 2019

The privileged script snippets are not designed to be a replacement for I Don't Care About Cookies. You can make an Userscript or extension for yourself to implement missing pieces.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Browser Bug Browser issue just place for remind wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants