ColdFusion SQL Injection Troubles

29 Aug, 2008  |  Written by  |  under ColdFusion

This has been an issue for a long time, but the past few weeks, we’ve started to see some automated attacks against ColdFusion sites trying to inject rogue SQL via forms and other parameters.  Ugh.  I’ve been working with a great piece of code called Portcullis, but it has a few rough edges that make it hard to deploy.  Here’s my application.cfm, in case it’s useful for anybody else fighting this:

	<cfif isdefined("application.Portcullis") eq false or isdefined("url.reset")>
	<cfset application.Portcullis = createObject("component","com.fusionlink.Portcullis").init()/>

	<cfset application.Portcullis.scan(url,"url",cgi.remote_addr)>
	<cfset application.Portcullis.scan(form,"form",cgi.remote_addr)>
	<cfset application.Portcullis.scan(cookie,"cookie",cgi.remote_addr)>

	<cfif application.Portcullis.isBlocked(cgi.remote_addr) eq true>
	 Sorry, there was an error detected.
	 <cfmail from=""
	  subject="SEI Portcullis: User Blocked" type="html">
	  <cfdump var="#cgi#"/>

	<cfcatch type="any">
	 <cfmail from=""
	  subject="SEI Portcullis Threw Exception" type="html">
	detail: #cfcatch.Detail# <br />
	<cfif IsDefined("cfcatch.SQLState")>
	sqlstate: #cfcatch.SQLState# <br />
	type: #cfcatch.type# <br />
	  <cfdump var="#cgi#"/>

One Response so far | Have Your Say!

  1. His_wife34  |  October 23rd, 2009 at 7:33 am #

    Thanks for a remarkably informative post. ,

    His_wife34 - Gravatar

Leave a Reply