Worst Practices - Encrypting Data

  • Comments posted to this topic are about the content posted at http://www.sqlservercentral.com/columnists/sjones/wp_encryption.asp

  • At my last place of employment we were an 'Oracle house' - and simply used the built-in oracle Function TRANSLATE to store passwords. This wasn't for any real encryption reasons but more so people could not look at a DBA's or developer's screen and see a password (or list of passwords).

    Translate is used with a character string which simply replaces a character with another such as[SELECT user_id ... FROM table a WHERE a.user_id = @userid AND a.password = Translate(@password,'pONmlkjihgfeDCBA','abcdefghijklmnop')]

    Translate can, of course, must used in reverse order to store the password. Storing the password retrieval and update sql in stored procedures kept the integrity current.

    Finally.. my question...

    Are there any such built-in functions for SQL Server 2000? Or, could a user-defined function be built into SQL server itself - or perhaps in a stored procedure? What is your suggestion?

    Thanks

    Shaun

  • No reason you couldnt create a user defined function to do the work. Should be fine to discourage casual snooping, just dont rely on it for anything more!

    We've got an ongoing discussion about Oracle vs SQL in one of our discussion areas - maybe you could share your thoughts?

    Andy

  • This isn't really encryption. More obfuscation which is a really low level security item.

    As Andy said, it's just for casual snooping.

    Steve Jones

    steve@dkranch.net

  • In oracle there are built in obfuscation routines so no need to code your own 🙂

    Anyhow, I agree that encrypting data in the DB is not the best practice in the world. More time should be spend on

    a) underlying roles and access to the DB

    b) DB and backup file encryption

    c) securing the server and associated sql*server service users

    d) encrypting t-sql code

    e) auditing

    the trick is always credit-card id's etc. you need to carefully analyse your routines that check and report on such data. Perhaps consider views with instead of triggers etc..

    The cost of writing encryption logic into a app to crypt data that can be cracked with simple routines is tough to justify.


    Chris Kempster
    www.chriskempster.com
    Author of "SQL Server Backup, Recovery & Troubleshooting"
    Author of "SQL Server 2k for the Oracle DBA"

  • Does Oracle have encryption/ decryption routines? How does it manage keys?

    I think the db is a good place for encrypted data, but it is extremely difficult to manage. Plus, to be secure , it has to be encrypted when it crosses the wire.

    I just with there was a way to lock out sa's. there are places where this is a good idea.

    Steve Jones

    steve@dkranch.net

  • Steve

    http://download-west.oracle.com/otndoc/oracle9i/901_doc/appdev.901/a88876/adgsec04.htm

    basically pl-sql stored procedure routines, ie:

    dbms_obfuscation_toolkit.DESDecrypt(input_string => encrypted_string,

    key => raw_key, decrypted_string => decrypted_string);

    for example.

    Includes:

    a) Data Encryption Standard (DES) algorithm

    b) encrypt and decrypt using 2-key and 3-key DES

    c) require keylengths of 128 and 192 bits, respectively

    d) DES algorithm itself has an effective key length of 56-bits


    Chris Kempster
    www.chriskempster.com
    Author of "SQL Server Backup, Recovery & Troubleshooting"
    Author of "SQL Server 2k for the Oracle DBA"

  • Interesting, but this still doesn't solve the key issue. Transmitting the key along with the data defeats the purpose to some extent. Any tool like profiler or a network sniffer would render this useless.

    Steve Jones

    steve@dkranch.net

  • These are valid points. Enhanced security will always have a price, and in the Database world, that equals response time. If security is that important to your organization then I would approach it like most other problems, do everything you can to tighten up the code then make up for the rest by scaling up. In this case since Disk IO is the potential bottleneck, I would consider implementing a Solid State SAN. There is no seek time to speak of and the randow reads are the same as sequential reads. As far as transmitting the data, SSL on ASP pages does pretty well, again performance is just a matter of how much you want to spend.

  • I agree with your points. I'd consider encyption for non-key fields, like salary. However, I'd want to place the key management in someone else's hands. After all if I hold the keys, why bother encrypting?

    Steve Jones

    steve@dkranch.net

  • Steve,

    I agree with the general scope of your argument but one area where I have used encryption in the past is for credit card numbers. We developed a bespoke VB/SQL system for a retail client which holds over a hundred thousand credit card numbers. I am not too happy about leaving those in clear type, especially as the user (who is also the DBA) is not especially technically competent and we can't rely on them maintaining tight database security. As a solution we implemented a client side encryption/decryption routine; it may not be proof against a security expert but should be okay otherwise.

    What are your thoughts on this? This is a similar situation to the salary issues noted earlier. ie a small, discrete item of data that is not subject to sorting, filtering, searching, etc. The alternative of leaving this data unencrypted would worry me!

    Also should not decryption be done at the client rather than on the server? If data is decrypted on the server then anyone with a packet sniffer can just read the now unencrypted data, which rather defeats the point.

    Keep up the good work! 

    Regards

    David Saville

    dps@aldex.co.uk

    http://www.aldex.co.uk

     

  • In the section "So why encrypt?" you seem to have forgotten about those institutions that are required by law to encrypt, if not all, at least part of their data. (i.e. Sarbane/Oxley requires that TAXIDS, etc be encrypted or made 'unreadable'). Does anyone have a suggestion of how to comply with this law using a method better, more secure, faster, easier to implement and maintain than to just to "encrypt" the required columns, fields, etc?

     

Viewing 12 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic. Login to reply