1

I have a Windows service that accesses a database connection. Since users rarely use Windows authentication, I encrypt the connection string. For development I have the password hard-coded, but I know this is a very bad idea. What is the proper way to store a non-user entered password?

As a side note, I tried storing the password in the Credentials Manager, but this required the service to be run under either the local system account or an administrator account, which some clients do not want to allow.

Edit

The main question here is this: What is the best way for a Windows service to store sensitive information?

8
  • Why do users need to connect to the database directly?
    – MechMK1
    Jun 4 '21 at 18:27
  • Users are not connecting to the database. The Windows service receives TCP messages and adds the information to the database, where they are consumed by another program.
    – Tim
    Jun 4 '21 at 19:50
  • Whether or not a user or a windows service connects directly to the database is irrelevant - the question is why there has to be a direct connection and not through, say, a service.
    – MechMK1
    Jun 5 '21 at 10:21
  • I'm sorry, I'm confused. It seems like this is moving the goalpost. If my service uses another service to access the database, then I would need to store a password to access that service and that service would need to store a database password.
    – Tim
    Jun 7 '21 at 13:04
  • Yes, but it makes a difference whether the database password is stored on the local machine (accessed by a Windows Service) or on a remote server, which offers an API to all local machines. In one scenario, an attacker simply needs access to the machine of any user to access the database directly, whereas in the other, the attacker needs to take over a specific server.
    – MechMK1
    Jun 8 '21 at 12:50

Your Answer

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

Browse other questions tagged or ask your own question.