I was recently asked a question by someone who had attended my Shmoocon talk entitled “Why are Databases So Hard to Secure?”. PDF slides are available (1.34 Mb). I was going to put this into a more formal structure, but the conversational nature works really well. I would love to see comments [...]
As a rule I always execute the following commands on a fresh database installation. Then for each user that is granted privileges, of course they are given a password and the host permissions are locked down as much as possible for their needs, alternately table and column privs as well. I’m not going to get into the parts the manual covers, but rather mention a couple of things on my mind.
First the initial commands:
mysql> use mysql
mysql> delete from user where User='';
mysql> delete from db where User='';
mysql> update user set Password=password('password_here')
where User=’root’;
mysql> flush privileges;
However, one thing I’ve noticed is that when you hand over a server to someone that doesn’t necessarily follow your same understanding or regard to user privilege security, bad things can happen. Such as users created without a password. …
[Read more]
I've been dealing with a security product from a security company
in recent days that breaks best practices with respect to the
database configuration. This has reminded me of the list of
issues I've seen over the past six months that have raised my
ire. I'll rail mostly at products that use SQL Server as the
back-end, but I'll save the last example for one that uses MySQL.
It's not the database products that are weak. It's the
application implementation on them!
Case #1: Don't EVER use SA and don't enable the network if you
don't have to!
This said security product recommends the use of SQL Server if
you are using it on over 1,000 users. Okay, no problem. It wants
its own instance. Okay... that raises a flag in and of itself. Is
performance really that bad? Well, no, not likely. Here's the
kicker:
To install the application you must use the sa account. Not a
service account with sysadmin rights …
As a follow up to my post about Cesar Cerrudo's new whitepaper, earlier this month David Litchfield talked about putting honeypots in the database in his blog post, Database tripwires..., to catch someone snooping around. The basic idea for non-Oracle databases is to create some sort of alerting function (such as one that fires an email) that gets called by a view with an interesting sounding name or interesting sounding column names. Triggers could work for INSERT, UPDATE, and DELETE, if the attacker is attempting to alter data. However, if the attacker is simply collecting information, then triggers aren't effective because triggers can't be defined on SELECT operations. This is why he …
[Read more]Cesar Cerrudo of Argeniss Information Security has put out a new whitepaper (.pdf format), Data0: Next generation malware for stealing databases, describing how malware could be crafted to steal information out of databases. For the most part, it stays at a high-level, however, Cesar does give a few example queries (for SQL Server), the appropriate API calls to perform certain operations, etc., which delve a bit more into the technical side, but even these are fairly straight-forward. To demonstrate what he talks about in the whitepaper, he built a simple proof of concept (PoC), but based on what's in the whitepaper (and what is generally accepted as what's possible), nothing seemed outlandish or hard-to-do. Just for those worried about that PoC being …
[Read more]While researching an article I came across a piece at http://www.simple-talk.com/sql/t-sql-programming/cursors-and-embedded-sql/. Basically the author says “embedded SQL” is bad — meaning developers should never put SQL in their code. Nor should they use ORM tools to generate SQL for them.
Instead, they should access everything they need through stored procedures. I have mixed feelings about this. On one hand, you have to give table-access permissions to users and then deal with the resulting security risks sounds very control-freakish to me. On the other hand, I agree that embedded code can be bad because if you change the database model in any way, you have to rewrite the procedural code that relies on the existence of the previous model.
And of course, stored procedures also help make your code more …
[Read more]
While researching an article I came across a piece at http://www.simple-talk.com/sql/t-sql-programming/cursors-and-embedded-sql/.
Basically the author says “embedded SQL” is bad — meaning
developers should never put SQL in their code. Nor should they
use ORM tools to generate SQL for them.
Instead, they should access everything they need through stored
procedures. I have mixed feelings about this. On one hand, you
have to give table-access permissions to users and then deal with
the resulting security risks sounds very control-freakish to me.
On the other hand, I agree that embedded code can be bad because
if you change the database model in any way, you have to rewrite
the procedural code that relies on the existence of the previous
model. …
So, O’Reilly’s ONLamp.com has published the “Top 10 MySQL Best
Practices” at http://www.onlamp.com/pub/a/onlamp/2002/07/11/MySQLtips.html.
Sadly, I find most “best practice” list do not thoroughly explain
the “why” enough so that people can make their own
decisions.
For instance, #3 is “Protect the MySQL installation directory
from access by other users.” I was intrigued at what they would
consider the “installation” directory. By reading the tip, they
actually mean the data directory. They say nothing of the log
directory, nor that innodb data files may be in different places
than the standard myisam data directories. More »
It's been a while since I've written about progress on the book. I actually stopped working on it as much at the beginning of the month, because on October 31(st) I managed to finish a first draft of the last big chapter! Now I'm back to full-time work at my employer, and I'm working on the book in the evenings and weekends only. Read on for details of what I've been working on and what's next in the pipeline.
I try my best to get things right the first time. So often,
correcting a mistake or bad choice is costly: more costly than it
would have been to take the time to do it right the first time.
However, as SQL Server MVP Andy Leonard points out, sometimes you can't correct an issue.
He starts with the example of a camera and taking a picture out
of focus and then brings it around to development. His example is
great: you can't provide up to the second updates to a system
than only collects data every five seconds. Well, you can, but
the data is only going to change ever five seconds. This raises
the question often asked by learning styles expert, …