Living the "Least Privilege" Lifestyle: Don't Run Every Day Logged In as an Administrator
- What's the Problem with Running as an Administrator?
- The Almighty Administrator
- What's Next?
I recently spoke at several software developer user groups around the country and made this assertion, representing it as one of the fundamental truths of computing today: The fact that most people run with administrative rights on their local machine is the root cause of many or most of today's security problems.
The corollary is that if most operating systems made it easier to run as a mere user without local administrative rights, the computing world would be a safer place. This is called running with a least privilege user account. Least privilege is one of the first principles of any kind of security: A user should have the permissions required to do his or her job, and not a single permission more.
But what does least privilege really mean? How do you do it? Why is it so critical? In this and following articles I'll explore these topics:
- Why running as a member of the administrators group every day has facilitated many recent worms, viruses, etc.
- Why running without administrative privileges is safer
- How to survive daily computer use as a mere user (including lots of tools and tricks)
- Why it's impossible to develop secure software when running as an administrator
- How to survive development work as a mere user (with a focus on Visual Studio .NET development)
Many users, particularly those of us who are reasonably technical, run with administrative rights on the local machine because it's easier that way. You can always install software, make a quick tweak to the operating system, solve security exceptions thrown by older applications, run disk defragmentation utilities and other tools that keep the system healthy. Mere users—those without administrative privileges on the local machine—either have to get someone from the help desk to perform such tasks, or meticulously log off and log back on using an account with administrative privileges to perform the privileged task, and then log off and back on as a mere user. The latter option gets old fast, but there are better ways to survive running as a least privilege user, and I'll cover them in this series of articles.
No matter how technically savvy you may be, there's no way to keep spyware, viruses, worms, and other nasties from running and taking over your machine. This is why I and others have worked to spread the least privilege message. Until operating systems force users to live with lesser privileges—and make it easier to do so—we all need to make the small extra effort. It's not as painful as you might think, but it does require learning a bit about how security works and the tools available in the operating system or from third parties.
I run Windows and am a Windows application developer, so I'll focus on Windows for these articles. The basic concepts apply to any operating system, but there are variations in the tools and techniques you'll need to use for living the least privilege lifestyle and developing apps that mere users can run.
What's the Problem with Running as an Administrator?
From a developer's standpoint, there are two reasons not to run as an administrator on your development machine:
- Your machine is more susceptible to attack by malware.
- It's impossible to write secure code.
I realize that these are strong assertions, but I've discovered the hard way that they're painfully true.
The reason that your computer is more susceptible to attacks is that malware launched from a process with your security token by default inherits that token. That's why if you run as an administrator, fire up Microsoft Outlook, open an email message, and double-click the attachment, the evil.exe file that runs has full administrative rights on the local machine. That code owns your machine, without any need to implement any tricky code to gain control of the machine. And if you're running as a domain administrator, the code owns the network.
Simply put, most recent malware attacks would not have been as serious had most people been running as a least privilege user. At the very least, malware would have spread far more slowly with fewer damaging effects. But with admin privileges, malware can read and write to any location on the hard drive and Windows registry (with very few exceptions), inserting any kind of nasty code. You've probably heard of the legions of zombies used by spammers and distributed denial-of-service attacks to spread their damage. These zombies are machines that have been so thoroughly compromised that attackers can use them at will as a free platform from which to spew spam or pummel a target. And the owners of those compromised computers are often blissfully ignorant of their contribution to spam and computer attacks.
The other major problem with running with administrative privileges is that it's impossible to write secure code. This is because it's far too easy to build insecure assumptions into your code that lead to security problems. Here's a simple example of how this problem occurs. Say that in the early stage of a project you write some low-level code that saves user configuration information to a file in the application directory. (Mere users don't have write permission to the c:\Program Files directory in Windows because such a permission would allow malware to insert code into an EXE or DLL file and save the hacked file to its original location.) Because you're running with administrative privileges, the code runs fine locally without causing any kind of security exception. As the project progresses, layer upon layer of code, all the way up to the user interface, expects the configuration information to be saved to that specific location, perhaps because it reads the information from that location. Over the life of the project maybe hundreds of components grow to depend on that flawed behavior. By the time you're ready to deploy, the problem has grown into a major flaw that would take hundreds of person-hours to fix.
When describing this problem in user groups, someone inevitably protests, "But we test under a least privilege account, so we'll find the problem and fix it!" Ah, yes, the argument that testing finds all flaws—how we developers just love the testing staff. The problem is that this level of testing inevitably happens only late in the project, when the security flaw is so insidious as to be impossible to fix. Because these kinds of security flaws tend to be rooted in low-level code, the behavior has likely proliferated throughout the application. Besides, you'd have to thoroughly test every possible path through the code with differing levels of permissions to completely root out the problem. Such detailed testing is very difficult and few shops tests apps that thoroughly.
This example of writing to the application directory is one of the simplest such security flaws. Throw in a few more insidious and subtle security bugs and there's no way your app will ship on time. Unless, of course, you deploy the app and require every user to have admin privileges, thus perpetuating the myth that users need local administrative rights to run desktop software. This has been the cycle for years now. It's time to break that cycle and create secure computing environments.