Article Rating: |
||
| August 8, 2008 04:00 PM EDT | Reads: |
5,952 |
SQL Injection attacks are one of the easiest ways to hack into a website. One recent hack, using a script from verynx.cn, involves injecting SQL into a web form that then appends some JavaScript code into fields in a database that then gets executed on the client side when a user views a database-driven page. To learn more about this hack, go to this link.
If you're using ColdFusion, to harden your website from sql injection attacks add the following code to your Application.cfm file. If you're not using ColdFusion, you can translate this code into the language you're using and it should still work.
<!--- CREATE SQL REGULAR EXPRESSION---> <!--- CHECK FORM VARIABLES ---> <!--- CHECK URL VARIABLES ---> |
This code would reside in your Application.cfm file which gets executed every time a ColdFusion file is requested on the server. What it does is it checks all form and URL variables to see if they contain any patterns matching an SQL SELECT, UPDATE, INSERT, DELETE or DROP statement.
If a match is found, the user is redirected to a message page indicating that a possible SQL Injection attack was made and the SQL injection is prevented.
Published August 8, 2008 Reads 5,952
Copyright © 2008 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
![]() |
littleviews 05/15/09 01:37:00 AM EDT | |||
I could not make this work in CFMX8. Does anyone have any suggestions? |
||||
![]() |
cmosdall 10/15/08 03:07:54 AM EDT | |||
There’s a very nasty SQL injection attacking our sites at the moment: DECLARE @S CHAR(4000); You need to add DECLARE and EXEC to the regex. |
||||
![]() |
klevenson 09/18/08 12:25:41 PM EDT | |||
If I change sqlregex = "select" for testing the code works fine. The complete regular expression as listed above doesn't seem to work in CFMX8. |
||||
![]() |
distinct 09/03/08 10:17:09 AM EDT | |||
Dangerous Solution! Whilst it can be useful to attempt to detect SQL injection; using detection as a defence mechanism is risky. The only way to really be sure that no SQL injection will be possible in ColdFusion is to ensure all queries use the cfqueryparam tag around user supplied input. Additionally, all user input should be validated server side in order to ensure it matches a specific and expected data type and format. In programming, one can always prove what is true, but not always prove what is false. Trying to protect a system by determining what user input is bad is shakey. By contrast, protecting a system by determining what user input is good is solid. Essentially, a system should only accept and process user input which adheres to an expected datatype and format. Everything else should be rejected. Beware! |
||||
![]() |
pgwalters 07/30/08 11:08:54 AM EDT | |||
And, if I may, add TRUNCATE TABLE (or the equivalent for your DBMS) |
||||
![]() |
cfengineers 07/30/08 09:22:00 AM EDT | |||
Dont forget that DECLARE should also be in the list. |
||||
- Oracle To Keynote Cloud Computing Expo
- Contrary Opinion: Why Silverlight is Good for Adobe
- Analytics for Adobe Air Applications
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Eval JavaScript in a Global Context
- Fig Leaf Software to Exhibit at Government IT Conference & Expo
- Is Microsoft as Free as Open Source?
- Cloud Computing Journal: Adobe to Deliver ColdFusion in the Cloud
- The Planet Named “Bronze Sponsor” of Cloud Computing Expo
- Adobe Reader Sued
- AJAX World RIA Conference & Expo Kicks Off in New York City
- Adobe Enters Cloud Computing with LiveCycle
- Oracle To Keynote Cloud Computing Expo
- Social Media Terrorists
- Adobe Flash Media Server on iPhone
- Contrary Opinion: Why Silverlight is Good for Adobe
- Adobe Flash Based GetJar Surpasses a Half Billion Downloads
- Adobe ColdFusion 9 and ColdFusion Builder Public Betas Now Available
- Adobe Tries Commercializing Its Online Software
- Adobe Open Sources Flash Initiatives
- The Next Programming Models, RIAs and Composite Applications
- Where Are RIA Technologies Headed in 2008?
- Constructing an Application with Flash Forms from the Ground Up
- AJAX World RIA Conference & Expo Kicks Off in New York City
- CFEclipse: The Developer's IDE, Eclipse For ColdFusion
- Personal Branding Checklist
- Adobe Flex 2: Advanced DataGrid
- Has the Technology Bounceback Begun?
- Building a Zip Code Proximity Search with ColdFusion
- i-Technology Viewpoint: We Need Not More Frameworks, But Better Programmers





































