Cross-site scripting: An old problem returns

When two Websites work together, it can cause security issues for you. Find out how to guard against this persistent threat.

In May, Web security consultant George Deglin discovered a cross-site scripting (XSS) exploit that involved Facebook's controversial Instant Personalization feature. The exploit ran on Yelp, one of the three sites that Facebook had selected to test Instant Personalization. Deglin was able to obtain not only Facebook profile information shared with Yelp but also the e-mail addresses for that profile's Facebook friends--a potential gold mine for marketers and spammers alike.

Shortly after Deglin's XSS flaw was fixed, another one surfaced on Yelp, and Facebook temporarily suspended the Instant Personalization program on that site.

XSS-based attacks are not new, but the rise of social media adds a new wrinkle to these sorts of vulnerabilities.

An XSS Primer

The most common XSS attack method uses e-mail: A criminal appends special characters, such as those of a foreign language, to an ordinary URL. These characters might tell a Web server to run a script that the crook has crafted. For example, say an attacker appends such a script to your bank's URL and e-mails it to you. If you click the link, believing that it's legitimate e-mail from your bank, your browser sends the script to the Web server, which runs the malicious code and passes a browser cookie with your bank login details to the attacker, who can then log in to your online banking account.

Another type of XSS attack stores the malicious code on a Web server. The attacker logs in to an e-commerce site, for instance, and posts a message containing a script. Some days later, you log in to the site and read the tainted post. As before, the script steals the cookie with your login information and passes it to the bad guy, who can then impersonate you.

A third type of XSS attack hits the Web browser itself. In this scenario, the attacker places a poisoned Flash file on a site that you visit. When your browser downloads the video, the file triggers a script in the browser, and the attacker can then control elements of the page inside your browser.

Web 2.0 and XSS

Today's Websites do a much better job of filtering out common XSS attacks than sites did in the past, but what happens when two sites with very different content-filtering needs decide to partner?

Say you click an ad on site A. Unbeknownst to you, that ad contains an XSS attack that silently directs your browser to site B, a travel site that has full access to your social networking profile. With an XSS attack, to become a victim you wouldn't have to visit site B, log in to it, click anything there, or even know that it exists. Because site B already has access to your social networking profile (and perhaps information on your friends), the criminals behind the ad on site A now have access to that information as well. That's what is starting to happen with Web 2.0 mashups similar to the Facebook-Yelp collaboration.

Protect Yourself

Unfortunately, sites can't prevent XSS attacks simply by encrypting connections. SSL (Secure Sockets Layer), indicated by the little padlock that appears in the toolbar when you browse to an encrypted site, merely encrypts the attack. Generally, site designers have to lock down their sites to prevent XSS exploits.

Users have two ways to avoid XSS attacks, however. One is to ignore links from one site to another: If site A links to, say,, instead of clicking that link you would go directly to in another tab and find the page using the site's search feature. This technique is effective against XSS attacks embedded in the linked URL, but it's inconvenient--and it doesn't help when two sites share content. The other method is to disable scripting languages such as JavaScript within your browser. Even though this can disable desirable features on some sites, you may find it tolerable.

Blocking Dangerous Scripts

Internet Explorer 8 was the first browser to have script-blocking XSS protection built in; Google Chrome soon followed. Both check to see if a script from a Web server is malicious--if it is, they block it. In April, at Black Hat Europe 2010, researchers David Lindsay and Eduardo Vela Nava demonstrated ways to neutralize this approach, but by that time Google had already fixed the problem in Chrome. Microsoft had corrected most of the issues in January (with patch MS10-002) and March (MS10-018), and planned to fix a third flaw in June, so the issue may be fully resolved by the time you read this.

Firefox users can employ the free NoScript add-on to selectively block scripts. For instance, you can unblock a Flash video while blocking other script components on the site. IE and Chrome aren't nearly as granular in blocking suspect scripts--it's all or nothing with them.

One problem with NoScript is that most users don't like the inconvenience of individually unblocking scripts. But blocking and unblocking typically become second nature. You can also authorize all scripts on a given site for a single visit or all future visits, something you can do in IE 8 and Chrome, too.

Join the newsletter!


Sign up to gain exclusive access to email subscriptions, event invitations, competitions, giveaways, and much more.

Membership is free, and your security and privacy remain protected. View our privacy policy before signing up.

Error: Please check your email address.

Tags cross-site scripting

Keep up with the latest tech news, reviews and previews by subscribing to the Good Gear Guide newsletter.

Robert Vamosi

PC World (US online)
Show Comments


Brother MFC-L3745CDW Colour Laser Multifunction

Learn more >



Sony WH-1000XM4 Wireless Noise Cancelling Headphones

Learn more >


Back To Business Guide

Click for more ›

Brand Post

Most Popular Reviews

Latest Articles


PCW Evaluation Team

Tom Pope

Dynabook Portégé X30L-G

Ultimately this laptop has achieved everything I would hope for in a laptop for work, while fitting that into a form factor and weight that is remarkable.

Tom Sellers


This smart laptop was enjoyable to use and great to work on – creating content was super simple.

Lolita Wang


It really doesn’t get more “gaming laptop” than this.

Jack Jeffries


As the Maserati or BMW of laptops, it would fit perfectly in the hands of a professional needing firepower under the hood, sophistication and class on the surface, and gaming prowess (sports mode if you will) in between.

Taylor Carr


The MSI PS63 is an amazing laptop and I would definitely consider buying one in the future.

Christopher Low

Brother RJ-4230B

This small mobile printer is exactly what I need for invoicing and other jobs such as sending fellow tradesman details or step-by-step instructions that I can easily print off from my phone or the Web.

Featured Content

Product Launch Showcase

Don’t have an account? Sign up here

Don't have an account? Sign up now

Forgot password?