Sqlmap – Automatic SQL injection and database takeover tool
sqlmap.org
sqlmap.org
But honestly, I have never heard another developer talk about using it (though I imagine full time sysops and security folks know it well)...even though it seems like it has an API easy enough to use and throw in as part of your dev toolkit (e.g. run it as part of an integrated test quite).
It's a tragedy that it has been almost a decade and it's still just as effective -_-
Cool to see tools lasting / improving, but depressing that SQLi is still so pervasive...
Prevented with prepared statements - correct?
I can't tell you how many times I've seen someone passing a query though the prepared query method but still crafting the query dynamically
Stuff like:
prepareQuery("SELECT something FROM table WHERE col='"+userInput+"' and otherCol=?", otherUserInput);
That is still vulnerable even though prepared statements are in use. As long as user input doesn't find its way into the query string though you should be safe from these assuming the issue isn't internal like bad stored procedures creating queries based on input.
This is very dumb, yet too common. :-/
"You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the
right syntax to use near '\'' at line 1"
As soon as we see an error message like this, we know we can dump the entire database in a matter of minutes.These days, we usually have to work a bit harder to find the more difficult to identify and exploit SQLi (e.g. boolean-based blind and time based) but the end result is the same once we do. SQLMap is a standard tool in a any good web app penetration tester's toolkit. It's not always going to work but when it does it automates away a lot of the grunt work. I applaud the SQLMap developers who seem to know SQL inside out and actively acknowledge feedback from the community.
For any devs, this is decent guide for preventing SQLi:
https://www.owasp.org/index.php/SQL_Injection_Prevention_Che...
I would say that SQLmap is normally effective at determining whether a HTTP parameter is injectable with a high degree of confidence. However, sometimes there will be Web Application Firewall (WAF) filters or unusual/inconsistent application behaviour on certain inputs which means it can't confirm whether the parameter is definitely vulnerable or not (less than 10% of the time in my experience). For the same reasons, often it won't be able to successfully automate the exploitation for you. On those occasions, we have to craft our queries manually to exfiltrate database contents and so forth.
And then there's the VTech's of the world.... sheesh!
Many people out there just simply don't feel like writing prepared statements, entity classes for domain specific problems, or pushing past SQL query strings, and treating a data access layer as more than a scriptable text-based input vector to a glorified command line tool.
For as long as there are SQL databases, so too, there shall be successful SQL injection attacks.
In all fairness, I'd say it's more like web application security is a huge field (larger than just SQLi) and a developer typically has their hands full wrestling the technologies they use on a daily basis.
I am the most senior developer here in a team of 6 and we all know just the most basic facts about SQLi (use stored procedures), XSS (use sanitizing libraries) and it ends right at CRSF. Of the OWASP top 10, we have an eye on the top 4 and I wouldn't wager a high bet we have them nailed down.
It feels bad, but considering the resources we'd need to pour into getting one of our better devs trained in all the facets of web app security, it's unlikely to change any time soon.
Consider the resources you'll have to expend in the event of compromise and compare. While this analysis doesn't always prove the slower but more secure approach to be cheaper, it usually does. Unfortunately, you usually can't get the people holding the purse strings to accept the trade until they've been bitten.
"Thanks for bringing this topic up, Mr. iSnow.
Looking at it pragmatically, we have no real use-case for that right now, so I don't think it's the right time to dive into it. I will, however, keep it in mind and would ask the team to collect information on this and keep an eye on the subject".
And of course, without dedicated time and budget for such a large area, developers can either cheat and hide learning it between feature requests or don't do anything about it. So, I am totally not surprised things like the VTech break-in happen all the time, I just don't think it's fair to blame developer's inertia for it.
I know prepared statements are the way to go but proper escaping, even if tedious, seams to be OK for me.