303 points · by sucuri2 · 15y ago · 110 comments
http://seclists.org/fulldisclosure/2011/Mar/309?utm_source=t...
Shameless self plug: Netsparker ( My startup: http://www.netsparker.com/ ) could have identified both of these vulnerabilities.
How is it different? I watched the demo video and couldn't really tell.
Metasploit is an exploitation framework. There's different versions available (community, pro etc.). The community version has a web app scanner and is reasonably ok, but it tends to be caught by intrusion detection systems fairly easily and it's payloads often don't clean up properly. It's better suited to infrastructure exploitation, but can be used in a web app context.
Canvas[1] has some limited web app scanning capability but has more of a core focus on infrastructure exploitation.
Burp Suite Pro[2] is a framework for testing web applications. It's probably the best tool out there for testing web apps (if you know what you're doing). It's also ludicrously cheap and there is a free version for non-commercial use. It comes with a fairly comprehensive web app scanner.
NetSparker is a web application scanner. From what I can tell it's mainly competing with things like Accunetix. It has some features that are similar to Metasploit Pro but focuses primarily on the application layer. It sits more between Burp Suite Pro and Canvas for my purposes. You can download an eval from http://www.mavitunasecurity.com/ or the community edition.
Netsparker is solely focused on web application security (detection & exploitation). For example Netsparker can crawl AJAX/Javascript apps, support form authentication etc. Metasploit on the other hand possibly will never do that kind of stuff.
Do we need to get into a detailed discussion of why I think the plug for your scanner is inappropriate for this thread? Or can we just let it suffice to say that HN isn't a great place to promote products on random threads?
But, more to the point, how annoying would it be if every time I responded to a comment on HN, I added "this is one of the many things we take care of it you get us to review your applications"?
When threads are about products, I think it's fine --- helpful, even! --- to point out competing offerings and alternatives. But on news stories, let's just keep the commercial offerings off the threads.
(I'm aware this may make impossible to use some web frameworks which rely on rdbms reflection, but I have the feeling this is not the case)
So yeah, it's the fault of the developers but it's also the fault of the people who aggressively marketed and evangelized MySQL and helped create the ditch they're just now digging themselves out of. It's a bit like the VB/Access culture Microsoft promoted back in the day, which generated some of the most hideous corporate apps I've ever seen. Yes, some developers are bad, but the company or group doing the evangelizing/marketing also needs to share some responsibility.
BlogComment.find(:all, :conditions => ['email = ?', 'foo@bar.com'])
But if you look at the source code you'll see that it just constructs a normal SQL query by internally substituting the '?' with the escaped version of 'foo@bar.com'. It does not utilize the database parameterization APIs at all.If you think stored procedures protect you against SQL injection, consider the following code snippet:
sql_exec("CALL InsertBlogComment('" + get_parameter("text") + "')")This means that every protocol client must implement their own query escaping, rather than relying on the database to provide a single, normative implementation of escaping.
> For example Ruby on Rails's ActiveRecord provides an API that looks a lot like it uses parameterization under the hood:
ActiveRecord's use of the non-parameterized APIs has led to a number of escaping/injection issues in the past eg, (http://www.ruby-forum.com/topic/152058, http://gsa.ca.com/vulninfo/vuln.aspx?id=36929, etc).
> If you think stored procedures protect you against SQL injection, consider the following code snippet ...
I believe the original poster was referring to the use of stored procedures as a mechanism for preventing or discouraging unintended direct modification of the database by applications, rather than SQL injection, specifically.
MySQL is a crucial part of its own community. You cannot hold the community responsible for this situation while giving MySQL a pass.
What?! Parameterized queries (in any competent implementation) ARE, in fact, injection protection mechanisms. Escaping != Parameterization.
Ruby on Rails is a poor example to use here - it's a trendy web language that (judging by your comment) does not use proper database practices.
Properly implemented parameterized queries offer protection against SQL injection because they seperate data from instruction - none of the data points in a query are executed, ever.
Gluing SQL instruction strings together with data from users is incredibly stupid and you should never, ever do that.
Use a framework that supports proper parameterized queries.
Aside from implementing bound parameters (which is useful for more than just preventing sql injection), we usually recommend using stored procedures if at all possible.
It's really suboptimal to rely on the user to specify what table they're accessing.
Think of it as the difference between the language keeping loaded footguns under its pillow with the safety off and keeping unloaded footguns in a locked gun safe. One is a lot less likely to get used than the other, even if either one will shoot your foot just as well.
One wonders what internal neglect MySQL is suffering behind the corporate veil.
The guys that write the actual database have nothing to with the web team. They didn't in MySQL days, they don't now.
Edit: It seems there are ways to work around server-side SQL parsing: http://www.xarg.org/2011/01/is-it-possible-to-avoid-query-pa...
I was thinking more about why it is allowed at all to send text-like SQL queries to a server. A binary protocol would both be simpler to handle and would have saved us from a lot of trouble.
Edit: If all client-side libs (for PHP, Python, etc.) would just use those [prepared statements](http://dev.mysql.com/doc/refman/5.0/en/c-api-prepared-statem...), it would be like what I mean.
Edit: Ah, I was wrong (as I hoped): For Python: https://launchpad.net/oursql
Of course that does not help if you construct the entire query string as text before sending it to the server, which is how SQL injection most commonly happens.
Prepared statements should afford you a clean conscience because the values never make up part of the SQL query .. unless you are using a library that emulates it, and there are libraries out there that do, so don't assume anything.
"because not every input to every query can be bound as a variable" Can you give me an example?
"Some operations do require dynamic query construction." what does that have to do with prepared queries?
Select(args=["name", "id"], from="students")
And maybe "name", "id" and "students" also could be replaced my some reference pointers.But in case someone really wants to keep the language, you could still do the parsing inside of the lib and thus for example disallow multiple commands in one statement and then only send some binary representation to the server (mostly like Prepared Statements in MySQL). Whereby I think that this step is obsolete and would in any way produce further problems.
Btw., this is not exactly like NoSQL what I am talking about here.
SQL is text. Also no one is sending a query to the server. It's a value that is embedded into the SQL query that circumvents it.
So they unnecessarily had a lot of people's username/passwords for absolutely no good reason.
I hate sites that require logins. Though apparently this one had a way around it, lots don't, and many of them are already in bugmenot. If not, add a mailinator-based account for others :)
But I agree. Most of the time, I prefer PostgreSQL.
I wonder if the timing on this has anything to do with Oracle's continued dismantling of the useful parts of the MySQL website.