One of my software (an R package) has to save on disk users sensitive information.

I encrypt such information using AES encryption using a random key that is generated at the moment of installation (which is saved in the same directory where I store the user profile).

I am trying to find a way to obfuscate the key and avoid other users on the same machine to access the other users key (the key are of course have read permissions only for the users who created the, but super users can use the key and read other profiles).

I would like to know:

  1. is it really necessary worrying about superusers? My gut feeling says no: in princible whathever the encryption method a superuser can read all the files and ultimately any kind of keys of the users;

  2. is ther a better way store a user profile other than encrypting it using AES or any other method?

  • Do these users have to input any password to authenticate themselves? If yes, then you may want to derive the encryption key from user's passwords. Otherwise it would merely get close to DRM systems. – WhiteWinterWolf Apr 18 '15 at 8:37
  • they insert the password to some db at the moment of installation and that's it.. but the idea is that I don want them to type it every time... – lucacerone Apr 18 '15 at 8:47
  • Then do not hesitate to click on the link in my previous message. It will lead you to discussions on this site related to DRM implementation (first how to encrypt data so users cannot easily decrypt them, itself marked as duplicate of another question about how effective such a system would be). Basically there will recommendation to estimate how complex you need your system to be, but there will be no definitive answer since there is no definitive solution. I wish you a good reading :) – WhiteWinterWolf Apr 18 '15 at 8:55
  • @GBZK thanks a lot, I'll definitively look at it :) – lucacerone Apr 18 '15 at 8:59

is it really necessary worrying about superusers? My gut feeling says no: in princible whathever the encryption method a superuser can read all the files and ultimately any kind of keys of the users;

Kind of. Even if the file is encrypted and the decryption is only done within the process the superuser has on most systems access to the process memory and can thus extract the decrypted data from there. Of course it takes way more knowledge to do that instead of just reading the plain file.

is there a better way store a user profile other than encrypting it using AES or any other method?

That's not an easy question and depends a lot on the environment you work in, how you trust your users, how the overall security is, how sensitive the data are and maybe also a corporate policy or similar restrictions. If you don't trust the superuser or fear a system compromise then simply don't store and handle any sensitive data on the system. If users can be tricked into executing code on the system then it will not help if the files are encrypted but can be decrypted without user interaction...

In short: there is no general answer. There is no 100% security and you have to evaluate the risks in your environment and which risks are acceptable. Based on this you can then go the cheap high-risk way or the costly low-risk way or something in between. In some cases "better" means easier usability at the cost of a higher risk, in other cases "better" is low risk even if it causes usability problems and other costs. Having the key together with the encrypted data is definitely high risk which might be lowered but not eliminated by obfuscation of the key and anti-debugging features in the decryption software.

  • Thanks Steffen, but I wonder how other softwares who store password (think of browser, database client and so on, do?) Don't they all rely on a key being stored together with the software and the data? I ask because this is the kind of usability I would like to get. As for the superuser I trust them, that is why I wonder if it is a real concern: in the end if an external attacker can read the key file he either has already broken into my account or gained superuser/root access to the machine, so the damage would be done in any case... – lucacerone Apr 18 '15 at 8:52
  • @lucacerone They don't store the password on client-side, you can't give someone the lock and the key and hope to stay secure – Freedo Apr 18 '15 at 9:02
  • @freedom as a concrete case take the mysql workbench.. when I save my credentials, aren't they saved in my computer? – lucacerone Apr 18 '15 at 9:05
  • @lucacerone: software handles this different. Firefox has some idea of a master password the user has to enter while Chrome simply stores the data in plain, i.e. expects the system to handle the security. Other software obfuscates, often in a way which can be easily broken. But don't rely only on what others do: again, it depends on your environment and on the risk you can accept. – Steffen Ullrich Apr 18 '15 at 9:08

I'm not a programmer but i think that if you don't want people having access to your code then you need to make it server-side, code executed in the client side, must be available not-encrypted on the client side at some point.

This is exactly like DRM: you're giving the user a lock, and also the key to it, and expecting to be able to say what they can do with it.

It's theoretically impossible: if their computer can execute the code, it has to be decrypted there. And if its decrypted AND available to the user then really you should not spend time trying to develop a way to stop people to read it or copy it or do anything...just look how successful Hollywood and games companies are, they get cracked in days or weeks if it worth the time and the effort then people will.

Move the logic to server-side if you want that, you didn't say what your program exactly do so i can't give you ideas, but maybe you never store the user profile on the device but on your server? Hard to tell without knowing what you want this user profile to do, but you got it.

Also security by obscurity mostly never works, you can obfuscate your code the hardest you can but this will only stop the less determined people like i said if they want it badly enough they will overcome this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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