Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sticky: user scripts #75

Closed
Thorin-Oakenpants opened this issue Mar 28, 2017 · 60 comments
Closed

sticky: user scripts #75

Thorin-Oakenpants opened this issue Mar 28, 2017 · 60 comments

Comments

@Thorin-Oakenpants
Copy link
Contributor

Thorin-Oakenpants commented Mar 28, 2017

Use this issue to suggest scripts for our wiki section Further Hardening: Extension Scripts. We're looking for scripts that enhance privacy and security, and block tracking and fingerprinting.

Please try to stick to general/global or major site specific scripts (such as google), rather than obscure sites no one really cares about.

Please note: The comments here will be regularly cleaned out to keep this sticky usable

@crssi
Copy link

crssi commented Mar 28, 2017

Some sites are trying to set tracking ID by adding ?something after the img url
see example: http://somedomain.com/blahblah/blah/image.jpg?21dd8daded_61880689
Maybe its nothing, but I just don't trust the hash after "?"... maybe someone can comment about it?

I am using REDIRECTOR to strip those out:
Include pattern; (.*\.(gif|jpg|png|svg))\?.*
Redirect to: $1
Pattern type: regular expression
Apply to: Images

@publicarray
Copy link

@crssi sometimes these are used as unique links and sometimes they are part of the authentication mechanism. e.g. Only users with the exact link are allowed to see the file or image.
e.g. Facebook: https://scontent-syd2-1.xx.fbcdn.net/v/t34.0-1/p160x160/16176889_112685309244626_578204711_n.jpg?oh=21587895d22fb2b678e2f60285c4e240&oe=59CAC063 without the ?oh= or &oe= fb replies with 403 (Forbidden)

@crssi
Copy link

crssi commented Sep 25, 2017

@publicarray thank you.
Months ago I have dropped REDIRECTOR, since there are some problems with it.
For this "tracking" over the images I am using now Request Control with additional exclusions.

The rule definition:

[ { "pattern": { "scheme": "*", "host": [ "*" ], "path": [ "*.jpg?*", "*.gif?*", "*.png?*", "*.svg?*" ] }, "types": [ "main_frame", "sub_frame", "image" ], "action": "filter", "active": true, "skipRedirectionFilter": true, "paramsFilterPattern": ".*", "paramsFilter": { "values": [ "w", "h", "crop", "s", "q", "auto", "fit", "size", "v", "height", "width", "dl", "sigh", "displayname", "oe", "oh" ], "invert": true }, "title": "Filter%20rule%20for%20*" } ]

RC also has "problems", but not in this case and this rule is the only rule I am using under RC.
For everything else about URL manipulation I am using now Skip Redirect for redirection control (its best one and works without a glitches out-of-the.box) and Neat URL for parameters stripping with the following configuration (default + quite big of additional chunk):

$/ref@amazon.*, _encoding@amazon.*, _hsenc, _hsmi, _openstat, action_object_map, action_ref_map, action_type_map, algo_expid, algo_pvid, aqs, bav, bih, biw, btsid, bvm, cn, cp, csi, [email protected], dpr, dq, ech, ei@google.*, fb_action_ids, fb_action_types, fb_ref, fb_source, [email protected], [email protected], forward, ga_campaign, ga_content, ga_medium, ga_place, ga_source, ga_term, [email protected], gs_gbg, gs_l, gs_mss, gs_rn, gws_rd@google.*, iact, icid, iid, ijn, [email protected], mkt_tok, ncid, ndsp, nid, nr_email_referer, oq, pbx, pd_rd_r@amazon.*, pd_rd_w@amazon.*, pd_rd_wg@amazon.*, pf, pf_rd_i, pf_rd_m, pf_rd_p, pf_rd_r, pf_rd_s, pf_rd_t, pq, [email protected], prmd, psc@amazon.*, psi, [email protected], ref_, refsrc, sa, [email protected], sclient, scroll, sei@google.*, [email protected], [email protected], sr_share, stick, tbnid, utm_campaign, utm_cid, utm_content, utm_medium, utm_name, utm_place, utm_pubreferrer, utm_reader, utm_source, utm_swu, utm_term, utm_userid, utm_viz_id, ved, ved@google.*, vero_conv, vero_id, vet, ws_ab_test, yclid, yv

