SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,606
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)

    Securing database data

    I was going to start working on a new project that includes storing some basic customer information, but would like to put some measures in place to increase security a little bit.

    Would an appropriate approach be to use the MySQL functions AES_ENCRYPT() and AES_DECRYPT() for encrypting field data?

    http://thinkdiff.net/mysql/encrypt-m...es-techniques/
    http://i.amniels.com/mysql-database-...c-private-keys

    I realize there will be a performance hit when encrypting/decrypting, but if it causes a delay of couple seconds seconds, I would consider it reasonable.

    If this is the appropriate approach, how would I then go about performing searches on those encrypted fields?
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain

  2. #2
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,182
    Mentioned
    66 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by Force Flow View Post
    I was going to start working on a new project that includes storing some basic customer information, but would like to put some measures in place to increase security a little bit.

    Would an appropriate approach be to use the MySQL functions AES_ENCRYPT() and AES_DECRYPT() for encrypting field data?

    http://thinkdiff.net/mysql/encrypt-m...es-techniques/
    http://i.amniels.com/mysql-database-...c-private-keys

    I realize there will be a performance hit when encrypting/decrypting, but if it causes a delay of couple seconds seconds, I would consider it reasonable.

    If this is the appropriate approach, how would I then go about performing searches on those encrypted fields?
    May I ask what type of data we are discussing? Keep in mind that if I were clever enough to retrieve your data, I'm going to be clever enough to think to give AES_DECRYPT a try on it along with some others when it looks obscured, run salt with it, probably in this case both a static AND dynamic salt (stored on each record of the table)

  3. #3
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,606
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by K. Wolfe View Post
    May I ask what type of data we are discussing?
    Names and contact information.

    Keep in mind that if I were clever enough to retrieve your data, I'm going to be clever enough to think to give AES_DECRYPT a try on it along with some others when it looks obscured, run salt with it, probably in this case both a static AND dynamic salt (stored on each record of the table)
    True, but I wouldn't think it would be a completely fruitless exercise. It still would be another layer of security that would have to be broken.

    Just because thieves can break into locked cars doesn't mean you should leave it unlocked.
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain

  4. #4
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,182
    Mentioned
    66 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by Force Flow View Post
    Names and contact information.


    True, but I wouldn't think it would be a completely fruitless exercise. It still would be another layer of security that would have to be broken.

    Just because thieves can break into locked cars doesn't mean you should leave it unlocked.
    Very true...

    For this exercise, it's a little backward from password strengthening. You'll want your salting on the scripting side, stored on the filesystem, but I'd run a second salt on the db.

    Keep in mind that any query you run against this will have to be run through the function you create to obscure it, and will throw any indexing you have out the window. I'd try to focus more on a security system / mechanisms to keep them out of your car rather than securing your glove box that you commonly need access to.

  5. #5
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,606
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by K. Wolfe View Post
    Very true...

    For this exercise, it's a little backward from password strengthening. You'll want your salting on the scripting side, stored on the filesystem, but I'd run a second salt on the db.

    Keep in mind that any query you run against this will have to be run through the function you create to obscure it, and will throw any indexing you have out the window. I'd try to focus more on a security system / mechanisms to keep them out of your car rather than securing your glove box that you commonly need access to.
    Good analogy

    I take all the usual precautions with securing an application and database. I'm just wary of leaving all that data as viewable plain text in the database just in case someone happens to slip past the front gates.
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain

  6. #6
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,633
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    The big question here is key security -- if someone can slip past the front-end and get into the raw db they can probably get at your key as well if it is handy enough to be decrypting data on the fly.

  7. #7
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,606
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)
    Besides denying access with htaccess and placing it outside of the web directory, what else can you do with the key?
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain

  8. #8
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,633
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Good question -- that is a bit beyond my linux chops. I'd look for a secure storage mechanisim like keychain, I suspect something exists. If the key is a file on disk then it is easily compromisable if the box is compromised.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •