Skip to main content
Inspiring
August 12, 2008
Question

cfqueryparam question

  • August 12, 2008
  • 1 reply
  • 282 views
Hello,

We recently found ourselves dealing with a nasty SQL code injection issue. I have implemented a few stop-gaps while I do something I should have been doing - Adding <cfqueryparam> to all my dynamic queries.

My affected database has about 20 tables for each of about 20 areas, so there's an Adata, Bdata, Cdata, etc. In my dynamic queries A,B, or C is a variable defined in a SESSION when the user logs in. So if I'm the guy from "A" all my tablenames in queries will be prepended with "A" via a session var.

My question is this;
In this query
SELECT ID
FROM #SESSION.ID.area#members
WHERE ID = #form.newID#

I am going to update the #form.newID# with CFQUERYPARAM, is there any threat with the SESSION variable, and if so how would I protect it and retain my dynamic abilities?

Also, 95% of my columns are nvarchar(255) due to the actual necessity of storing a lot of data. I know using cfqueryparam even with (whichever type matches) this type declaration will prevent code executing on the server, but doesn't it still allow it to be written, due to it still being text? And won't it still execute if called to a browser?
This topic has been closed for replies.

1 reply

Inspiring
August 12, 2008
If someone submits sql to a text datatype, you will store what you get and if you display it in a browser, it will not execute.

With javascript, it will execute when you display it in a browser, cfqueryparam or not. At least it did when I tried it.