@ZIEXED
Copy link

ZIEXED commented Dec 17, 2017

@Atavic
Copy link

Atavic commented Dec 28, 2017

@Thorin-Oakenpants
Copy link
Contributor Author

@earthlng & co - see pes10k/web-api-manager#75 re thwarting Page Visibility API and peter's comments. Can this be beefed up to cover the things mentioned?

It doesn't handle the vendor prefixed versions of each feature, so the same information might be accessible through document.mozHidden or document.webkitHidden, etc

while not really necessary from a privacy/security perspective, I'm quite keen on it. I came across it on a reddit thread about a month ago, and then this reddit thread reminded me I had it

@ghost
Copy link

ghost commented Apr 17, 2018

Clear window.opener script appears to be unsuccessful when tested at About rel=noopener

There is another script which is flawless: noopener_by_default

Edit by Thorin: but this new script has some issues: see earthlng's comment , so do not use, see the new issue #401 and wait for what we come up with

@Thorin-Oakenpants
Copy link
Contributor Author

Thorin-Oakenpants commented Apr 17, 2018

note: FF59.0.2, using Violentmonkey (scripts are run @document-start)

❗ EDIT: kinda slightly messed up with temp JS rules in uM. With all JS allowed now and locked in, I fail both tests with clear window.opener


"clear window.opener"

Click me!!1 (same-origin)

  • loads malicious in a new tab and displays "Why don’t you go back to the previous tab?"
  • the previous tab has been changed to ...#hax so it displays 0m6 you’ve been h4ck3d!!1one!shift!!!1 at the top

Click me!!1 (cross-origin) ✔️

  • loads demo/opener in a new tab and displays "Why don’t you go back to the previous tab?"
  • the previous tab is unchanged

"noopener by default"

The script says "@description blah blah blah. For Chrome only. blah blah", but I tested it anyway. Seems fine.

Click me!!1 (same-origin) ✔️

  • loads a new tab with malicious.html and displays "The previous tab is safe and intact. window.opener was null; mischief not managed!"
    • WTF does "mischief NOT managed" mean? sounds back to front to me!
  • the previous tab is unchanged

Click me!!1 (cross-origin) ✔️

  • same result as clear window.opener

Note: for both scripts, cross-origin causes CSP console errors. There are no console errors for same-origin.

I'll leave this in earthlng's hands

@ghost
Copy link

ghost commented Apr 17, 2018

FF59.0.2, using Violentmonkey as well here.
Thanks for developing.

@crssi
Copy link

crssi commented Apr 17, 2018

Why would window.opener be a problem on same-origin?
Asking, since I blindly do not see the real problem there might be.

@earthlng
Copy link
Contributor

earthlng commented Apr 17, 2018

  1. if the cross-origin test displays "Why don’t you go back to the previous tab?" but the previous tab is unchanged you probably didn't allow JS on that page.
  2. FPI together with privacy.firstparty.isolate.restrict_opener_access=true already covers cross-origin window.opener tampering EDIT: nvm, my bad
  3. my script works perfectly fine with legacy Greasemonkey in ESR. The problem is that webextension user-script addons apparently can't guarantee that @run-at document-start works reliably or works at all. The greasemonkey wiki has this to say:

@run-at document-end ... The only guaranteed working value, in Greasemonkey 4.0.

I assume the same is true for Violentmonkey and others.

The greasemonkey wiki provides a code example to test if any @run-at document-start script actually runs at document-start:

if ('loading' == document.readyState) {
  alert("This script is running at document-start time.");
} else {
  alert("This script is running with document.readyState: " + document.readyState);
}

