I've been SQL injected!

drebo

Diamond Member
Feb 24, 2006
7,035
1
81
Well, not really...it wasn't my code. But, I'd never actually seen a SQL injection before.

The culprit? A page that pulls management bios from a database and displays them.

Moral of the story? Don't embed form variables (or URL variables) directly in your SQL queries without first verifying them!
 

JACKDRUID

Senior member
Nov 28, 2007
729
0
0
or you can use a stored procedure, which should take care of most of the sql injection attacks.
 

drebo

Diamond Member
Feb 24, 2006
7,035
1
81
Yeah...my customer is learning that very quickly.

Anyway, as an update, it appears that this is a fairly widespread issue with ColdFusion 8 that's cropped up in the past few days. It's affected two completely disparate sites on separate servers of mine now in the last two days. Interesting. Both times were pages that were written in similar fashion (not by me) and used inline queries.

Just a warning to anyone else out there using ColdFusion...check your queries!

Edit: For anyone who's interested, here's some more info: http://www.coldfusionmuse.com/...te-Ben-Speaks-His-Mind
 

alocurto

Platinum Member
Nov 4, 1999
2,173
0
76
I had that happen to a site I am hosting (didn't write) in CF. ha, it's a freakin mess and a half. They are like "Fix it!"... yeah... ummm 10000+ CFM pages.. I'll get right on that. Always use parameterized queries from code and always use stored procs.
 

Snapster

Diamond Member
Oct 14, 2001
3,917
0
0
Thankfully most of the sites I've had to 'fix' have had a common include file where I can just scan through the request vars for fishy stuff. Saves me having to update loads of pages quickly/cheaply.
 

alpha88

Senior member
Dec 29, 2000
877
0
76
You should investigate the competence of whoever is writing the code.

Cold Fusion is probably the easiest language to protect against SQL injection.

You can still do 'inline' SQL, just use <cfqueryparam /> in all your queries.

Example

<cfquery name="select">
SELECT Something FROM Users WHERE Email = <cfqueryparam value="URL.EmailAddr" cfsqltype="CF_SQL_CHAR" />
</cfquery>
 

drebo

Diamond Member
Feb 24, 2006
7,035
1
81
From what I've read, ColdFusion automatically escapes strings within SQL queries. The vulnerability (this one, anyway) had to do with injecting into number fields.

I would still parameterize them...but just saying.
 

AleleVanuatu

Member
Aug 16, 2008
95
0
0
This is such a noob mistake. Soon I hope that most languages won't even let this happen by building in sanity-checking into the relevant sql api.
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
Originally posted by: AleleVanuatu
This is such a noob mistake. Soon I hope that most languages won't even let this happen by building in sanity-checking into the relevant sql api.

You won't be able to prevent this on the API level until you stop preventing people from running adhoc queries. If the API was checking every single query for sanity there would be quite a bit more overhead then what you currently see.

For example, Ruby on Rails has great built in ways to generate results from a database where you don't have to type a single line of SQL. It handles all of the escaping and prevents SQL injection, yet you can still run a full blown hand written SQL statement through code where it won't check the query and just run it which is vulnerable to SQL injection.
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |