Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to prevent coldfusion sql-injection on order by clause

Since cfqueryparam doesn't work in an order by, would using xmlformat stop sql injections?

ORDER BY #xmlformat(myVariable)#

Thanks,

like image 843
Mike Henke Avatar asked Feb 24 '23 10:02

Mike Henke


1 Answers

http://www.petefreitag.com/item/677.cfm

A good way to get around this limitation is to use the ListFindNoCase function, to limit the sortable column names, for example:

<cfset sortable_column_list = "age,height,weight,first_name">
<cfquery ...>
  SELECT first_name, age, height, weight
  FROM people
  ORDER BY <cfif ListFindNoCase(sortable_column_list, url.sort_column)>#url.sort_column#<cfelse>first_name</cfif>
</cfquery>
like image 142
Mike Henke Avatar answered Mar 04 '23 05:03

Mike Henke