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

In 2026, scientists assembled the Greenland shark’s 5.9-billion-letter genome and examined retinas from animals more than a century old, finding intact vision, expanded DNA-repair pathways and unusual chromatin machinery inside a vertebrate believed capable of surviving for nearly four centuries
At 3 gigahertz, a processor has only a third of a nanosecond between clock ticks, enough time for light to travel about 10 centimetres in vacuum before real interconnects, logic gates and capacitance shrink the distance a signal can cross on the chip
When Adobe announced Flash’s end-of-life in July 2017, it closed a technology that had once run on 99 per cent of desktops — and took with it an estimated four million animations, games and interactive works now preserved only by an amateur archive called Flashpoint
When Japan’s trade ministry put the PlayStation 2 under export control in April 2000, its 6.2-gigaflop hardware was considered adaptable for missile guidance, briefly forcing anyone exporting more than one console to seek government approval
Standard QR codes hide three larger squares in their corners so scanners can orient them from any angle, while their strongest Reed-Solomon setting can restore roughly 30 per cent of damaged codewords, though not necessarily 30 per cent of the visible square
In 1911, the Dutch physicist Heike Kamerlingh Onnes cooled a thread of mercury to 4.2 kelvin in a bath of liquid helium and its electrical resistance vanished completely, and a current set circulating in a superconducting loop like that will still be flowing years later, indistinguishable from the day it began
Red, green and blue became the primary colours on every screen because the human retina carries just three types of cone cells — the pixels aren’t matching the light, they’re matching your eyes
Inside a modern processor, transistors switch on and off billions of times a second — and they’ve shrunk to about 3 nanometres wide, roughly 15 silicon atoms across, close to the physical limit of how small a switch can be