This isn't really language specific, but I'm wondering if anyone has any suggestions for a security model securely storing some user details in a way that could be accessed in an automated fashion.

i.e. I want to be able to send users automated emails when certain events happen but I don't want to store that email address or the event description in plain text.

If it wasn't an automated system then I would use some of the users credentials to salt the encryption but as it is, the application needs to be able to access it in some way but not an "intruder".

A solution can involve a second server instance (or separate physical server) but I still see myself presented with the same problems.

  • What programming language/platform are you targeting?
    – Rowland Shaw
    Jan 26, 2014 at 17:25
  • MY language of choice would probably be python, but could easily be perl or php.
    – t0mmyt
    Jan 26, 2014 at 17:28
  • So the server needs to be able to decrypt it, but not anyone starting some application on that server? I see your trouble there. You could make it hard, but if the intruder has access to raw memory...
    – Wrikken
    Jan 30, 2014 at 19:42
  • I think if the intruder had access to raw memory then it's too late! I'm more worried about somebody running arbitrary code through an exploit though a non-root user so in that case memory shouldn't be a problem. I guess the best I can do is keep the decryption key in a root owned 0600 file and pass the value to the script that started the server process. The only process that should be listening for anything as root would bee sshd and if that gets exploited (again) then we're all screwed.
    – t0mmyt
    Feb 3, 2014 at 16:41

2 Answers 2


To make a system like this work you're going to need to either store the users e-mail in plain text somewhere, or store it in encrypted format and then store the key for that in plain text somewhere.

It's inescapable that in an automated system sometimes somewhere the server has to be able to decrypt the data and send it.

If you're interested in "high security" options, you could look at storing the users information in encrypted format on disk and then make use of an HSM to handle the decryption in a more secure manner than just having the key on disk.


The preferable model is that all the users have a public (and private) key pair. The automation server has the public key for each user and encrypts a message with the user's public key. When the user receives the message, they decrypt it with their private key.

However, no one has been able to force their users to have public keys.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .