Cross Site Scripting (XSS) in ColdFusion

Firstly let me say that this is not definitive, this will not ensure that your site is safe. There may be more that you need to do. We were in need of a simple way to make sure that users were not using our "email a friend" forms to send nasty stuff around... So, using the stripHTML() udf from cflib we managed to get rid of all of the nasties from form fields as they hit the site just by looping over the form scope

<cfscript>
// clean up all the form fields for cross site scripting for(key in form)
{
form[key] = stripHTML(form[key]);   
}
</cfscript>
if you wanted to be a little nicer and allow users to have HTML formating tags (like bold) in their forms, then you can use safeText() in a similar manner to get rid of nasty tags. This is a little slower to run however due to all the looping and stuff.

Of course, you really should do this for the URL scope and perhaps even the cookie scope.

Comments
Tony Petruzzi's Gravatar Lack of common sense does not an XSS make.

How many times has everyone said to validate user input?
# Posted By Tony Petruzzi | 11/5/06 10:01 AM
Lucas Sherwood's Gravatar yep, that is about it - we all know that we should do it, it is just that we often forget :)
# Posted By Lucas Sherwood | 11/5/06 10:03 AM
warhammer gold's Gravatar Cross Site Scripting (XSS) in ColdFusion
# Posted By warhammer gold | 10/9/08 7:12 PM
yfi's Gravatar Horde Leveling Guide
This <a href="http://www.coolingame.com/wow-power-leveling.php" target="_blank">http://www.coolingame.com/wow-power-leveling.php">wow power leveling</a> guide starts at level 21, if you need <a href="http://www.coolingame.com/wow-power-leveling.php" target="_blank">http://www.coolingame.com/wow-power-leveling.php">wow powerleveling</a> guides for any other <a href="http://www.coolingame.com">powerleveling</a> level range (from 1-21 for example) please take a look at this <a href="http://www.coolingame.com">power leveling</a> page.
This <a href="http://www.coolingame.com">wow power level</a> guide is optimized for FAST leveling with a minimum of grinding sessions. <a href="http://www.coolingame.com">wow powerlevel</a> Quests are important, they give rewards and faction and are less boring than pure <a href="http://www.leveln.de">wow powerleveling</a> grinding, BUT sometimes some quests are really a time waste and we will skip those and replace them by good <a href="http://www.leveln.de">wow power leveling</a> grinding session when it is necessary.
Some people say that <a href="http://www.leveln.de">wow power leveln</a> grinding is always faster than questing, this is true in theory when you don't know which <a href="http://www.leveln.de">wow powerleveln</a> quests to take and which to avoid, and what is the best order to do them. With this <a href="http://www.game-market.de/Fiesta-Online-Gold.php">fiesta online</a> guide, questing will be very efficient and much better than pure grinding. Follow each <a href="http://www.leveln.de/fiesta-online-Gold.php" target="_blank">http://www.leveln.de/fiesta-online-Gold.php">fiesta online</a> instruction carefully and you will see for yourself.
The <a href="http://www.leveln.de/Last-Chaos.php" target="_blank">http://www.leveln.de/Last-Chaos.php">last chaos</a> quest choices and order to do them are optimal so that you run as few as possible while doing the most possible and then turning several <a href="http://www.leveln.de/Last-Chaos-Gold.php">last chaos gold</a> quests in at the same time. This <a href="http://www.leveln.de/Last-Chaos-Gold.php">lastchaos gold</a> guide will be very useful for both veteran and novice players. I try to keep the amount of <a href="http://www.game-market.de/Last-Chaos-Gold.php">last chaos gold</a> information as short as possible. So even the guide itself is optimized for the minimum reading possible, to save time! Let's get started immediately then! Everything described in this <a href="http://www.game-market.de/Last-Chaos-Gold.php">lastchaos gold</a> guide can be done solo (besides when I say otherwise). However you can follow this guide while duoing, grouping, it's not a problem, it works too.
# Posted By yfi | 10/31/08 4:05 PM
warhammer gold's Gravatar <A href="http://www.vipwarhammergold.com/" target=_blank><FONT =4><B>warhammer gold</B></FONT></A> <FONT =4></FONT><A href="http://www.vipwarhammergold.com/news/news.html" target=_blank><FONT size=4><B>buy warhammer gold</B></FONT></A><BR><A href="http://www.bestwarhammer.com/" target=_blank><FONT size=4><B>warhammer gold</B></FONT></A><FONT size=4></FONT> <A href="http://www.bestwarhammer.com/news/news.html" target=_blank><FONT size=4><B>buy warhammer gold</B></FONT></A><BR><A href="http://www.aocsale.com/" target=_blank><FONT size=4><B>aoc gold</B></FONT></A> <FONT size=4></FONT><A href="http://www.aocsale.com/aoc-news/" target="_blank">http://www.aocsale.com/aoc-news/" target=_blank><FONT size=4><B>age of conan gold</B></FONT></A><BR><A href="http://www.game4power.com/" target=_blank><FONT size=4><B>wow gold</B></FONT></A> <FONT size=4></FONT><A href="http://www.game4power.com/news/" target="_blank">http://www.game4power.com/news/" target=_blank><FONT size=4><B>buy wow gold</B></FONT></A><BR><A href="http://www.wowgoldone.com/" target=_blank><FONT size=4><B>wow gold</B></FONT></A> <FONT size=4></FONT><A href="http://www.wowgoldone.com/" target=_blank><FONT size=4><B>buy wow gold</B></FONT></A><BR><A href="http://www.game4power.com/" target=_blank><FONT size=4><B>world of warcraft gold</B></FONT></A> <FONT size=4></FONT><A href="http://www.wowgoldone.com/" target=_blank><FONT size=4><B>world of warcraft gold</B></FONT></A><BR><A href="http://www.gamelevelup.com/" target=_blank><FONT size=4><B>wow power leveling</B></FONT></A><BR><A href="http://itemstores.com/" target=_blank><FONT size=4><B>wow item</B></FONT></A>
# Posted By warhammer gold | 11/19/08 6:07 PM