What Is An XSS Attack And What Can You Do About It?

The world is starting to wake up to something known as a cross-site scripting (XSS) vulnerability. While I believe it’s a good thing that the issue is being addressed in websites around the globe, I don’t think it’s very good for us to be ignorant of what it is. After all, most XSS attacks are preventable by the potential victim. In the internet, it is your responsibility to arm yourself against any threat lest you become a victim. To understand how you can protect yourself against XSS, you must first know what XSS is and how it can affect you, then how to prevent it.

What Is XSS?

The definition is in its name. An XSS attack is executed by modifying a URL in a way that can allow certain scripts to be injected into it. For example, you can make an entirely different website show up within a frame of the URL’s destination.

Look at an example of the modified URL:

xss-sample-url

See where the script was injected? In this example, it’s rather easy because it starts with “

How Does XSS Affect You?

XSS can be used in a variety of ways. Some may just post a link on Twitter containing the malicious URL. Twitter does half the work for them by covering up the URL partially. Contextual links within untrustworthy blogs and websites may contain URLs that are masked by the “anchor text” (which is another fancy way of describing text that’s underlined and blue).

When you click on the link, a number of things can happen. In a best-case scenario, you’ll just experience a “prank”, per se. In other words, you’ll be directed to a page with a bunch of fake content, perhaps showing credit to the group that performed the XSS attack. In a worst-case scenario, your browser will experience nightmarish symptoms. You may have your home page changed, and several different annoyances can occur on your computer as a result of executed malware.

XSS can also be used to trace you by installing cookies on your computer without your consent. Gathering this data could allow hackers to better understand a “digital demographic” of the people they are targeting for future malware infections. In such a case, you might not even notice anything going on in your computer or mobile device at all.

How Dangerous Is XSS?

xss-fakepage

All things considered, XSS isn’t usually very dangerous. It may be annoying, but it won’t present any long term consequences, at least not in the short term. However, beware of combinations between XSS attacks and other sorts of malicious behavior!

For example, let’s say that Facebook is vulnerable to XSS. A hacker can easily inject a fake log-in page to Facebook’s URL. You’d log in successfully (since the fake page can send your credentials to both Facebook and its own database), but the hacker will now have your username and password. This is where the true danger of XSS presents itself.

How To Protect Yourself Against XSS

One of these days, XSS will just be a thing of the past. But until then, you have to learn to prevent yourself from falling into the XSS trap. Every time you enter a page, have a look at the URL. If there’s anything indicating there’s a script in there (such as the “” characters surrounding a word), then it’s wise to use your discretion and perhaps leave. Also, watch the URLs to links. Right-click every link and copy it to your clipboard. Paste the URL into your notepad application and check it out before you even go in.

If you have a website you’re developing yourself, read this cheat sheet. This will protect you and your visitors from XSS. Be sure to mail the cheat sheet to any web developers you know. They’d appreciate it.

If you have any more questions about XSS, be sure to leave it in a comment below!

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Miguel Leiva-Gomez Avatar

Read next

The original iPhone Steve Jobs unveiled in January 2007 could not record video, could not copy and paste text, could not run a single third-party app, and could only reach the internet over 2G — and Jobs spent ninety minutes on stage at Macworld arguing, one missing feature at a time, that every absence was actually a design decision.
In 1965, Joe Sutter’s Boeing team began shaping the 747 around a future they thought would belong to supersonic jets, lifting the cockpit onto a hump so the nose could open for cargo once the giant subsonic passenger plane had outlived its brief moment
Apple’s original 1984 Macintosh keyboard had no arrow keys, no function keys, and no numeric pad because Steve Jobs wanted users to reach for the mouse first. Then Apple quietly sold the missing keys as an accessory.
When the SS Great Eastern laid the first working transatlantic telegraph cable in 1866, a message that had taken ten days by steamship suddenly crossed the ocean in minutes, and the financial markets of London and New York were forced, within a single trading week, to invent the modern concept of synchronised global price.
Masahiro Hara and Denso engineers built the QR code in 1994 to help Toyota suppliers scan car parts from any angle, then kept the patent open until phone cameras and a 2020 pandemic turned the factory square into a daily ritual on restaurant tables
In 1965, Mary Allen Wilkes wrote LAP6 for the LINC computer from her parents’ Baltimore home, testing an interactive operating system on a 250-pound machine in the living room and becoming the first known person to use a personal computer at home, twelve years before the Apple II reached buyers
When Grace Hopper wanted to explain a nanosecond to admirals who kept asking why satellites were slow, she handed each of them a piece of wire 11.8 inches long, the exact distance light travels in a billionth of a second, and told them to keep it in their pocket as a reminder that physics, not laziness, sets the limit.
The Big Ear telescope was scanning at 1420.4056 megahertz on the night of 15 August 1977, the exact frequency at which hydrogen atoms vibrate across the universe, because Giuseppe Cocconi and Philip Morrison had argued years earlier that any species trying to be found would broadcast on that channel — and then, for 72 seconds, something did.