Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why running a service as Local System is bad on windows?

I am trying to find out the difference between difference service account types. I tumbled upon this question.

The answer was because it has powerful access to local resources, and Network Service should be used if possible.

But still I am not able to understand that if it has powerful access to local resources, how attacker can access the account? What are the ways to compromise the account? I understood it is all about security, but I don't know how. It could be dark hacker's world, however anybody could explain, in simple terms, why network service account is better than local account ?

Thanks in advance.

like image 738
pointlesspolitics Avatar asked Nov 13 '09 16:11

pointlesspolitics


People also ask

What is local service in Windows?

The LOCAL SERVICE account is a predefined local account used by the service control manager. It has minimum privileges on the local computer and presents anonymous credentials on the network. For more information, see LocalService Account.

What is the difference between local system and network service?

The built-in Network Service user account has fewer access privileges on the system than the Local System user account; it is part of the Users group but the Network Service user account is still able to interact throughout the network with the credentials of the computer account.

What is local system service?

The LocalSystem account is a predefined local account used by the service control manager. This account is not recognized by the security subsystem, so you cannot specify its name in a call to the LookupAccountName function. It has extensive privileges on the local computer, and acts as the computer on the network.

What does local system account mean?

A local system account is a user account that is created by an operating system during installation and that is used for operating system-defined purposes. System accounts often have pre-defined user IDs (e.g. the root account in Linux.) The distinction between system accounts and service accounts is sometimes blurred.


3 Answers

Every program you run increases the attack surface of your server.

You have to assume that a determined, malicious actor can exploit bugs or loopholes in your program to make it do anything. You mitigate that by executing your programs with the least privileges required to do their jobs.

Some of these exploits include:

  • Luring attacks, in which an attacker tricks your program into executing their code under the program's elevated privileges.

  • Buffer Overrun Attacks, in which extra data sent to a method is written into adjacent memory, which may be the target of control flow logic.

  • Man in the Middle attacks, where an attacker falsifies messages to your program.

Often, a given service isn't obviously vulnerable to any of these. Running under network service (or another account with reduced permissions) is a 'better safe than sorry' strategy that acknowledges two important facts of software development: programmers are fallible and attackers are inventive.

like image 166
Jeff Sternal Avatar answered Oct 13 '22 03:10

Jeff Sternal


The LocalSystem account is the Windows equivilant of the *nix root account. It's even more privileged than an administrator account. When you run as LocalSystem, you have full access to every resource on the machine.

As others have written, you should write your code to run with the least possible privileges.

The primary difference between LocalService and NetworkService is that services running as NetworkService have the ability to authenticate to other machines in the domain (as the machine account I believe).

Please note that the LocalService and NetworkService accounts both have the "Impersonate" privilege which is a potentially dangerous privilege - it allows the service to impersonate the user who is calling into the service. If that user is an administrator, then even though your code is running in a low privileged service, it can do anything that the administrator does. If an attacker can exploit a buffer overflow in your least privilege service, they can hook out the APIs you use to impersonate your caller and wait until a high privileged caller calls into your service. This technique is known as "Token Kidnapping" and the MSRC has a great blog post describing the issue (and contains links that describe how to mitigate many of the other risks associated with using LocalService and NetworkService accounts).

like image 25
ReinstateMonica Larry Osterman Avatar answered Oct 13 '22 04:10

ReinstateMonica Larry Osterman


The Local account has effectively full administrative priviledges on the local machine. Hence any code that might escape from say a buffer overrun and get itself executing has significant scope to do damage.

On the other hand, the Network Service account has by default only Guest level access to the local system. Hence even if an attacker managed to find way to send and execute code within the service that code would have limited access.

like image 36
AnthonyWJones Avatar answered Oct 13 '22 03:10

AnthonyWJones