Activate your free membership today | Log-in

Friday, June 1st, 2007

Spyjax: Using a:visited to test your history

Category: JavaScript, Security

Spyjax can scare you, or excite you depending on what you want to do.

By using a simple JavaScript check on the CSS style on URLs, a script can work out if you have been there:

JAVASCRIPT:
  1.  
  2. function hasLinkBeenVisited(url) {
  3.         var link = document.createElement('a');
  4.         link.href = url;
  5.         document.body.appendChild(link);
  6.         if (link.currentStyle) {
  7.                 var color = link.currentStyle.color;
  8.                 if (color == '#ff0000')
  9.                         return true;
  10.                 return false;
  11.         } else {
  12.                 link.setAttribute("href",url);
  13.                 var computed_style = document.defaultView.getComputedStyle( link, null );
  14.                 if (computed_style) {
  15.                         if (computed_style.color == 'rgb(255, 0, 0)')
  16.                                 return true;
  17.                 }
  18.                 return false;
  19.         }
  20. }
  21.  

Couple this with the ability to chunk this over time, and you could quickly test a lot of URLs.

Spyjax

Posted by Dion Almaer at 1:27 am

+++--
3.9 rating from 30 votes

18 Comments »

Comments feed TrackBack URI

This is most interesting ;)
Incredibly simple yet powerful. I’ve thought about it some time ago.

Anyways, I believe it will be considered a hack and blocked by browsers in the near future, same as cascading-killer-popups and other funny things, that have been invented since Netscape 3 :)

Have a great day!

Comment by Joustin — June 1, 2007

Technique from 2006 … http://jeremiahgrossman.blogspot.com/2006/08/i-know-where-youve-been.html … how exciting. Where are the cool new things, ah, I remember its Friday again ;-)

Comment by digitarald — June 1, 2007

Yep - this is just a rip off based on the work of Jeremiah Grossman and Robert Hansen. The PoCs included just ten or twenty URLs to test - this one seems to use over 10K URLs. This definitely crosses a border - bad stuff!

My 2cents…
.mario

Comment by .mario — June 1, 2007

While there’s nothing novel here, it’s nice to have that code wrapped up, free and ready to use. IIRC, the earlier PoCs had some problems with performance, not all of them were cross-browser and I don’t rememeber how they were licenced.

Comment by a hovering ox — June 1, 2007

Great thing)

Comment by dienow — June 1, 2007

Don’t complain that this project is nothing new. The guys at Merchanto.com even state that.

Quote from http://www.merchantos.com/makebeta/tools/spyjax/:

Comment by Stephan — June 1, 2007

-.- … here’s the quote:

“[...]based on the Hey you! Where have you been? blog post by Peter van der Graaf and script from Jeremiah Grossman and Robert Cabri[...]“

Comment by Stephan — June 1, 2007

This is sad … do people not remember the article from August 25, 2006 on ajaxian.
http://ajaxian.com/archives/its-friday-how-web-20-aware-are-you

Comment by Tahir Khan — June 1, 2007

except Grossman’s “Where have I been?” trick isn’t working (for me anyway) anymore

Comment by BillyG — June 1, 2007

I wrote the “web 2.0 awareness test” that checks around 45 URLs for fun, but a script that scans thousands of URLs with the potential to send the results somewhere is not, IMHO, very cool.

It has been a known potential issue for quite a long time (see this Mozilla bug from 2000 with :visited):
https://bugzilla.mozilla.org/show_bug.cgi?id=57351

Comment by Scott Schiller — June 1, 2007

…thanks for the post and the info. This is good to know about. I, for one, did not know it was out there, guessing others didn’t too. Interesting stuff, thanks, Ajaxians

Comment by Mark Holton — June 1, 2007

wow, good stuff!!! very excited to try it out later tonight and see what I can find out.

Comment by Liming — June 1, 2007

Hah, changed the browser setting (firefox -> tools -> options -> content -> colors) to display both visited and unvisited links in same color and spyjax didn’t find jack … :)

Comment by Vasili Sviridov — June 1, 2007

Hey Everyone,
Thanks for commenting on Spyjax. I put a good amount of my free time into it over the course of a week or two. So it’s nice to see people talking about it!
-justin

Comment by Justin — June 1, 2007

Re Vasili: you can easily change the script to not check the visited color, but, for instance margin-right, or text-indent, or background-repeat or whatever…

As long as :visited is allowed in CSS and getComputedStyle/currentStyle is allowed and accurate in JS this will be a problem.

And if they block getComputedStyle for link-elements, I could, just as easily make sure my a:visited has side-effects on an ancestor-element (by setting display to block and height to 1000px for instance) and my script can detect it by checking that ancestor element.
And disabling all getComputedStyle/currentStyle-informaton will break a lot, if not all, animations/ajax/js.

So I don”t see a solution here. Except disabling :visited in CSS.

Comment by lon — June 1, 2007

Re Ion: that’s true. It’s pretty much a chicken and egg problem - I disable this, you enable that, and so on and so forth… For now i’ll just adblock the js and php with those names. Just in case :)

Comment by Vasili Sviridov — June 1, 2007

I read a poll published Oct 27, 2004 from Bentley College that states “49 percent of internet users are not aware of security flaws in Internet browsers”. Further, “48 percent are rarely sure or are unsure that sensitive information is encrypted before transmitting it over the Internet”. I’m sure that these figures have changed slightly since the end of 2004, but I don’t think public awareness of Internet security issues has significantly changed. Very few internet business even address browser security issues beyond general warnings. For the most part web publishers seem Dependent on these kind of tracking tools to target potential customers or deliver targeted ads.

The answer to browser and identity security concerns isn’t solved by updating browsers or turning off javascript. Statistics show that a little less than half of all Internet users are even aware of security flaws. You will find significantly fewer people aware of the vast amount of information personal information being collected, let alone the intrusive methods that are used to collect that information. In regard to these issues the average internet user would probably see words like “javascript” and “cookie” as tech-talk and ignore Internet security issues all together. Put more simply, the language used to describe security problems is far too technical and no good simple answers are available.

It would be interesting to see internet companies ranked against each other on these security issues. Google publicly acknowledges that it mines a lot of data by tracking links, parsing email, and using persistent cookies; whereas http://christonium.com lets you turn ads off, does not use persistent cookies and protects all of your content from caching. Anyone can put up just about anything on myspace; and whatever that is certainly doesn’t take user security or privacy into consideration.

I personally believe that the solution to these problems is for publishers to create web applications that are profitable or popular because they are useful, like linkedin, wikipedia, salesforce and chirstonium.com. What I see proliferating on the web are advertisers that are skillful at manipulating users to click on targeted advertisements. Google, myspace, facebook, youtube, yahoo, and the like don’t currently fit into that kind of business plan because they’re all dependent on maintaining high ad revenues and current business/marketing plans for survival.

Comment by James — June 1, 2007

If you are using Firefox, this extension seems to protect against this attack:

http://safehistory.com/

Comment by Wodow — June 1, 2007

Leave a comment

You must be logged in to post a comment.