You will use cfqueryparam... or else!
A friend, who prefers to remain anonymous, pinged me today to ask what my favorite cfqueryparam scanner was. I don't actually use one, but when I asked him why he wanted one, I was a bit surprised by his answer.
My friend does hosting, but it's not his primary business. He has decided that he is going to begin a policy of scanning all the files on his system for ColdFusion queries w/o cfqueryparam. He will then send emails out to all developers who have failed to properly use cfqueryparam. If the code isn't updated in two weeks, the server will be disconnected.
What do people think about this? Too draconian? Should a host be scanning for 'trouble' code at all?
Comments
He has to protect his business. And there is nothing like a little SQL injection to kill your server.
As long has he is "gentle" in his explanation he will be ok. Those that aren't using queryparam probably don't know it exists and will appreciate the education. He just needs to be prepared that he will have to work with some of his customers.
He should probably have an updated TOS to also CYA... :-) (You can tell I'm paranoid)
If someone has an issue with it, they can go elsewhere.
I actually don't think this sort of move is too extreme. And we should not forget that using CFQUERYPARAM also delivers performance benefits.
Or, draconian would be saying that queries without cfqueryparam will be manditorily debugged and vetted by hosting staff at a rate of $150/hr.
This? This is just good business.
(And using someone else's code isn't an excuse. If it's on your site, you are responsible for it.)
What about
cfcompile -deploy <webroot directory> <directory to compile> <output directory> or cfencode??
Will this magic scanning tool catch everything?
Hi Rick!
In fact, I would never use a host I had a suspicion of looking at my code in the first place. The code is my property, they are only giving me a place to execute it.
Again, I would argue that the host has no business looking at the code of a client in any circumstance except when the client has asked the host to do so and given them explicit permission. (I know there are some hosts out there that will do consultant work or help out with a site, I'm not talking about that sort of situation).
My host is not signing a non-compete, NDA or waiver to get me as a client. How do I know they aren't copying and using my code, selling my code, taking my ideas, etc?
Just my 2 cents.
http://www.coldfusionmuse.com/index.cfm/2008/11/18...
Basic summary, use cfqueryparam, but take care in how it's used to avoid potential performance issues
CFQP may be a best-practice (and I use them extensively and see the huge value in them), don't freaking tell me how to code! I'll write my own applications as I want! Whether it's spaghetti code or a perfectly built OO application, or anything in between, it's my code (as Ryan G mentions).
You don't see companies like hostmysite.com telling their customs to do this.
Time to find a new host.
We are a boutique host that specializes in application monitoring, support and certification compliance. We monitor errors in real time and provide code correction when warranted.
9 out of 10 times, we are responsible for cleaning up the mess that someones code has caused. Chances are, the developer is no where to be found at 4am.
In simpler terms...
If you clean houses for a living, you don't want the customer who's dog craps all over the carpet and leaves you to clean it up.
While most of your complaints are valid to some degree I'll address a few directly.
Everyone - We are well aware this is no protection from everything. We just believe that enforcing best practices is in the best interests of all of our clients.
Rick - We'd be happy to secure your application at a cost.
Ryan - If you are hosting with us, your code is accessible by us. That's why your with us in the first place.
Josh - We do offer Web Application Firewalls. If you can afford it, were happy to give it to you.
Tony - Actually... no. We don't have to take the good with the bad.
Point blank. Its our environment and your choice.
If I had a site hosted by you (who knows, maybe I do since this is anonymous!) and you threatened me, I'd pull my business and site. Not so much because I disagreed with you, but because then I'd be thinking... what next? Are you putting my site through every possible security scan (cross scripting, etc.)?
As for your comment about "if you are hosting with us your code is accessible by us"... would you read your customers' emails, too...? After all, they are on your servers as well. Do you state in your contract that you are going to do this with/to your customers? If not, you might want to rethink your approach.
I think you skipped over the entire part where I mention that that's what we are payed for.
The entire reason you would host with us is because we will maintain your code for the health of your application.
No need to rethink our approach.
But if the environment is self contained where you're responsible for your own stuff... then do whatever you want.
When I had my sites on a hosted service, the sites would go down frequently. After many calls (from many people) the hosting provider discovered that teh issue came from one site that would hoard all the resources on a regular basis. If I was still in that environment, having my code scanned so that other's bad code can be found would make me feel all warm and fuzzy inside.
Then within each file (cffile action="read") FindNoCase'ing instances of cfquery's
Within each cfquery, Find() any instance of '=' and 'like', then advance to the first non-space character, and if it's not a '<' then a cfqueryparam is not being used.
Whenever there's a hit, dump that to a log of path/file + line #.
cfqueryparam is not the only way to protect against sql injection attacks, and there are valid reasons to not use cfqueryparam (or other flavors of prepared statements).
In a cfc I might scrub my data to a greater degree than cfqueryparam would do ( eg: escaping html,escaping punctuation ).
I would be very concerned that another "Best Practice" directive would be instituted. Best practices tend to evolve over time.
Ultimately, if forcing the use of cfqueryparam is more important than potentially losing customers go for it. If your current customers are ok with this, go for it. If you are willing to lose potential new customers, go for it.
I doubt a large hosting company would ever do this.
yes, if you must use <cfexecute> in your application, you won't host your app with that provider. same here: you do not want to use <cfqueryparam> - find a different host, sure.
i am all for officially equating not using cfqp when it is a must to having malicious code hosted on your site!
however, of course, any case of not using cfqp must be carefully examined for actual need of using one. one can't just blindly require it be used in each and every query.
my 0.02$
Because encrypting my files would probably be my first reaction if I heard my hosting company was going to examine all my code for defects.
What I would rather see, though is something from Adobe that would make it take extra effort to bypass the parameterization process instead of the other way around.
I noticed the part about you being paid. So it comes down to one simple question: are your customers paying you to shut them down if they don't do what you tell to in terms of cfqueryparam?
What I'm simply suggesting is that its a questionable business move. I understand about resources being hogged because of bad SQL injections killing or screwing with the db. There may well be a better way of achieving your goal is all.
If this policy was coming from a general web hosting company (like HostMySite, for example), then yes I would say it's a bit draconian. But with this particular company, this policy actually seems very consistent with their business model (i.e. protecting their customers from their own code)
@The people saying you would lose money from driving people away. I think this impact is less than the people you would lose from their db connection/cf connection constantly being down, hung, or messed up. I've left many hosts where CF constantly hung like a dozen times a day because of other people's bad code on the machine.
In one case the host had fusion reactor and had spotted the problem. They said they were in communication with the customer to get it fixed, but had no recourse to disable it temporarily themselves. I took this as not being proactive enough and dropped my account there after a week of it not being resolved. It's all trickle-down. The people I had put something up for would then be mad with all the downtime etc etc down the line.
If a vulnerablility is found, you can let the customer know, and provide a solution for them. If not, there is no need to force the use of cfqueryparam against their wishes.
While it is unlikely submitted work will cause physical damage to the presses or bindery equipment, jobs can hurt the company and its brand. There are limits of what we'll run that are probably incredibly fuzzy and gray, but they still exist.
Every company that provides infrastructure support to another organization's message has to decide what the limits are. That Ray's friends has decided that his group doesn't want to host a group of victims-in-waiting is an interesting business value proposition that is sure to be received in mixed fashion, like it already has been here.
However, whether you host with this company or another, it is incredibly naive to believe the information hosted on another system is not subject to review by 3rd parties. Not least of which, almost all hosting firms have an acceptable use policy concerning the content being hosted and it can only be enforced if the service has the ability to inspect said content.
I agree with some earlier comments concerning CYA and updating TOS/AUP as, in general, I think transparency is the only sane way to deal with customers.
For some reason it strikes me kinda the way smoking bans do. I am completely against the idea of legislated smoking bans (if every host was forced to do this), however I fully support a restaurant owner deciding whether or not the business allows smoking (where this host does not). The people then can use the policy of the restaurant to contribute to them making there dining choice (do I want to host there or not).
Personally, I think they should *kinda* implement it, Ie. leave some flexibility for code that might fail an automated check, but pass a "this logically doesn't need it or can't use it" check.
searching for absence of cfqueryparam will reveal queries that are not using it but doesn't really mean the code is bad.
cfqueryparam was created and designed to define a parameterized query and execution plan. As such there are many many cases where it is actually not a good thing to use cfqueryparam. using cfparam to define type on a variable is probably more or just as secure as using cfqueryparam.
securing queries is not the reason this tag exists. it is unfortunately used as a lazy or uniformed developers method to secure unclean code.
validating and cleaning your users input is ultimately the only way to address security.
using cfqueryparam may, in most cases, prevent sql injection, but the code is still dirty and results in sql statements being saved in your database fields, which can result in other unexpected data later.
Although we all know how bad coding can cause a major security problem here, there are cases where I can wrap the query in a function that is type cast.
This eliminates the need for cfqueryparam, and although there are other benefits from using this tag. It is not upto one individual to tell us how to code.
I for one will never use a host that does this. That would be like saying here is your house, but it has to be built using timber only as thats what we want for this area.


I know that there are a lot of people that do that. How can you penalize that, especially since that is meant to help with security.