Slashdot Mirror


Top 15 Free SQL Injection Scanners

J.R writes "The Security-Hacks blog has a summary of the 15 best free SQL Injection scanners, with links to download and a little information about each one. The list is intended asan aid for both web application developers and professional security auditors."

24 of 103 comments (clear)

  1. Why is this needed at all? by Anonymous Coward · · Score: 5, Insightful
    If you just make sure you always use prepared SQL statements with positional arguments, you will never have any problems with SQL injection.

    I suppose the over-use of PHP (which for a long time didn't even support prepared statements (does it even do it today?)) combined with stupid users that created the current situation.

    1. Re:Why is this needed at all? by ThwartedEfforts · · Score: 2, Insightful

      magic quotes ain't helping though either, but I suppose seeing backslashes littering the output (as is common on many websites) is better than SQL injection. The magic quotes setting, and the concept behind and naming of the stripslashes function, is so confusing that it's best to just turn off magic quotes, don't use stripslashes, and manually make sure you either quote everything (hard) or use prepared statements (much easier).

    2. Re:Why is this needed at all? by mabinogi · · Score: 5, Informative

      It's the completely wrong answer to the problem though, as it still promotes the idea of using SQL built by string concatenation.
      The result being that SQL injection is only one forgotten function call away.

      --
      Advanced users are users too!
    3. Re:Why is this needed at all? by hclyff · · Score: 5, Insightful

      Every language allows you to write libraries which do things properly. The language is not a limiting factor here. PHP did not for a long time. And no, I don't believe that "magic quotes" allows you to write secure code properly. Any framework which relies on string concatenation for building an SQL command is inviting insecure code, because the programmer has to *actively* seek to fix injection problems. There is statistical certainty he will overlook something sooner or later. Coupled with the fact that PHP4 was (is?) prevalent compared to PHP5/6 for a long time, it just might be the single most contributing factor to why are SQL injections so common.
    4. Re:Why is this needed at all? by vr · · Score: 3, Interesting

      If you just make sure you always use prepared SQL statements with positional arguments, you will never have any problems with SQL injection.

      Actually, that is not true, as it ignores one problem: bugs in the database drivers. Seriously, there have been bugs in database drivers that have enabled SQL injection... I specifically remember a bug in the PostgreSQL JDBC driver a while back.

      I also remember seeing a JDBC driver that simply inserted arguments into the string containing the SQL statement, although I fail to remember exactly which driver that was. This was a while back, mind you, so hopefully errors like that have been fixed. :)

      Until I encountered these things, I believed that positional arguments was the silver bullet. The point here is that positional arguements in itself is no guarantee, it is only a part of an API. At some point you have to trust the developers of the database driver and the database itself, of course...

    5. Re:Why is this needed at all? by AnObfuscator · · Score: 2, Interesting

      If you just make sure you always use prepared SQL statements with positional arguments, you will never have any problems with SQL injection.


      Well, prepared statements have their own shortcomings -- they're not the magic bullet to solve all our DB issues. Some would have you believe they are, but don't be fooled.

      I suppose the over-use of PHP (which for a long time didn't even support prepared statements (does it even do it today?)) combined with stupid users that created the current situation.

      IIRC, when PHP 4's mysql drivers were written, MySQL did not support prepared statements. However, PHP 5's mysqli driver does support MySQL prepared statements. Also, PHP 5's PDO system offers a unified DB API with prepared statements.

      --
      multifariam.net -- yet another nerd blog
    6. Re:Why is this needed at all? by billcopc · · Score: 2, Insightful

      Gee that's an easy solution: dump the legacy apps! PHP 5's only been out for 3 years :P How hard can it possibly be to rewrite the vulnerable bits of SQL anyway ? I never really felt much of a shock when I switched to PHP5 years ago, the bulk of my coding habits were unaffected and the few things that broke involved a 5-minute fix or less.

      --
      -Billco, Fnarg.com
    7. Re:Why is this needed at all? by PhotoGuy · · Score: 2, Insightful

      It's the completely wrong answer to the problem though, as it still promotes the idea of using SQL built by string concatenation.
      The result being that SQL injection is only one forgotten function call away.


      I agree. I actually find it easier to use the call with parameters, rather than trying patch together a string. Putting in the "?" parameters in the string, and listing them afterwards, pretty damn simple. I'm amazed SQL injection is an issue at all. I guess there's a lot scarier programming out there on major sites than I can possible imagine.

      --
      Love many, trust a few, do harm to none.
    8. Re:Why is this needed at all? by ceswiedler · · Score: 3, Insightful

      Huh? Do you prepare your statements every time you execute them? That would certainly be slower, but if you prepare the statement once and execute it many times, the local overhead becomes minimal and the execution time in the database improves because the DB doesn't have to re-parse and re-plan the query.

    9. Re:Why is this needed at all? by GnuDiff · · Score: 2, Insightful

      I think it is due to 2 reasons:

      1) the string concatation technique being present in several pretty popular (and awful) PHP books, and (afai remember) in the PHP documentation itself, thus becoming defacto "standard";

      2) The general ignorance of a significant part of PHP developers of any database abstraction layers and in fact anything but the magic LAMP.

    10. Re:Why is this needed at all? by enrevanche · · Score: 2, Insightful
      I cannot answer for Ruby, but for Java/JDBC this is only true for the first call to a prepared statement. For the second and subsequent calls to a prepared statement, a prepared statement is always better or at worst equivalent. With connection and prepared statement pooling, performance can be improved dramatically.

      Note that this all depends on the database and the driver, as some databases do not cache query plans or the driver does not properly coordinate the query plan with the database.

      There is no simple answer, as this all depends on the database and the application.

  2. Alternatives by stonecypher · · Score: 2, Interesting

    Of course, security through obscurity is badbear.

    That said, there are times - and this is one of them - that I'm glad my recently most common database isn't fundamentally SQL, or anything well-recognized. It also helps that (I believe) mnesia is immune to injection, given that its queries are never textual, but rather always functional, and given that data are always presented as arguments. Every route to injection I'm aware of just doesn't make sense in context (though if someone knows a way attack Mnesia, I'd love to hear about it.)

    Sure, there are times at which SQL is a major win over mnemosyne, but they're not common. Sure, it's nice to have a database be ready for you at any host, instead of having to take the time to find a good host who lets you run stuff. But when it comes down to it, the atypical performance characteristics of Erlang (especially since I write multiplayer games, for which massive concurrency is win) and the ridiculous speed of Mnesia make me miss SQL less every day.

    'Course, client stuff still needs to work on MySQL. :(

    --
    StoneCypher is Full of BS
  3. Detecting SQL Injection is hard ... by Gopal.V · · Score: 4, Insightful

    The feedback factor for SQL Injection is very low. It is very hard to generically detect the after-effects of a successful sql-injection attack.

    In comparison, something like XSS is easy because if you inject a string, the string re-appears in the HTML returned (HTML injection). The XSRF and XSS attacks dominate the internet attacks because they are really easy to scan for - though technically that should be an excellent reason they shouldn't exist :)

    Rasmus Lerdorf has this awesome test-tool for XSS he keeps demo'ing (thankfully not released). You can see the tool in action in the background. But there's still no real easy way to reliably scan for Sql injection.

    1. Re:Detecting SQL Injection is hard ... by Plutonite · · Score: 2, Insightful

      Rasmus Lerdorf has this awesome test-tool for XSS he keeps demo'ing (thankfully not released). Why thankfully? I've left this stuff a long time ago, but nothing has changed about security and obscurity. You cannot win this way, you only prolong a possibly undetected failure.

  4. what exactly is an sql injection? by siddesu · · Score: 2, Interesting

    i hear people talking about them from time to time, but i still can't figure out how they appear.
    ain't there query parameters in practically all database access APIs?

    1. Re:what exactly is an sql injection? by MickDownUnder · · Score: 3, Informative

      SQL injection attacks target code in which sql statements are dynamically created.

      e.g.

      'select * from employees where fullName like ' + mySQLInjectedInputFromUser

      where mySQLInjectedInputFromUser has been asssigned a value entered by the user:-

      Fred Flinstone; GO; delete employees; GO

    2. Re:what exactly is an sql injection? by FooBarWidget · · Score: 2, Insightful

      What do you mean, "I'll bite"? What makes you think it's a troll? Can't people have a legit question these days without being seen as flamers and trolls?

  5. Testing slashdot by mobby_6kl · · Score: 4, Funny

    blah'; UPDATE users SET uid = '1' WHERE uid = '668092';

  6. Re:Properly written software... by growse · · Score: 2, Insightful

    Which I'm sure is fabulous if you're using .NET and MSSQL. However, I imagine that particular combination doesn't make up a very large percentage of all the database applications out there.

    Don't get me wrong, stored procs are a useful tool which are the correct answer to some types of problem. But completely overkill if you just need simple or even slightly complicated CRUD operations. Using stored procs when they're not really necessary is the mark of a developer who doesn't know how to use every tool in his toolbox properly.

    --
    There is nothing interesting going on at my blog
  7. Top 15 _______? by kjart · · Score: 2, Insightful

    What is this, Digg?

  8. Validating Input by mtjo · · Score: 2, Informative

    Validating input prevents alot of problems. Prepared queries help but can still be exploited in poorly written statements. As in the classic SELECT query example, "where id=23 OR 1=1", using a datatype test as well as testing for null values for a $_GET or $_POST parameter before executing the query would throw back an error if expecting an unsigned integer.

  9. One of the best SQL injection attacks I've seen... by thewils · · Score: 4, Informative

    ...was in conjunction with an error page which displayed the results of failed SQL.

    I was able to change an innocuous 'select ... from catalog where section=1' into 'select ... from catalog where section=(select password from users where id=1)'.

    This was nicely reported back to me as a SQL error stating that SQL was unable to convert "sdfsdfsdfsdf" into an integer, where "sdfsdfsdfsdf" was user id 1's password. I reported the problem to the site's owners, and it was still a month before they fixed it.

    Moral of story - don't show the users any SQL errors, it gives them far too much information.

    --
    Once I was a four stone apology. Now I am two separate gorillas.
  10. do they check cookies? by brunascle · · Score: 2, Insightful

    it's not just URLs and post-back forms that can be vulnerable, cookies can be too. i didnt realize that until i found one on my own site. (it wasnt exploited, i found it on my own.)

  11. Re:Properly written software... by Ash+Vince · · Score: 2, Insightful

    What alovely idea, but here in the real world we have things called design constraints. Like maybe you have a web application that has been doing its job for the previous 5 or 6 years but is also constantly evolving. You have a lot of legacy code that was written to run against a mysql database from 5 years ago. That puts you on MySQL 4.0 with no stored procedures.

    Now I am not saying this doesnt need an upgrade (currently in the works), but when you are talking about a mission critical app that is already making money you have to be very careful about breaking anything, you cant just throw a new version of mysql on your master database server and pray to the gods of IT. You have to be 100% sure everything will work before you move to a new version of anything, otherwise you irrepairably damage the image of your business.

    Even when you are sure that it will work you have to perform the switch outside of core hours and warn customers of the potential for downtime. Things do not always go 100% according to plan and the most minor error can have serious consequences. Especially when in order to do something outside working hours you are doing this at 4am. It takes several days to switch your sleep patterns over to nighttime working but quite often in the run up to the overnighter you are too busy to sleep all day.

    Out here in the real world we have to deal with suboptimal platforms as the decision to go with a particular DB server might have been taken years before you started working for the company. You can not just go in and insist everything is changed to what you would prefer (even if it is a better platform).

    --
    I dont read /. to RTFA, I read /. to offend people in ignorance.