Security vulnerability in MySQL ubuntu
seclists.org
seclists.org
mySQLgame[1] demonstrates that domain logic can be successfully implemented within a publicly accessible database[2]. It would be better to reword your statement to:
Minimise the attack surface by preventing unnecessary access
There are times where public access to a database server make perfect sense. It is the reason why database servers implement TLS client certificate verification, Role Based Access Control (RBAC) and other security features which a typical application (with domain logic at the application layer) has no hope of implementing correctly.
In any case, the typical web app deployed by HN readers has no business having an exposed MySQL port.
This works well. There are some things we are still working on improving, but it's getting there. Moreover it means multiple clients on multiple codebases are possible and we don't have to worry as much about the implications of what happens when someone writes a secondary client to hit the database.
At the same time, we use PostgreSQL, which I have a bit more confidence in than MySQL. Of course I would still suggest limiting access only to those IP address ranges where that is necessary.
1) Going to a db-centric security model has allowed us not to trust the SQL-Ledger code (good thing too).
2) We are refactoring/removing SQL-Ledger code as quickly as possible. As of 1.3 this means payment logic, reconciliation logic, contact management logic and more. 1.4 will hopefully rip out and replace all search and reporting functions. It will take us a few more years to get the codebase where we want it though.
3) The bad thing about bad code is that bad code is contagious. When you spend a lot of your time debugging bad code it is very hard to write good code. Most of what we wrote for 1.3 will need to be rewritten again. I am pretty happy with the code we are writing for 1.4.....
I think we have come through the worst of it. Pace of development is speeding up which is a good sign and much more of the application is subjected to unit tests.
As a side note, when we first added unit tests to the number rounding tests for the code we inherited from SQL-Ledger, there were failures. We replaced that logic very quickly.
Yeah, it was pretty bad... Now its getting better.
Edit: Also it seems to me the worst never seems so bad when you are in it. I don't think that I could see how many problems we had from this until I am here, half way from 1.3 to 1.4, asking why 1.3 took five years to release (we beat Perl 6 and HURD though, I guess Duke Nukem Forever in fact beat us date-wise by a couple months).
Looking back at the customers of mine who have had problems, or projects that went way over budget or took too long because of difficulties here, I can see how much that hurt us. At the time though, it was just one of those keep working on it kind of things.
On other other hand, I'd trust OpenSSH more than MySQL.
Also agreed. I'd trust OpenSSH to do security better than MySQL.
Thus began years of efforts on our part of security fixes, which I would not have started except that I had customers to support.
Cheapest? SSH tunnel or openvpn point to point link.
http://lcamtuf.blogspot.com/2012/06/this-page-is-now-certifi...
To me, that makes as much sense as:
"In most real-world applications, file permissions have absolutely no effect on security."
Or:
"In most real-world applications, running services under isolated uids instead of running everything as root has absolutely no effect on security."
It's a bold claim, but one made with no evidence to back it up.
Your advice is for everyone that is providing and using shared web hosting, to stop it?
Sorry if that makes you feel bad.
Tens or hundreds of millions of database servers? That's hyperbolic.
Do you really think that we've come close to eliminating all the vulnerabilities inside a MySQL session, post-authentication? Because what you're arguing is effectively that application owners should trust that MySQL is resilient against attackers who can get an authenticated handle to their own database and run nearly arbitrary SQL statements against it. You think all the code in the MySQL query parser, the planner, and the various storage backends have been fully audited? This is a project that didn't even get authentication right.
Now, do you really care if some community bulletin board's database gets owned? Probably not. But I wouldn't run a shopping cart on a shared hoster.
I agree. tptacek is the one who disagrees with you. He thinks there is "never" a good reason to use shared hosting.
I really don't understand Mike Cardwell's objection; I don't think what I'm saying is controversial at all. I actually thought I was making a relatively banal point.
You: Attackers should never, ever be able to connect directly to your MySQL database directly
Me: "Never" ... You are aware of the existence and mass use of shared web hosting systems right?
EDIT: You could have just replied to my original comment agreeing with me that shared hosting systems work that way, and that it's ok for certain types of site. It would have made more sense than your comment "Don't use shared web hosting."
If you don't fit either of those molds, I don't think any less of you, but I'm not going to tailor my advice to you either.
It really sounds like you're just looking for something to be indignant about. I don't know you or anything about you, so I had no expectation that you were that kind of person. Consider addressing your objections to the thread, instead of aiming them at me, if you'd like to avoid that appearance. For truly, I do not care whether you like shared hosting or your friends are struggling indie shared hosting operators. That's not relevant to me even a little.
A less personal way to frame your objection, rather than "Are you commenting just so you can be downvoted to oblivion", would be to write a comment that starts with the words "There is another side to this that readers should consider..." and go from there.
"If you operate the kind of application that people on HN tend to operate, you should avoid shared hosting."
Is a far cry from:
"Attackers should never, ever be able to connect directly to your MySQL database directly"
That comment was about as useful as:
"Attackers should never, ever be able to enter the data center where your servers are hosted"
https://github.com/rapid7/metasploit-framework/blob/master/m...
If you do need your mysql to be exposed to the internet you can use bind_address=x.x.x.x or some kind of firewall.
That's two months ago. Looking at the changelog (http://dev.mysql.com/doc/refman/5.1/en/news-5-1-63.html), they piled in a bunch of other changes like "use less disk space". This should have gone out pronto. I feel it's not the kind of thing you sit on until your next quarterly release is scheduled.
[oh wait, this is worse. mysql 5.1.63 was actually released a month ago. But they only now tell us what the security bug was? Meanwhile the bad people have had a month to diff sources? Double unhappy.]
What ever happened to public disclosure as soon as a patch is released?
I have been bit twice by problems relating to difficulties getting security fixes/announcements out in time. In my defence I was trying to patch a difficult codebase and this just took a long time. For example, there was a full SQL injection audit that took us two months to complete early on, and there was an issue of XSRF vulnerabilities which could not be effectively patched in a production release.
But waiting a month to announce the security issue after the release was out strikes me as hard to justify.
Unfortunately Oracle's stewardship of MySQL appears to be a closed model. There is no public access to their bug tracker, and distributions struggle to keep up with security updates because the details of their fixes in the source are not published. The future of MySQL appears to be in one of the MySQL forks.
See https://lists.ubuntu.com/archives/ubuntu-server/2012-Februar... and https://lists.ubuntu.com/archives/ubuntu-server/2012-Februar... for details.
Via HDMOORE on twitter
This is a serious vulnerability. Especially since the latest ubuntu seems to be affected(I'm on mint 13, and it is)
See Ready shodanhq query for latest mysql version:
http://www.shodanhq.com/search?q=port%3A3306+5.5.22-0ubuntu1
Debian lenny 32-bit 5.0.51a-24+lenny5
Debian lenny 64-bit 5.0.51a-24+lenny5
Debian lenny 64-bit 5.1.51-1-log
Debian squeeze 64-bit 5.1.49-3-log
Debian squeeze 32-bit 5.1.61-0+squeeze1
Debian squeeze 64-bit 5.1.61-0+squeeze1
Ubuntu lucid 64-bit 5.1.62-0ubuntu0.10.04.1
So I'm not inclined to think it's as bad as made out by the simple exploit above.
It sounds like they were casting the result of a memcmp to a char. A char only has a range of -128 to 127. The resulting overflow means that an arbitrary password hash has a 1/255 chance of landing on 0, but you still have to try a bunch to hit one.
How do you know, how the Ubuntu devs compiled their mysql server?
But, that is just my single VM instance and I would assume HD Moore knows what he is doing.
However tests of trying to brute force the root password using the mysql one liners in this thread have failed every time.
Both machines allow local access only so I assume I'm safe.
Here's a guide for limiting access to it by IP address via the apache config for Ubuntu users:
http://mixeduperic.com/ubuntu/how-to-restrict-phpmyadmin-ip-...
This is why real C programmers use int as their bool type. :)
It has the same problem if a wider type (e.g. long) is assigned to it. Use _Bool instead.
return 0 == memcmp(hash_stage2, hash_stage2_reassured, SHA1_HASH_SIZE)
As in, return a bool on whether it matched.I mean, as I read it, the function returns true if they don't match?
Also, the associated bug report: https://bugs.launchpad.net/ubuntu/+source/mysql-5.5/+bug/101....
I thought at first it might be because I do not have a root password (it's a VM) so trying to use any password at all returns a failure before the faulty code is reached. Then I tried to login as debian-sys-maint and some other users that do have passwords, and it still did not work.
(Again, this is just an unconfirmed theory.)
If you roll a dice 6 times, will one result be a 6?
(5/6)^6 = 0.335
For the original question:
(255/256)^256 = 0.367
so yes, you'll succeed in 63.3% of the cases.
I am sad to say it worked on my Ubuntu server :(
So you need a 64 bits system, and be sure that you are not using a virtualisation system which does clear SSSE4 flag in /proc/cpuinfo (VirtualBox does).
Why 1/256?
Ubuntu always ship fucked up, broken, shitty MySQL versions.
Look at the one that is current HEAD on 10.04 LTS. It's got so much broken stuff in it, we had to move everything to a spare windows machine where we could stick a later version on without screwing up the machine (DBs for: team city, jira, crucible).
I'm in the process of binning it all and moving to Debian which is actually trustworthy...
This is a slicehost box, so I'm assuming that can be extrapolated to mean that anyone using ubuntu on slicehost is probably safe.