Has ColdFusion MX taken care of SQL injection ?

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default Has ColdFusion MX taken care of SQL injection ?

    Has ColdFusion MX taken care of SQL injection ? The reason is that when I
    tried to test my own application without using <cfqueryparam ...> it seems like
    when I test with a form field it adds extra quotes automatically in the query
    at runtime to handle this. If this is so do we need to use <cfqueryparam ...>
    .. Also is it the same for URL variables as well. If Cold Fusion is still
    vulerable can someone post me some test lines so I can try them. Ihave tried
    just about everything I know about SQL injection and have reached the end of
    the road. Thanks

    yaf23 Guest

  2. Similar Questions and Discussions

    1. SQL Injection
      Hi, I have to check all textboxes in my web application for SQL injection. Is there any ready product that detect SQL inhection patterns? A...
    2. Taking care of Fail Back in HDR
      Again this is another surprise for me in Informix that failover is not automatic. In fact they expect the application logic to be written keeping...
    3. Anyone care to share experiences they've had with smartDAX 700?
      We're shopping for a archivial mechanism, and have had extended conversation with these folks (ChessET). It all looks good, but it's all a single...
    4. Joining Tables from different DBs => Do I have to care about performance?
      Hi, I have a more theoretic question: I have two huge tables (db1.dbo.table1 and db2.dbo.table2). I need to join them. Will the effort to join...
    5. Nursing, Care
      Hello all - am new to this site. Can someone direct me to a royalty free site for nursing or loving care high resolution photos? Or, better yet, do...
  3. #2

    Default Re: Has ColdFusion MX taken care of SQL injection ?

    The short answer: Every system is vulnerable to SQL injection, one way or
    another. There will never be a computer language that can PREVENT you from
    shooting yourself in the foot. The long answer: It looks like you're testing
    all of the right things, and you should be pretty safe. It is highly
    recommended by most experts for both of SQL injection, as well as performance
    reasons. So, unless you really NEED to put parameters inline in the SQL,
    switch back to <cfqueryparam> and you're just about guaranteed that you're safe
    from this attack. In addition, you're describing on another anti-sql-injection
    feature of CF. Within a <cfquery> block, ColdFusion will automatically escape
    single quotes in the value of any variable that you include. So, when
    FirstName='O'Reilly', putting #FirstName# inside a <cfquery> block will
    actually send O''Reilly to the database server. This default behavior can
    cause a problem in some instances, so CF includes the PreserveSingleQuotes()
    function that lets you manually override it. It also works slightly
    differently when you have a function such as #Left(FirstName, 10)# -- so it's a
    good idea to test these, too. Benjamin Pate P.S. Security is always relative.
    For example, are you locking out login attempts after 6 tries, or can I run a
    dictionary attack against your user database until I find a username/password
    combination? It always comes down to how much work, and dilligence you put
    into your code. That common sense goes for any language.

    Ben Pate Guest

  4. #3

    Default Re: Has ColdFusion MX taken care of SQL injection ?

    As mentioned:
    When outputting variables inside a cfQuery, CF escapes all single-quotes
    within the value of the var.

    I'd therefore say that SQL-injection is taken care of in CF !

    The only way around this is specific use of #PreserveSingleQuotes(myVariable)#
    => shooting yourself in the foot ;-) if you do it without real purpose

    There are some bugs in this replacement function:
    In #Form[myVar]#, CF will escape single-quotes in the value of myVar (the name
    of the form-var), NOT in the value of the actual form-var (don't really know
    the behaviour in newest CF-version, MX still had that bug).

    BTW, we've never seen a use for cfQueryParam and prefeer to write our complete
    SQLs ourselves with the correct datatypes.

    p.s.
    Single-quotes in variable-values is the only kind of SQL-injection that I know
    of, anyone know another?

    Stefan K. Guest

  5. #4

    Default Re: Has ColdFusion MX taken care of SQL injection ?

    Originally posted by: Stefan K. BTW, we've never seen a use for cfQueryParam
    and prefeer to write our complete SQLs ourselves with the correct datatypes.
    Stefan, You need to look at what cfqueryparam actually does. The advantages in
    sending a prepared statement to the database rather than a plain string of SQL
    are numerous, especially if you are on a database that supports bind variables
    (like MSSQL and Oracle). It's basically all the advantages of stored procs
    without having to actually write stored procs.

    Dross.2 Guest

  6. #5

    Default Re: Has ColdFusion MX taken care of SQL injection ?

    @Dross2

    Thank you for the hint.
    But writing stored procedures really is no problem, same with local vars.
    We just prefeer it this way so we see and know what's going on.

    Stefan K.
    Stefan K. Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139