Issue with code injection when using NS

Ask for help about NoScript, no registration needed to post
namslew
Posts: 3
Joined: Tue Oct 15, 2013 7:12 pm

Issue with code injection when using NS

Post by namslew »

Hi,

I've been using NS for a while without problem but can't seem to figure out why I've just encountered the following problem. I was just visiting the website for http://www.bothwellcheese.com/about-us/ ... lades.html and by having NS running and blocking scripts it seems to have allowed a few lines of spam to be injected into the page. When scripts are allowed for the page the injected code disappears and the page displays normally. Obviously I'm a novice user and can't seem to figure out if this is a problem on my end or something with their website. The problem also occurs on several other of their pages. Thanks for the help.
Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Firefox/24.0
barbaz
Senior Member
Posts: 11089
Joined: Sat Aug 03, 2013 5:45 pm

Re: Issue with code injection when using NS

Post by barbaz »

The "problem" is on their end. Nothing is being "injected" into the page. That spam is being hidden by a script which is why it goes away with scripts allowed. I have no idea why they would do that however :?:
*Always* check the changelogs BEFORE updating that important software!
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:24.0) Gecko/20100101 Firefox/24.0 SeaMonkey/2.21
namslew
Posts: 3
Joined: Tue Oct 15, 2013 7:12 pm

Re: Issue with code injection when using NS

Post by namslew »

Thanks barbaz. I just wasn't sure if it was a vulnerability on my system that was allowing code to be injected into webpages or something there. And were you asking why they'd use a script to hide the problem rather than solve it?
Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Firefox/24.0
barbaz
Senior Member
Posts: 11089
Joined: Sat Aug 03, 2013 5:45 pm

Re: Issue with code injection when using NS

Post by barbaz »

namslew wrote:were you asking why they'd use a script to hide the problem rather than solve it?
No question intended, I was just trying to say that the whole thing seems really odd and implying that you should be extra careful about what scripts you allow on that site. The :?: icon is just the closest thing to a "confused" smiley that this board has. Sorry about the misunderstanding.
*Always* check the changelogs BEFORE updating that important software!
Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Firefox/24.0 SeaMonkey/2.21
namslew
Posts: 3
Joined: Tue Oct 15, 2013 7:12 pm

Re: Issue with code injection when using NS

Post by namslew »

Ahh gotcha. I was rather confused by it also, hence why I asked about it. Again, thanks for your help and for taking the time to answer my question. :D
Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Firefox/24.0
User avatar
Thrawn
Master Bug Buster
Posts: 3106
Joined: Mon Jan 16, 2012 3:46 am
Location: Australia
Contact:

Re: Issue with code injection when using NS

Post by Thrawn »

:D Although this website behavior is somewhat evil, it's actually rather clever! They know that an actual <noscript> element could be detected and neutralised by something like NoScript or an ad-blocker, so they instead put the ad in the page unconditionally, and remove it if you allow JavaScript! I have to tip my hat to their creativity.

The ID of the ad element doesn't seem to change, so you could try using a surrogate script to run the ad-hiding code.

In about:config, add a new string value 'noscript.surrogate.bothwell.sources' set to

Code: Select all

!www.bothwellcheese.com
and another value 'noscript.surrogate.bothwell.replacement' set to

Code: Select all

if(document.getElementById('bjyhplkvj') != null){document.getElementById('bjyhplkvj').style.display = 'none'; document.getElementById('bjyhplkvj').style.width = '0px'; document.getElementById('bjyhplkvj').style.height = '0px';}
======
Thrawn
------------
Religion is not the opium of the masses. Daily life is the opium of the masses.

True religion, which dares to acknowledge death and challenge the way we live, is an attempt to wake up.
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:24.0) Gecko/20100101 Firefox/24.0
User avatar
Thrawn
Master Bug Buster
Posts: 3106
Joined: Mon Jan 16, 2012 3:46 am
Location: Australia
Contact:

Re: Issue with code injection when using NS

Post by Thrawn »

OK, so it looks like the ID does change after all, and it is different on different pages.

But thus far, it has always been a string of 9 lowercase letters.

Try putting this in 'noscript.surrogate.bothwell.replacement':

Code: Select all

var divs = document.getElementsByTagName('div'); for (var i = 0; i < divs.length; i++) { if (/^[a-z]9$/.test(divs[i].id)) { divs[i].style.display = 'none'; divs[i].style.width = '0px'; divs[i].style.height = '0px'; } }
That seems to catch the spam, and thus far I haven't noticed it breaking anything.
======
Thrawn
------------
Religion is not the opium of the masses. Daily life is the opium of the masses.

True religion, which dares to acknowledge death and challenge the way we live, is an attempt to wake up.
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:24.0) Gecko/20100101 Firefox/24.0
Post Reply