Cross-site Scripting Prevention 27
An anonymous reader writes "Cross-site scripting (XSS) occurs when an attacker introduces malicious scripts to a dynamic form that allows the attacker to capture the private session information. This article casts light on the areas vulnerable to XSS exploitation, explains how the user can protect himself, and details what the webmaster can do to secure a site from this type of malicious intrusion."
hey! cool! (Score:2, Interesting)
http://www.securityfocus.com/archive/1/280218/200
(also provides a good example for people asking "what's an XSS?")
site redirects (Score:5, Interesting)
<meta HTTP-EQUIV="Refresh" CONTENT="0;URL=http://www.xml-dev.com">
in messages on the online forums. I know Hypernews was vulnerable to this attack.
Extremely common (Score:5, Insightful)
I'm what I consider a well-seasoned (and spicy!) web developer, and I've been bitten by this more than once in recent memory myself. It is hard to catch all possible avenues in which data you do not directly control might get interpolated into a web page you render. The latest bug I ran into was is displaying content from a security audit, when I did not realize the content included snippets of Javascript inside it... content that then became part of the page I rendered. Oops, that call to window.close() just got included into the text! It took quite a while to debug this one, because everytime someone went to the page in question, their browser just closed! I thought I had somehow segfaulted both Mozilla and IE until I was able to capture the page using Lynx and look at the content...
So... the name of the game is to audit,audit,audit. Always ask yourself "Do I know where this data came from? Could it contain markup or scripting? Have I escaped those characters so I know they cannot be interpreted as HTML?". Then I usually turn things over to a colleague and ask him to actively try to subvert the application... that usually catches a few "gotchas" I missed.
Some people advocate "sanitizing" all data before it is displayed. That is certainly possible, but can be a waste of cycles when it certainly is possible to rule out some data sources as being vulnerable. If I know I sanitize data going *into* my database, then I can probably trust data coming out... but even in that case, only if I know no other malevolent entity can attack that data (and we all know how often hacks occur from the inside...)
Re:Extremely common (Score:3, Informative)
From the article "...can occur when:
1. A Web server does not take adequate steps to ensure that the properly encoded pages are generated.
2. An input is not suitably validated."
So, validate/sanitize your inputs, and properly encode your outputs. Its not rocket science.
Re:Extremely common (Score:1, Insightful)
Some people advocate "sanitizing" all data before it is displayed. That is certainly possible, but can be a waste of cycles when it certainly is possible to rule out some data sources as being vulnerable.
So sanitize the untrusted data sources, and don't sanitise the ones you don't need to. The vast majority of web applications are simple enough for their developers to know straight away which ones are untrusted. Unfortunately, the vast majority of web applications are written by people who don't know
Re:Extremely common (Score:1)
Couldn't you just have looked in your web-browser's cache for the most recently modified files?
Re:Extremely common (Score:2)
for cryin out (Score:5, Funny)
Not everything needs a three-letter acronym, guys. Particularly when that acronym is not actually shorter than the thing it's short for. ("Cross-site scripting" and "XSS" have the same number of syllables. One of them carries meaning. The other doesn't.)
It reminds me of "www." Remember "www?" It's the only known acronym in the world to have more syllables than the phrase it's supposed to be short for. ("World wide web." Three syllables. "Doubleyou doubleyou doubleyou." Nine syllables. It's anti-compression.)
Re:for cryin out (Score:1)
ah, but thats why those in the know say it "w-w-w" (sort of a stuttered w).
Of course, most people look at me a bit strange for the second or two it takes them to comprehend. And then there are those that never get it.
</modrequest>
Re:for cryin out (Score:2)
I mean, are there any sites out there configured badly enough to required the www anymore?
Re:for cryin out (Score:2)
Re:for cryin out (Score:2)
It's shorter, doesn't make you sound retarded, and is geekish as hell
Isn't that what we all aspire for?
Re:for cryin out (Score:1)
I agree with your sentiment of www. It is becoming a fad in the media (at least where I live) to say "dub dub dub", which is strangely annoying.
Re:for cryin out (Score:2)
By the way, even when you actually pronounce it, XSS has three syllables, cross-site scripting has four.
It could be worse. (Score:3, Funny)
When the web was all new and shiny, even to us geeks, we would pronounce the leading part of the URL as "huh-tuppa-wuh-wuh", referring to "http://www."
Fantastic article (Score:3, Informative)
There is a problem in Listing 5, though. The article says the script is vulnerable because it blindly prints an input value back to the user; however, it only prints the word "parameter" back to the user and is thus not really vulnerable to anything. Looks like they left out a "$".
Re:Fantastic article (Score:2)
Well, don't just tease!
While we're making corrections, this bit of the article is incorrect as well, AFAICT:
One would expect to see the JavaScript alert message "Tes
I'm confused (Score:2)
Re:I'm confused (Score:3, Informative)
You can, but it's a hell of a lot easier to sneak tainted data into a form than it is to set up a man-in-the-middle attack. Further, XSS can guarantee you information on everyone who views the tainted page, while a MITM attack can't.
Another article (Score:3, Informative)
PHP (Score:4, Interesting)
If you simply pass all form text through these filters, wouldn't that totally get rid of XSS vulns?
Re:PHP (Score:1)
More audits of XSS (Score:3, Interesting)
Security is a parallel, interlocking issue if asking, "where does the data come from and where does the data go to?" (props to an old school EE guru and physicist for this saying) because you can have very secure client- and server-side apps but if the methodology of data retention is flawed you could have a password-less system and the privacy would still be just as bad.
I've always disliked heavy use of ECMAScript and cookies while debatable as to whether they're XSS or no they're easy to make as gateways to such things.