3

Imagine you have a master key to encrypt/decrypt the data saved in your database of your app service. What is the risk of having this key embedded in your app service code to store this key in the app server binary files? Can hackers get this key from the binary of your app server?

If not, what is the best way to protect this master key if you are running in the cloud?

The language used is C.

1
  • 1
    Is the Binary publicly distributed? Your term 'app server' is confusing.
    – techno
    May 7, 2014 at 12:47

2 Answers 2

6

Hackers could obtain this key when they obtain access to the server binary.

When there is no reason why the users would need legitimate access to the server binary files (which should be the case when they interact with the server via network), it should be possible to harden the server sufficiently to make access impossible.

But keep in mind that when you hardcode a secret key in your application, anyone who has access to the sourcecode can leak the key to a 3rd party - intentionally or accidently. For that reason it would be much smarter to read the key from a configuration file. That way the development team can work with their own development-key, while the production server uses a different key which is only available to the sysadmin which deploys and maintains the server in production.

Another thing which could bite you is using C for a security-relevant server application. I don't want to start a programming language flamewar, but the C programming language is known for certain features which trade security for performance and easily lead to vulnerabilities like buffer overflows which allow arbitrary memory access or even code execution. A careless bug in a completely unrelated part of your netcode could easily allow an attacker to extract the memory which stores your key (no matter if it's hard-coded or read from a config file). But when you insist on writing an application which is security-relevant in C, at least be careful with certain functions like memcpy, strcpy, sprintf and several others which deal with arrays and don't do automatic bound-checking (which, how and why is enough stuff for another question).

2

It shouldn't be any worse than storing it in a configuration file on the server. Unfortunately, if someone gets control of your server it isn't going to be too complicated for them to find the keys in either case, but there isn't any particular reason that embedding it in the program should hurt your security compared to using a config file stored elsewhere on the server. It just doesn't gain anything either.

You must log in to answer this question.

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