0

I’m developing an application that will run on a private, on premises network. The application will be accepting requests through an API, read some encrypted data from the disk, decrypt them, do some processing on them and return the result.

Both the data and the key have to be stored on the same device somehow, since an internet connection is not always guaranteed.

I understand that it’s impossible to hide the key from someone who has access to the machine, but I’m looking for a way to make it reasonably difficult for someone with access to the machine to get their hands on my data.

Where and how can I store the key to make it difficult for a user with local admin access to decrypt the data? If this is not possible, how can I make it difficult for other users to decrypt my data?

The application is written in .NET, but I’m open to any solutions that would help to secure my data. It will run on both Windows 7 and Windows 10.

2
  • do you require that in the case of a program restart, it starts without any human input?
    – user284677
    Nov 20, 2022 at 12:15
  • Yes, that is a requirement
    – Q-bertsuit
    Nov 20, 2022 at 12:35

1 Answer 1

1

According to Kerckhoff's principle, the security of a crypto-system should be based solely on the key; i.e. as long as an adversary does not know the key, the system should be secure (given that the system is not vulnerable in any other way, e.g. breakable maths or flawed implementation).

By your requirements, you allow the key to be accessible to the adversary which, in principle, makes your system unconditionally breakable.

So, the question is how difficult can we make it for an adversary to locate the key.

For unprivileged accounts, proper permission configuration should suffice in order to disallow unauthorized access to the key (i.e. the program would run as a user which will have exclusive access to the key and data).

For privileged accounts, though, disallowing access to the key is practically impossible; an administrator is usually not constrained by filesystem permissions and can access any part of it at will (at least for an unhardened OS). A common counter-measure is to use a password pepper, provided by direct user input (keyboard) or a network peer (API request). However, (a) you don't want interruptions during the program's booting process (so this solution is not for you) and (b) even this approach cannot withstand key extraction from memory dumps (examples here and, for a more in-depth analysis, here).

5
  • Fantastic answer, thank you very much! I have a couple of follow up questions. Does this mean that for unprivileged accounts, I can store the key in clear text in a file as long as the correct permissions have been set? For privileged accounts, what can I do to make it a bit more difficult for the adversary than to just hard code the key in my app?
    – Q-bertsuit
    Nov 20, 2022 at 15:17
  • 1
    In principle, yes, you could store the key unencrypted, however there are too many ways to bypass access permissions that I wouldn't recommend depending your whole defense in a single measure. For the privileged accounts, off the top of my head, you could split the key and store the parts in different locations so that finding it is not an one-off step. However, I really don't have a good suggestion because you can obfuscate your key as much as you want but in the end of the day a determined adversary with physical access to your server will be able to find it.
    – user284677
    Nov 20, 2022 at 15:36
  • So even if split the key and store it in different locations, an unprivileged user could still get access to it if he was determined?
    – Q-bertsuit
    Nov 20, 2022 at 15:59
  • 1
    A determined unprivileged user may find a way to escalate her privileges and then retrieve the key. If you assume that privilege escalation is not an issue, nor is bypassing restrictions through permission misconfiguration, then it is safe to assume that unprivileged accounts are not a threat to your setup (although you should be really cautious when it comes to assumptions). Once an entity is in the position to find the key, the split is just a way to make finding it a bit more involved, but it's not a serious defense mechanism
    – user284677
    Nov 20, 2022 at 16:15
  • thanks again, really appreciate your time and input
    – Q-bertsuit
    Nov 20, 2022 at 16:21

You must log in to answer this question.

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