I tried it numerous times and not once did I get an This script is running at document-start time. alert! So the problem is much worse than just my script not working reliably (or at all) because any and all user-scripts which need to run at document-start don't work. Nothing I can do about it, it's up to either mozilla to fix this or to the addon devs to come up with a workaround.

EDIT: thanks @mazesy for letting us know 👍

EDIT2: middle-clicking a link opens the tab in such a way that document-start scripts work correctly

@earthlng
Copy link
Contributor

Why would window.opener be a problem on same-origin?

because of user-generated content on a website

@ghost
Copy link

ghost commented Apr 17, 2018

I'm not at all into coding, need to repeat. I just happened to run a test page, noticed a script apparently wasn't doing the job when another performed correctly.

Javascript never disabled here.
The other script, noopener_by_default, doesn't include any @run-at ... and yet works.

I'm not discussing, only submitting. I'm fully aware this could be a false-positive. No idea, really.

@crssi
Copy link

crssi commented Apr 17, 2018

because of user-generated content on a website

yes, but its the same origin... isn't that quite normal by some web apps to pass some data to a new window/tab
I still don't see the problem until this is not happening cross origin

@earthlng
Copy link
Contributor

earthlng commented Apr 17, 2018

EDIT2: middle-clicking a link opens the tab in such a way that document-start scripts work correctly

to clarify, middle-clicking lets a script (reliably?) run at document-start but it's not guaranteed that the script works as expected. Something fundamentally changed with webextensions vs legacy which means some scripts need to be rewritten to work with webextension user-script addons. For example the Conceal history.length user-script from the wiki doesn't work anymore even if it happens to run at document-start. Conceal window.name most likely doesn't work anymore either but I haven't tested it.

@ghost
Copy link

ghost commented Apr 17, 2018

Something fundamentally changed with webextensions vs legacy which means some scripts need to be rewritten to work with webextension user-script addons.

That explains why clear window.opener runs flawlessly with legacy Greasemonkey in ESR, OK

About conceal history.length : impossible to determine its validity here considering I always get
Number of pages visited in History 1 on dedicated BrowserSpy test page, script activated or not.

About Conceal window.name : seems to do the job considering I get, on dedicated JoDonym test page,
Tab name -- "window.name" has been anonymized.when script is active
Tab name -- "window.name" is traceable. Your unique ID: xxxxxxx with script deactivated

Really odd, and triggers an alarm if it appears that scripts run by a legacy script manager run differently when applied with a webextension script manager. This would be a scoop.

I repeat, running scripts with ViolentMonkey 2.9.1 (hence Webextension) on Firefox 52.0.2 (64-bit).

@Thorin-Oakenpants
Copy link
Contributor Author

Edited my post to clarify re JS running - I had allowed it, but forgot the cross origin one.

The other script, noopener_by_default, doesn't include any @run-at ... and yet works.

@mazesy The document run is in the script settings of the VM dashboard
vm

@earthlng 57+ users, we recommend VM. When I migrated to VM (I think this was around FF54 or 55) there were so many issues with mixing legacy and non-legacy apps (uBO/uM + GM caused lots of weird behavior such as direct images not loading - ask @grauenwolfe and @atomGit ). The three scripts required @document-start to work, and VM was the only one that worked (at the time).

I don't know the state of GM now, but they were massively late to the party, even months later you still couldn't save scripts and stuff. Can you do your document start test in VM?

@ghost
Copy link

ghost commented Apr 17, 2018

@Thorin-Oakenpants ,

The document [noopener_by_default] run is in the script settings of the VM dashboard

So true... I had forgotten that!
Nevertheless, concerning the noopener_by_default script, I had simply copy/pasted it without modifying its settings pane, so I have thereRun-At -- (Default) (and the script makes it such as)

So then, concerning our Clear window.opener script, it appears I had as well not set its Run-At -- to document-start in its setting pane. I installed again, set this time document-start but the script continues as before with Run-At -- (Default) : inefficient (apparently considering what @earthlng mentioned afterwards), anyway still inefficient when run with ViolentMonkey (webext) on FF52.0.2.

@Thorin-Oakenpants
Copy link
Contributor Author

