NS blocking SmartSearch JS bookmarklet execution

Bug reports and enhancement requests

NS blocking SmartSearch JS bookmarklet execution

Postby al_9x » Fri Dec 10, 2010 9:49 am

SmartSearch opens keyworded bookmarklets, based on the selected text, in a new tab. If the keyworded bookmarklet is a javascript one "javascript:alert('%s')", NS blocks its execution. The new tab opens with the right JS url, but it doesn't get executed. Without NS, it runs.

Fx 3.6.13, NS 2.0.8.1
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13
al_9x
Master Bug Buster
 
Posts: 871
Joined: Thu Mar 19, 2009 4:52 pm

Re: NS blocking SmartSearch JS bookmarklet execution

Postby Giorgio Maone » Fri Dec 17, 2010 12:08 am

Probably WONTFIX.
NoScript needs to patch the bookmark system in order to get bookmarklets to execute.
If SmartSearch called into the bookmark API, it would likely work, but they seem to open the URL directly which, in this case, cause the JavaScript to run with a null principal which NoScript needs to block, obviously.
Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13
User avatar
Giorgio Maone
Site Admin
 
Posts: 6864
Joined: Wed Mar 18, 2009 11:22 pm
Location: Palermo - Italy

Re: NS blocking SmartSearch JS bookmarklet execution

Postby al_9x » Tue Jul 05, 2011 2:00 pm

Giorgio Maone wrote:Probably WONTFIX.
NoScript needs to patch the bookmark system in order to get bookmarklets to execute.
If SmartSearch called into the bookmark API, it would likely work, but they seem to open the URL directly which, in this case, cause the JavaScript to run with a null principal which NoScript needs to block, obviously.


Please reassess this in light of Fx 6.0 ban on javascript:. The workaround of manual reissuing of a smartsearch attempted, and blocked by NS, javascript: navigation will no longer work. Is there anything you can do? A javascript: url is being opened from privileged code so it should be allowed, if possible. If not, can you suggest something for smartsearch that will work in the presence of NS?
Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0
al_9x
Master Bug Buster
 
Posts: 871
Joined: Thu Mar 19, 2009 4:52 pm

Re: NS blocking SmartSearch JS bookmarklet execution

Postby Giorgio Maone » Tue Jul 05, 2011 2:22 pm

They could use Components.utils.Sandbox to emulate JavaScript URL execution (that's what NoScript does for bookmarklet execution on non-whitelisted pages).
Mozilla/5.0 (Windows NT 5.2; WOW64; rv:5.0) Gecko/20100101 Firefox/5.0
User avatar
Giorgio Maone
Site Admin
 
Posts: 6864
Joined: Wed Mar 18, 2009 11:22 pm
Location: Palermo - Italy

Re: NS blocking SmartSearch JS bookmarklet execution

Postby al_9x » Tue Jul 05, 2011 5:29 pm

Giorgio Maone wrote:They could use Components.utils.Sandbox to emulate JavaScript URL execution (that's what NoScript does for bookmarklet execution on non-whitelisted pages).


I emailed the author. So there is no way to know that a javascript url is being opened from privileged code (an extension calling openUILinkIn)? Also, you mentioned bookmark API, did you mean that it supports the invocation of bookmarks (something like: bookmark.open('keyword_arg', 'tab') as opposed to extracting the bookmark data and issuing the navigating oneself?
Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0
al_9x
Master Bug Buster
 
Posts: 871
Joined: Thu Mar 19, 2009 4:52 pm

Re: NS blocking SmartSearch JS bookmarklet execution

Postby Giorgio Maone » Wed Jul 06, 2011 9:44 pm

al_9x wrote:So there is no way to know that a javascript url is being opened from privileged code (an extension calling openUILinkIn)?

Yes there is, but I should patch yet another browser function (fragile!) just to support this very rare use case.
al_9x wrote:it supports the invocation of bookmarks (something like: bookmark.open('keyword_arg', 'tab') as opposed to extracting the bookmark data and issuing the navigating oneself?

More or less, yes.
Mozilla/5.0 (Windows NT 5.2; WOW64; rv:5.0) Gecko/20100101 Firefox/5.0
User avatar
Giorgio Maone
Site Admin
 
Posts: 6864
Joined: Wed Mar 18, 2009 11:22 pm
Location: Palermo - Italy

Re: NS blocking SmartSearch JS bookmarklet execution

Postby al_9x » Wed Jul 06, 2011 9:59 pm

Giorgio Maone wrote:
al_9x wrote:So there is no way to know that a javascript url is being opened from privileged code (an extension calling openUILinkIn)?

Yes there is, but I should patch yet another browser function (fragile!) just to support this very rare use case.

I guess I was hoping that it could be patched once at a sufficiently low level to catch all possible javascript: url openings from privileged code.
Giorgio Maone wrote:
al_9x wrote:it supports the invocation of bookmarks (something like: bookmark.open('keyword_arg', 'tab') as opposed to extracting the bookmark data and issuing the navigating oneself?

More or less, yes.

Please point to it. So if they used this api, instead, it would work with NS? Is that not better than the sandbox?
Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0
al_9x
Master Bug Buster
 
Posts: 871
Joined: Thu Mar 19, 2009 4:52 pm

Re: NS blocking SmartSearch JS bookmarklet execution

Postby Giorgio Maone » Wed Jul 06, 2011 10:18 pm

al_9x wrote:
Giorgio Maone wrote:
al_9x wrote:So there is no way to know that a javascript url is being opened from privileged code (an extension calling openUILinkIn)?

Yes there is, but I should patch yet another browser function (fragile!) just to support this very rare use case.

I guess I was hoping that it could be patched once at a sufficiently low level to catch all possible javascript: url openings from privileged code.

Address bar JavaScript (which we don't want to allow) is "javascript: url opening from privileged code", and at that level it cannot be discriminated anymore.
al_9x wrote:
Giorgio Maone wrote:
al_9x wrote:it supports the invocation of bookmarks (something like: bookmark.open('keyword_arg', 'tab') as opposed to extracting the bookmark data and issuing the navigating oneself?

More or less, yes.

Please point to it. So if they used this api, instead, it would work with NS? Is that not better than the sandbox?

Any PlacesUIUtils method which calls checkURLSecurity() will do.
Mozilla/5.0 (Windows NT 5.2; WOW64; rv:5.0) Gecko/20100101 Firefox/5.0
User avatar
Giorgio Maone
Site Admin
 
Posts: 6864
Joined: Wed Mar 18, 2009 11:22 pm
Location: Palermo - Italy

Re: NS blocking SmartSearch JS bookmarklet execution

Postby al_9x » Thu Jul 07, 2011 3:30 am

Giorgio Maone wrote:Yes there is, but I should patch yet another browser function (fragile!) just to support this very rare use case.


To defend this use case, the ability to process text from pages with parameterized javascript bookmarklets, transform it and make arbitrary requests based on it, is a pretty powerful extensibility mechanism, there is value in preserving it. Sure it's an advanced feature, but so is NS for the most part, so it's NS users who are more likely to use and miss it.

Giorgio Maone wrote:Address bar JavaScript (which we don't want to allow) is "javascript: url opening from privileged code", and at that level it cannot be discriminated anymore.


I debugged it a bit. It looks like you are patching loadURI. If you patch one "level" lower, loadURIWithFlags, you should be able to:

  1. intercept the SmartSearch load(openUILinkIn->openLinkIn->loadOneTab->addTab->loadURIWithFlags), fixing this issue
  2. know when the nav is user typed javascript (javascript: url and LOAD_FLAGS_DISALLOW_INHERIT_OWNER flag set)
  3. here's a nice bonus, you could optionally strip/ignore the LOAD_FLAGS_DISALLOW_INHERIT_OWNER flag, overriding the 6.0 ban on user typed javascript: this would be a welcome feature apart from this issue

Giorgio Maone wrote:Any PlacesUIUtils method which calls checkURLSecurity() will do.


I don't think openNodeIn (or anything else there) supports parameterized invocation, does it? Doesn't look like that's an option.
Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0
al_9x
Master Bug Buster
 
Posts: 871
Joined: Thu Mar 19, 2009 4:52 pm

Re: NS blocking SmartSearch JS bookmarklet execution

Postby al_9x » Sat Jul 16, 2011 3:29 pm

loadURIWithFlags patching is also needed to make built-in keyword bookmarklet invocation work in 6.0.
Mozilla/5.0 (Windows NT 5.1; rv:5.0.1) Gecko/20100101 Firefox/5.0.1
al_9x
Master Bug Buster
 
Posts: 871
Joined: Thu Mar 19, 2009 4:52 pm

Re: NS blocking SmartSearch JS bookmarklet execution

Postby Giorgio Maone » Sun Jul 17, 2011 2:47 pm

Fixed in latest development build 2.1.2.4rc2.
Mozilla/5.0 (Windows NT 5.2; WOW64; rv:5.0) Gecko/20100101 Firefox/5.0
User avatar
Giorgio Maone
Site Admin
 
Posts: 6864
Joined: Wed Mar 18, 2009 11:22 pm
Location: Palermo - Italy

Re: NS blocking SmartSearch JS bookmarklet execution

Postby al_9x » Sun Jul 17, 2011 4:53 pm

Giorgio Maone wrote:Fixed in latest development build 2.1.2.4rc2.


When addTab calls loadURIWithFlags on an a newly created browser, you haven't replaced loadURIWithFlags yet. Is it possible for you to somehow get at it earlier? I noticed they are dispatching a TabOpen event prior to calling loadURIWithFlags, can that help?

The good news, is that with allowURLBarJS the manual workaround works. By the way, I think many would be happy to know that NS now has an option to override the 6.0 urlbar js ban, you should advertise that somehow.
Mozilla/5.0 (Windows NT 5.1; rv:5.0.1) Gecko/20100101 Firefox/5.0.1
al_9x
Master Bug Buster
 
Posts: 871
Joined: Thu Mar 19, 2009 4:52 pm

Re: NS blocking SmartSearch JS bookmarklet execution

Postby Giorgio Maone » Wed Jul 20, 2011 10:09 pm

I'm investigating the cleanest way to do this early enough, thanks.
Mozilla/5.0 (Windows NT 5.2; WOW64; rv:5.0) Gecko/20100101 Firefox/5.0
User avatar
Giorgio Maone
Site Admin
 
Posts: 6864
Joined: Wed Mar 18, 2009 11:22 pm
Location: Palermo - Italy


Return to NoScript Development

Who is online

Users browsing this forum: No registered users and 4 guests