House of Fusion
Home of the ColdFusion Community

Search cf-talk

October 07, 2008

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
       1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31   

Subscribe Now
Fusion Authority Quarterly Update - ColdFusion 8 Special Edition
Search over 2,500 ColdFusion resources here  >>>      
Home /  Groups /  ColdFusion Talk (CF-Talk)

avoiding direct SQL command injection

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Hi,
Sebastian Mork
01/26/06 09:30 P
Nice. thank you all..
Sebastian Mork
01/28/06 01:23 P
Hi Les,
David McCan
01/29/06 01:09 P

01/26/2006 09:30 PM
Author:
Sebastian Mork

Hi, In my apps I use nearly everytime selecting data from a database the cfqueryparam tag.. Now I tried (using mysql-db) to execute some sql-commands via url-param.. The case is I wanna avoid direct sql injections. Therefore I made some tests to see how manipulation works and how to avoid it. An example, I've a query like this: select tbl_users.* from tbl_users where fld_username='#url.test#' All test, e.g. trying so call file.cfm?test=anything';update tbl_users set fld_password='abc' failed. Anyway, I don't wanna get this working, I wanted to see if e.g. a cfqueryparam with type=cf_sql_ varchar avoids this from execution or not. When using numeric values as queryparams an error is thrown, (eg where fld_id=<cfqueryparam cfsqltype="cf_sql_bigint" value="#url.v#"> when v=abc) but what about other types like text,varchar..? A way to avoid could be replacing the ; from e.g. search-strings when searching for anything in db. But what if a semikolon is needed to search for eg in a product teaser or something like that.. Any tips about that would be great, thx -- Sebastian Mork <federente@gmx.de>

01/26/2006 09:45 PM
Author:
James Holmes

CFQUERYPARAM avoids SQL injection by binding the parameter into the statement, not just by checking types. It is impossible to have a bound parameter executed as literal SQL (if the DB actually supports binding). On 1/27/06, Sebastian Mork <federente@gmx.de> wrote: -- CFAJAX docs and other useful articles: http://jr-holmes.coldfusionjournal.com/

01/26/2006 11:07 PM
Author:
Justin D. Scott

> When using numeric values as queryparams an error is thrown, > (eg where fld_id=<cfqueryparam cfsqltype="cf_sql_bigint" > value="#url.v#"> > when v=abc) This is easy to get around by wrapping the url variable in a val() function. That will guarantee that whole number will be passed in. -Justin

01/27/2006 11:33 AM
Author:
Dave Watts

> Anyway, I don't wanna get this working, I wanted to see if > e.g. a cfqueryparam with type=cf_sql_varchar avoids this from > execution or not. As Mr. Holmes pointed out, CFQUERYPARAM creates a prepared statement containing bound parameters. This means that pieces of data are explicitly identified as being data, instead of SQL commands. So, it doesn't matter what's in the data; the database will know it's not executable code. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ Fig Leaf Software provides the highest caliber vendor-authorized instruction at our training centers in Washington DC, Atlanta, Chicago, Baltimore, Northern Virginia, or on-site at your location. Visit http://training.figleaf.com/ for more information!

01/28/2006 01:23 PM
Author:
Sebastian Mork

Nice. thank you all.. -- Sebastian Mork federente@gmx.de -- On Fri, 27 Jan 2006 11:32:17 -0500 Dave Watts <dwatts@figleaf.com> wrote:

01/28/2006 11:44 PM
Author:
Les Mizzell

>> CFQUERYPARAM creates a prepared statement >> containing bound parameters. Just because some of you might find this fun and slightly related to the above... I'm working on a Congressional site at the moment, and Coldfusion is *very* poorly supported to start with. The "official house supported" version is CF5, so I'm having to rewrite most of my carefully crafted snippets and reusable code chunks. Anyway, once you're logged onto the house network and posted your files, they have to go through a "security scan" before they can go live. The scan doesn't take cfqueryparam into consideration at all, so my first scan of a dynamic page generated about 5 pages worth of "failed" reports that looked like: ScanDo included the ' (apostrophe) character in the parameter value. The server's reply indicates that the parameter is vulnerable to manipulation using SQL symbols. 1)High Severity URL: mypage-detail.cfm?id=97' Solution: Make sure parameter values sent by remote users do not include SQL commands or symbols. Validate and sanitize every user variable passed to the database. Check that the input has the expected data type. Never pass unchecked user-input to database-queries. Basically, the scan program tries about every SQL Injection trick known to man, and if you fail one of them, you don't go live. All my carefully written queries using cfqueryparam meant nothing. Pfffftttt! So, for every single variable passed to a query, about the only way to pass the security scan was to do this: <cfif IsDefined("fname") and (findoneof("!<[^>]+%>!=",fname,1) NEQ 0)> <cfabort> Sheesh..... But, this presents a HUGE problem. The client has requested an admin section to update content on certain pages. So, a simple <p> tag which needs to get passed will trigger the cfabort above. ACK! I'm glad I'm getting paid well for this.... More later once I've got it all figured out on how to give the client what they want but pass all the required BS needed to get stuff approved, including the "Secret Squirrel Security Code Generator" that we've now got that display a security code to login into the house private network that changes every 60 seconds. This is fun stuff...

01/29/2006 01:09 PM
Author:
David McCan

Hi Les, How about removing single quotes in application.cfm for the short term and submitting information from Adobe on the value of cfqueryparam for preventing sql injection in the hopes that helps for the future? David


<< Previous Thread Today's Threads Next Thread >>

Mailing Lists