Search code examples
c++securitywinapiwindows-servicesdacl

Create file that can be opened only by a Windows Service


Is it possible to select such a security descriptor using a DACL string such that the file can only be opened by a Windows Service, but not by an ordinary process, even if the process is run by the local Administrator account?

To clarify, I just need to make it reasonably hard for a non-technical user to open it in NotePad and tamper with it. It doesn't need to work against a programmer willing to dedicate a month of his life to reverse engineering and cracking it.

I prefer to achieve this using DACL instead of locking the file because then my windows service doesn't need to run all the time for the file to be protected.


Solution

  • Local administrator account = God (at least on the box). There's no way to do this.

    You can define a special privileged account for your service to run under, and make the ACLs on the protected file only allow access by that user (and all machine admins). You can disallow interactive login using that service account.

    If your primary concern is tampering by interactive users, you may need a policy whereby the local user does not run by default with local admin rights. Unfortunately you cannot allow 'partial' local admin rights - it's all or nothing.