Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I keep a mySQL database secure?

I'm going to be implementing a PHP/mySQL setup to store credit card information.

It seems like AES_ENCRYPT/AES_DECRYPT is the way to go,

but I'm still confused on one point:

How do I keep the encryption key secure?

Hardwiring it into my PHP scripts (which will live on the same server as the db) seems like a major security hole.

What's the "best practice" solution here?

like image 863
user3578 Avatar asked Sep 11 '08 01:09

user3578


2 Answers

You should think long and hard about whether you REALLY need to keep the CC#. If you don't have a great reason, DON'T! Every other week you hear about some company being compromised and CC#'s being stolen. All these companies made a fatal flaw - they kept too much information. Keep the CC# until the transaction clears. After that, delete it.

As far as securing the server, the best course of action is to secure the hardware and use the internal system socket to MySQL, and make sure to block any network access to the MySQL server. Make sure you're using both your system permissions and the MySQL permissions to allow as little access as needed. For some scripts, you might consider write-only authentication. There's really no encryption method that will be foolproof (as you will always need to decrypt, and thus must store the key). This is not to say you shouldn't - you can store your key in one location and if you detect system compromise you can destroy the file and render the data useless.

like image 72
Kyle Cronin Avatar answered Oct 05 '22 20:10

Kyle Cronin


MySQL, there is six easy steps you can do to secure your sensitive data.

Step 1: Remove wildcards in the grant tables

Step 2: Require the use of secure passwords

Note: Use the MySQL “--secure-auth” option to prevent the use of older, less secure MySQL password formats.

Step 3: Check the permissions of configuration files

Step 4: Encrypt client-server transmissions

Step 5: Disable remote access

Step 6: Actively monitor the MySQL access log

Security Tools

like image 30
Joseph David Avatar answered Oct 05 '22 22:10

Joseph David