Thorin-Oakenpants commented Apr 17, 2018

conceal history.length

works fine on both browserspy and jodonym. They are both run at document start in VM.

STR

  • disable conceal history.length
  • go to the wiki in a NEW TAB, click around and load five or six pages in that tab, the last one being the user scripts page
  • click the browserspy link and the number of pages in (tab) history will be correctly shown
  • enable conceal history.length from the VM toolbar button and the test page reloads and history is now 2
  • toggle it on and off. It works

^^ Ditto for same script tested on JoDonym's "tab history"


conceal windows.name

Exact same thing, except I already had the JoDonym open in that tab (the one I had lots of history in), so instead I toggled conceal windows.name. The script works.


noopener by default

works every time: is run at document-start: And as I type Tom just said it works as run at Default. I do not know what "default" means.


conclusion

clear window.opener needs tweaking for VM and it will work. Wiki can hold two versions, a legacy GM version and a 57+ VM version

@earthlng
Copy link
Contributor

earthlng commented Apr 17, 2018

Can you do your document start test in VM?

your test results clearly indicate that VM doesn't work correctly either.

@mazesy

I always get Number of pages visited in History 1 on dedicated BrowserSpy test page, script activated or not

you need to click a couple of other links on that page to increase the number of pages in your history

@ghost
Copy link

ghost commented Apr 17, 2018

conceal history.length and conceal windows.name indeed both do it, but here both are set to Run-At -- [Default) ... and both of those scripts state by themselves @run-at document-start

Now, one thing I ignore with ViolentMonkey : does a script's setting pane prevail on the script's settings (when available) or not? I mean, if the script itself states // @run-at document-start and if its settings pane instructs Run-At (Default) will the script be ran at document-start in this example? I guess it will if the setting is {Default) but if there is contradiction (document-start/end) then perhaps the settings pane will prevail..

@ghost
Copy link

ghost commented Apr 17, 2018

@earthlng ,

you need to click a couple of other links on that page to increase the number of pages in your history

I had done that, aware. Opened several other tabs, reloaded BrowserSpy, Always got 1
That's why I was puzzled...

@earthlng
Copy link
Contributor

Opened several other tabs

that doesn't work. history is per tab, you need to open a couple of links in the same tab.

@atomGit
Copy link

atomGit commented Apr 17, 2018

if there's any chance these scripts will be modified at some point, i might suggest adding the update URL param to them and host them in an appropriate repo

Wiki can hold two versions, a legacy GM version and a 57+ VM version

far as updating scripts based on browser version, i don't know if that's possible, but it sounds like there may be a need for it ... OR, can the script itself determine the browser version and run the appropriate code maybe???

@ghost
Copy link

ghost commented Apr 17, 2018

that doesn't work. history is per tab, you need to open a couple of links in the same tab

Oh, right. Gosh, so logic... testing ...Yeah, OK, with the script active, max is 2, otherwise it incements. My fault.

@Thorin-Oakenpants
Copy link
Contributor Author

Thorin-Oakenpants commented Apr 17, 2018

your test results clearly indicate that VM doesn't work correctly either

Say what? On VM, with run @ document start, I just showed the two tests work, as does the new one. The only one failing out of all four is clear window.opener (edit, i.e in non legacy extensions)

Edit: Oh, the very first test that showed that clear window.opener failed, which is what I just said. My point is that VM doesn't seem to have a problem with document-start - hence why I asked you to run the document-start test on VM

@ghost
Copy link

ghost commented Apr 17, 2018

We have -- I have, anyway, here with ViolentMonkey on Firefox 59,

  • Conceal history.length : no problem
  • Conceal window.name : no problem
  • Clear window.opener : problem

All three with // @run-at document-start (code and settings-pane with Run-At=(Default)

@Thorin-Oakenpants
Copy link
Contributor Author

Tom - make them run @ doc start. Default (from some quick searches) seems to be run at document end, meaning that as soon as the initial HTML document is ready, the script may be executed. I am not an expert, but content scripts can already be done and dusted before that, so user scripts can in those cases, not work.

