<?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>Grapii &#187; Forms</title>
	<atom:link href="http://www.grapii.com/tag/forms/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.grapii.com</link>
	<description>Personal Site of Raj Patel</description>
	<lastBuildDate>Mon, 06 Sep 2010 13:45:46 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Form security using SESSION.SESSIONID</title>
		<link>http://www.grapii.com/2008/01/form-security-using-sessionsessionid/</link>
		<comments>http://www.grapii.com/2008/01/form-security-using-sessionsessionid/#comments</comments>
		<pubDate>Fri, 18 Jan 2008 10:03:47 +0000</pubDate>
		<dc:creator>grapii</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Forms]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Web Apps]]></category>

		<guid isPermaLink="false">http://www.grapii.com/?p=17</guid>
		<description><![CDATA[I&#8217;ve been having problems recently with attempted spamming exploits on my form to email scripts (i.e. users downloading forms, messing with them and then submitting them remotely to my form handling scripts) and thought I&#8217;d see if comparing the sessionID of the sending pages and form handling pages could help to weed out these fake [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been having problems recently with attempted spamming exploits on my form to email scripts (i.e. users downloading forms, messing with them and then submitting them remotely to my form handling scripts) and thought I&#8217;d see if comparing the sessionID of the sending pages and form handling pages could help to weed out these fake submissions.<br />
<span id="more-17"></span><br />
I also thought it would be even more secure if the I used a hashed version of the SessionID.</p>
<p>First I included the <a href="http://www.grapii.com/?p=12" title="Display Encrypting Usernames &amp; Passwords">MD5 function</a> in both the sending and form handling pages as it isn&#8217;t included with ASP</p>
<pre>&lt;!--#include file="md5.asp"--&gt;</pre>
<p>Then I defined a variable for the hashed SessionID</p>
<pre>Dim strHashedSessionID
strHashedSessionID = MD5(Session.SessionID)</pre>
<p>Next I added the hashed SessionID to the querystring of the form handling page</p>
<pre>&lt;form method="post" action="formhandler.asp?sender="&gt;</pre>
<p>On the form handling page, I added a server-side error message, generated only if the two values don&#8217;t match</p>
<pre>&lt;%
If Not Request.QueryString("sender") = strHashedSessionID Then
 Response.Write "Authentication error: Please re-sumbit the form"
End If
%&gt;</pre>
<p>Finally, if the two values do match, the email is sent</p>
<pre>&lt;%
If Request.QueryString("sender") = strHashedSessionID Then
 'send the email using CDOSYS
End If
%&gt;</pre>
<p>After adding some additional server-side form validation, I added the additional security scripting to my <del><a href="http://www.grapii.com/contact.asp" title="Grapii Contact Form">contact form</a></del>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.grapii.com/2008/01/form-security-using-sessionsessionid/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reducing the Risk of SQL Injection Attack</title>
		<link>http://www.grapii.com/2008/01/reducing-the-risk-of-sql-injection-attack/</link>
		<comments>http://www.grapii.com/2008/01/reducing-the-risk-of-sql-injection-attack/#comments</comments>
		<pubDate>Fri, 11 Jan 2008 13:18:47 +0000</pubDate>
		<dc:creator>grapii</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Forms]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Web Apps]]></category>

		<guid isPermaLink="false">http://www.grapii.com/?p=7</guid>
		<description><![CDATA[Databases can be compromised if they are open to SQL Injection Attack. Stripping invalid characters from form inputs will reduce this risk.
If you have a form on your site that interacts with a database (e.g. a username/password login form), you should secure the form by adding an additional stage between submission and the database look-up. [...]]]></description>
			<content:encoded><![CDATA[<p class="note">Databases can be compromised if they are open to SQL Injection Attack. Stripping invalid characters from form inputs will reduce this risk.</p>
<p>If you have a form on your site that interacts with a database (e.g. a username/password login form), you should secure the form by adding an additional stage between submission and the database look-up. One way to do this is to check for valid content.<span id="more-7"></span></p>
<p>As usenames and passwords are usually strings of alphanumeric characters, you can strip out &#8216;bad&#8217; characters from the input string.<br />
The easiest way to do this is to collect the form&#8217;s input and check each character against a regular expression, removing any that are invalid.</p>
<p>The code below removes all non-alphanumeric characters from the input string:</p>
<pre>&lt;%
'gets the text submitted via a form
Dim strUsername, strPassword
strUsername = Request.Form("username")
strPassword = Request.Form("password")

'call the function to use
strUsername = stripString(strUsername)
strPassword = stripString(strPassword)

'function to strip all non-alphnumric characters
function stripString(strInput)
 Dim objRE
 Set objRE = New RegExp
 With objRE
  .Pattern = "[^A-Za-z0-9]"
  .Global = True
 End With
 stripChars = objRE.Replace(strInput, "")
 Set objRE = nothing
End Function
%&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.grapii.com/2008/01/reducing-the-risk-of-sql-injection-attack/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
