Take the 2-minute tour ×
Information Security Stack Exchange is a question and answer site for Information security professionals. It's 100% free, no registration required.

I'm developing a web application with a database backend using Django that will be accessed from the Internet. The database will contain sensitive information and I'd like some advice on the approach I should use to secure the data.

Approach 1: Encrypt the information using RSA-2048 bit encryption using the public key on the Internet facing server. Then on a separate server (not internet facing) have another web application to decrypt the data using the private key.

Approach 2: Encrypt the information using AES-256 bit encryption with a single encryption/decryption key on the Internet facing server.

Which approach is securer and more efficient?

The issue I see with approach 1 is that although it's a belt and braces approach the data that is submitted via the web application can't be modified by the end user once it's been encrypted. And the issue I see with approach 2 is that since the encryption/decryption key is on a single server, if the web application was compromised so would the data.

I'd appreciate your advice.

Thanks in advance.

share|improve this question
    
Do I understand right that we are only speaking about database encryption, not about transport encryption? –  Paŭlo Ebermann Oct 12 '11 at 20:49
    
@PaŭloEbermann Yes that's correct, I'm only referring to database encryption. –  Imran Azad Oct 12 '11 at 21:37

1 Answer 1

About efficiency: symmetric encryption (like AES) of comparable security level will always be faster than asymmetric one (like RSA).

Because of this (and since RSA needs some random padding to be secure, meaning the ciphertext is a bit larger than the plaintext), the usual way to use RSA (if you have to encrypt more than about the key size) is to generate a random key for a symmetric algorithm, encrypt that key with RSA, encrypt the plaintext with this random key, and store the encrypted key together with the plaintext.

So, your selection is actually between:

  • RSA (with public + private key) together with AES (or some other algorithm, but let's stay simple)
  • only AES (with a secret key)

The actual cryptography here is not a point where an attacker will get any advantage - both AES and RSA (with the given key size) are secure enough to resist brute-force attacks.

If you are using only symmetric encryption, of course the encrypting server needs this key, and if compromised, this key can be used to decrypt the data in the database. There is not really a way around this.

If you are using asymmetric encryption, your encrypting server could have only the public key – but this is only a viable option if this webapp server never needs to decrypt the data again, i.e. for write-only data. Do you really have such data? (It can be modified after submitting, but only by overwriting it, not by first reading it, changing and writing back.)

Also, since this is using a public key for encrypting, there is nothing hindering an attacker with database access from changing the data to something else. If an attacker somehow gets access to the database (he shouldn't, of course), it is not that complicated to derive the public key from the encrypted data. Having that, the attacker can simply insert new records into the database, or overwrite old ones, and your decrypting process (with the private key) has no chance to see the difference. To avoid this, have the writing process also sign the data (with the private key of a different key pair), where the reading process can verify these signatures.

You can have a second server to decrypt it for the first one on demand, but this will not be much safer than having the first one do it itself (only that you can simply cut it off when you remark the attacker's presence).

So, to completely estimate your security, it is necessary to first have an attack model (i.e. against which attacks do you want to be sure), then you can judge which variant protects better.

I want to be sure the Internet facing server doesn't get attacked.

The encryption of the database by itself does not open (or close) any attack route on the web server, either way. They are only different if some attacker finds another security hole in your web application, and gets access to the web server.

share|improve this answer
    
Firstly, thank you for the thorough and succinct answer, really appreciate it. In response to your question with regard to the 'attack model', I want to be sure the Internet facing server doesn't get attacked. Also when you say that nothing hinders an attacker changing the data to something else because of the use of a public key - I'm sorry I don't understand this, could you elaborate please? Thanks –  Imran Azad Oct 13 '11 at 0:01
    
I added some details about "changing the data", and your attack scenario. (I'm not really a security expert, so maybe someone else can still answer about which attack scenarios might be relevant here.) –  Paŭlo Ebermann Oct 13 '11 at 13:10
    
I really appreciate all the help, many thanks. –  Imran Azad Oct 13 '11 at 14:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.