@ghost
Copy link

ghost commented Apr 17, 2018

Surprise with Conceal history.length:
I've changed the script's itself to: // @run-at document-end
I've changed in ViolentMonkey, the script's / Settings to Run-At - document-end
I open BrowserSpy's test page... and the script runs perfectly (blocked at 2)!

@Thorin-Oakenpants
Copy link
Contributor Author

Thorin-Oakenpants commented Apr 17, 2018

I have nothing in the script. I changed it to run-at-end and it FAILS - for the last F time, you must use doc-start.

Why do you think 3 different authors explicitly used // @run-at document-start in their GM scripts

@ghost
Copy link

ghost commented Apr 17, 2018

@Thorin-Oakenpants , but are you on Firefox ESR or Quantum?
OK: I remove in the script its run-at and set in Settings Run-At - document-end ... and it works as well! (not sure we're not exiting the logic zone)

@Thorin-Oakenpants
Copy link
Contributor Author

I am on Quantum, why would I be testing VM and scripts on ESR? Please tell me you aren't doing all this on ESR

@ghost
Copy link

ghost commented Apr 17, 2018

No, no, Quantum Level Firefox 52 :=)

why would I be testing VM and scripts on ESR?
I must have mixed up with @earthlng who is running on ESR if I understood correctly

@Thorin-Oakenpants
Copy link
Contributor Author

What does that mean. What FF version are you doing this all on?

@ghost
Copy link

ghost commented Apr 17, 2018

Firefox 59.0.2 ... x64 ... sorry

@Thorin-Oakenpants
Copy link
Contributor Author

Well FFS ... no wonder. You're using a 7 version OLD release (in terms of features, not security updates). FFS!! what a waste of time, comapring apples to oranges. We KNOW the legacy version of GM and the scripts work. This is ALL ABOUT 57+ and web extensions (seems to fail in GM but work in VM except that one script which I am sure can be fixed if earthlng wants to, otherwise we can point to the new script or use an extension).

@ghost
Copy link

ghost commented Apr 17, 2018

@Thorin-Oakenpants , I'm missing something: what's this 7 version old have to do here? I corrected: I'm running and running these tests on Firefox 59.0.2 64-BIT.
Ouf!

@Thorin-Oakenpants
Copy link
Contributor Author

In fact 52.0.2 isn;t even the latest ESR

2017-03-07: 52.0 - over a year old

@ghost
Copy link

ghost commented Apr 17, 2018

It's not 52, it's 59; me have mistaked numbers!

@Thorin-Oakenpants
Copy link
Contributor Author

I'm running anr running these tests on Firefox 59.0.2 64-BIT.

Then why did you say you were doing it on 52.0.2. I give up

@ghost
Copy link

ghost commented Apr 17, 2018

Because I typed wrong, I had the 2 from Firefox 59.0.2 in mind, I guess!
Don't give up! Ypu want my ID, driver's license? Firefox 569.0.2, for whispering out loud!

@Thorin-Oakenpants
Copy link
Contributor Author

This sticky has become a massive useless thread now on a side issue of how VM uses run-at. END of STORY - use doc-start. I don't care HOW yu do it. Its on you.

What we need to do it decide if earthlngs script can be changed to work on 57+ VM, or we just go with the new one, or point to an extension (there are several from memory), and edit the wiki accordingly.

@Thorin-Oakenpants
Copy link
Contributor Author

And in order to move forward, we just need earthlng to decide what he wants to do

@ghost
Copy link

ghost commented Apr 17, 2018

@Thorin-Oakenpants it's getting late, indeed (in EU anyway).

As I said above,

  • Conceal history.length : no problem
  • Conceal window.name : no problem
  • Clear window.opener : problem

There's one problem and one only: Clear window.opener ran with ViolentMonkey 29.1 on Firefox 59.0.2 (x64) and maybe in other configurations, and run-at may not be the culprit...

I'm off to bed. Sleep well, sweet dreams.

@Thorin-Oakenpants
Copy link
Contributor Author

There's one problem and one only: Clear window.opener ran with ViolentMonkey 29.1 on Firefox 59.0.2 (x64) and maybe in other configurations.

No. VM stable is currently 2.9.1 (or 29.1 in your typo) and the script DOES NOT WORK (on 59.0.2). It does not ran. That's the whole reason you brought it up.

@earthlng
Copy link
Contributor

apparently, without looking at the code, just based on your test results, VM uses a different way to inject the scripts and that's why the user-scripts work in their current form. However that method comes with a different set of problems. For example I'm pretty sure the window.opener script doesn't work because the demo page is hosted on a domain with strict CSP rules. That means you can't rely on your user-scripts to work on potentially malicious pages, at all.
I can think of at least 1 other problem but won't bother you with the details.

re: the 2 different scripts: noopener_by_default works by modifying the links on the original page, while "my" user-script works on the "new" page.

noopener_by_default has several issues (1) it's less efficient because it modifies all links targeting a new tab, (2) can easily be tricked to not modify a malicious link, (3) and maybe most importantly, it doesn't clear window.opener when a page uses window.open(). There might be other problems as well, fe. a form can also have target=_blank and it's possible that a page opened that way could also have access to window.opener. If it does then noopener_by_default does nothing against that, either. It can also break a page because adding rel=noopener to a link apparently opens the page without the referer header.
The script in the wiki has none of these problems because it works on the "new" page.

@Thorin-Oakenpants
Copy link
Contributor Author

Thorin-Oakenpants commented Apr 18, 2018

#401

@ghost
Copy link

ghost commented Apr 18, 2018

@Thorin-Oakenpants

No. VM stable is currently 2.9.1 (or 29.1 in your typo) and the script DOES NOT WORK (on 59.0.2). It does not ran. That's the whole reason you brought it up.

What's this useless nagging? Of course it's VM 2.9.1, of course I meant There's one problem and one only: Clear window.opener when run with ViolentMonkey 29.1 on Firefox 59.0.2 (x64) and maybe in other configurations, and run-at may not be the culprit..., the whole context of the thread makes it obvious! If we start focusing on typos and grammar we're loosing time, Pants.

I brought up this issue, indeed, which makes my typos and language issues irrelevant.

@earthlng ,
OK, looks like indeed the script manager (VirtualMonkey) influences the way a script is deployed.
I reported the issue, it is acknowledged and reveals a deeper problematic. From there on what's to be done is above my skills.

@Thorin-Oakenpants
Copy link
Contributor Author

What's this useless nagging?

Wot. That was to clarify so there was no more misunderstanding. You're reading too much into what is just TEXT (which does not emote well). Nothing was meant by it

@ghost
Copy link

ghost commented Apr 18, 2018

That was to clarify so there was no more misunderstanding.

Everyone, anyone having read the thread understood what I meant. It was late, for us all. Further emphasizing would bring this very comment useless as well. Let's stay focused on the scripts and on what appears to be a ViolentMonkey interference.

@ghost
Copy link

ghost commented Apr 18, 2018

Then stop going on about it

Who started dabbing?
I don't read into people, your personal life is neither of my concern nor of my curiosity. Remains the fact you become picky quite easily when other times you are the most sympathetic person I can imagine; fortunately the latter compensates the former.

@ghost
Copy link

ghost commented Apr 18, 2018

Any more of this and I will just block you

A threat as a last resource. Well just do it then.

for some reason you rub me the wrong way a bit of the time

You rub as well, and not only me.

Calm down or block, it's up to you. But I never adapt to threats and, should I be forgotten here that I'd forget it as quickly. Think about it.

@crssi
Copy link

crssi commented Apr 18, 2018

@earthlng, could you take a look at this please #401 (comment)
Thank you so much
Cheers

@Thorin-Oakenpants
Copy link
Contributor Author

Wiki page now asks for further submissions on scripts to be a new issue. This sticky is over!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

7 participants