Tools and Techniques for Solving Least Privilege Security Problems

Exclusive offer: get 50% off this eBook here
Least Privilege Security for Windows 7, Vista and XP

Least Privilege Security for Windows 7, Vista and XP — Save 50%

Secure Microsoft Windows desktops with least privilege security for regulatory compliance and business agility with this security book and eBook for Windows 7, Vista and XP

$35.99    $18.00
by Russell Smith | July 2010 | Enterprise Articles Microsoft

There may be situations where you need to support standard users and have no choice but to temporarily grant administrative privileges. This article by Russell Smith, author of Least Privilege Security for Windows 7, Vista and XP, includes information about tools and techniques that can be used to solve Least Privilege Security problems.

In this article we'll learn to:

  • Set up a system for temporarily granting administrative privileges to standard users for support purposes
  • Use Task Scheduler to run common processes without the need to elevate privileges

(For more resources on Microsoft products, see here.)

Granting temporary administrative privileges

One of the primary concerns for system administrators when implementing Least Privilege Security on notebook computers is how to solve problems that require administrative access if a remote connection cannot be established. Consider a scenario where a user arrives at a conference center but can't connect their notebook to the local network because there isn't a DHCP server available. The only way to make a successful connection is to manually configure an IP address.

While we could add users to the Network Configuration Operators group on each notebook so that they can configure local network settings, the requirement to manually configure network options is rare and granting this access is likely to create more support problems than it solves. If you've ever worked on a help desk, you'll know that a high percentage of calls from mobile workers are related to network connection problems, often caused by a misconfiguration.

Windows doesn't have any built-in mechanism that allows system administrators to temporarily grant administrative privileges, leaving IT nervous to commit to Least Privilege on notebook computers. In this section, we'll look at a couple of simple techniques that can be used to grant temporary administrative access to mobile users when all else fails. Neither method is perfect, and could potentially be hijacked by savvy users to install unsanctioned software or grant themselves permanent administrative access, but there must be a back door for system administrators to ensure confidence in the ability to provide support in any situation.

The instructions that follow use local user accounts and local policy settings, but are intended for use in a domain environment. If you wish to manage the accounts and policy settings centrally, domain users and domain-based Group Policy Objects can be used as an alternative. The following techniques shouldn't be used in high security environments.

Granting temporary administrative access using a separate logon (Vista and Windows 7 only)

For each notebook in our organization, we need to create a set of accounts that have administrative access. Let's create three accounts on each notebook—Support1, Support2, and Support 3.

Creating three support accounts

You can do this easily from the command prompt or by adding the appropriate commands to a batch file. Log on to the notebook as an administrator and run the following two commands from the command prompt:

net user Support1 ******** /expires:never /passwordchg:no /ADD
net localgroup Administrators Support1 /ADD

Replace ******** with a random password for each account. The passwords for each support account must be recorded somewhere for future reference. The password for each account should be completely random and differ on every notebook.

Creating a policy setting to automatically delete the support account at logoff

To ensure that the support account is deleted at log off, we need to create a local policy setting for each support account.

  1. Type MMC into the Search programs and files box on the Start menu and press Enter.
  2. Press Ctrl+M to add a snap-in.
  3. In the Add or Remove Snap-ins dialog box, select Group Policy Object Editor from the list on the left and click Add.
  4. In the Select Group Policy Object dialog box, click Browse.
  5. In the Browse for a Group Policy Object window, switch to the Users tab.
  6. Select Support1 in the list and click OK.
  7. In the Select Group Policy Object dialog box, the Group Policy Object will now read Local Computer\Support1. Click Finish.

    Least Privilege Security for Windows 7, Vista and XP

  8. In the Add or Remove Snap-ins dialog box, click OK.
  9. In the MMC console window, expand Local Computer\Support1 Policy, User Configuration, Windows Settings under Console Root in the left pane.
  10. Click Scripts (Logon/Logoff) under Windows Settings.

    Least Privilege Security for Windows 7, Vista and XP

  11. In the central pane, double-click Logoff.
  12. In the Logoff Properties dialog box, click Add.
  13. In the Add a Script window, type net in the Script Name field.
  14. In the Script Parameters field type user support1 /delete and click OK.
  15. Click OK in the Logoff Properties dialog box.

    Least Privilege Security for Windows 7, Vista and XP

  16. Close the MMC window.

These steps need to be repeated for each support account.

Testing the support accounts

To test the configuration, log in to Windows using the Support1 account.

  1. You'll need to click Switch User on the log on screen and then select Other User.
  2. When entering the username, specify that it's a local user account using the format COMPUTERNAME\USERNAME. In this case, the computer is called WIN7.

    Least Privilege Security for Windows 7, Vista and XP

  3. Check that Support1 has administrative access by performing a task such as changing the date or time. If Support1 has administrative privileges, UAC will not prompt for elevation.
  4. Log off Support1 and then try to log in again using the same account. This time you should be presented with The user name or password is incorrect as an error message because the Support1 account no longer exists.

 

To repeat the support procedure, the password for Support2 must be known by the user.

Putting into practice

The procedure outlined here can be used by help desk staff when a user requires a temporary administrative login for support:

Least Privilege Security for Windows 7, Vista and XP

Least Privilege Security for Windows 7, Vista and XP Secure Microsoft Windows desktops with least privilege security for regulatory compliance and business agility with this security book and eBook for Windows 7, Vista and XP
Published: July 2010
eBook Price: $35.99
Book Price: $59.99
See more
Select your format and quantity:

Granting temporary administrative access without a separate logon

Sometimes we just need to give the logged in user administrative privileges without asking them to use a different account. The following technique uses the same three support accounts created earlier, but this time instead of asking the logged in user to switch user and start a new desktop session, we'll ask them to launch a preinstalled batch file using the support user's credentials supplied by the help desk.

Creating a batch file to elevate the privileges of the logged in user

We're going to create three batch files, one for use with each of the three support user accounts. The batch files are also unique for the logged in user. As this elevation technique will generally only be used for mobile users, and notebooks tend to have only one regular user, this limitation shouldn't prove too much of a problem. This technique could be developed further to accommodate more complex requirements.

Using Notepad, save the following commands as Support1.cmd:

@echo off
net localgroup Administrators AD\user /ADD
@ping 127.0.0.1 -n 60 -w 1000 > nul
@ping 127.0.0.1 -n %1% -w 1000 > nul
net localgroup Administrators AD\user /DELETE
net user support1 /DELETE
exit

So what does the batch file do?

  1. The logged in user, in this case user@ad.contoso.com, is added to the notebook's local Administrators group.
  2. The two ping commands are used as a means of creating a timed delay in the batch file of 60 seconds. This value can be changed to meet your needs and gives user@ad.contoso.com a time-limited chance to elevate his/her account.
  3. Once the timer has stopped, user@ad.contoso.com is removed from the local Administrators group and the support1 user account is deleted to ensure the user can't repeat the procedure.

You should create three batch files, one for each support user account, modifying the commands as necessary—Support1.cmd, Support2.cmd, and Support3.cmd. The files should be saved to a trusted location on the user's notebook, for instance to a dedicated folder in C:\Program Files or C:\Windows, to help ensure that the user can't modify commands in the batch files. when they are running without administrative privileges.

Testing the procedure

Log in to a notebook with a standard user account and follow these instructions:

  1. Locate the support batch files in C:\Program Files or C:\Windows.
  2. Select Support1.cmd, right-click on the file, and select Run as administrator from the menu.
  3. User Account Control will prompt for administrative credentials. Enter the credentials for the Support1 account, remembering to use the following format: COMPUTERNAME\USERNAME.

    Least Privilege Security for Windows 7, Vista and XP

  4. A command-line window will appear. Now attempt to change the time or date. UAC will still prompt for administrative credentials, but this time user@ad.contoso.com can enter their own credentials to elevate and successfully change the date or time.
  5. After 60 seconds, the batch file will continue processing and remove user@ad.contoso.com from the local Administrators group.
  6. Try again to change the time or date; enter user@ad.contoso.com credentials into the UAC prompt and this time the request will be denied as user@ad.contoso.com has been demoted back to a standard user.

Limitations of the procedure

OK, so this seems to work well, but you may have noticed some limitations. The user could close the command-line window and prevent the batch file from completing, effectively leaving user@ad.contoso.com in the local Administrators group. While there's no simple way to prevent this, you can use Group Policy Restricted Groups to ensure that only approved accounts remain permanently in the Administrators group on each notebook.

user@ad.contoso.com could also log out and log in before the batch file completes processing, again elevating themselves to a permanent administrative status if Group Policy Restricted Groups is not configured. Ultimately, it's important to understand that even in granting a user temporary administrative privileges lies the possibility that they could change system-wide configuration to prevent Group Policy settings applying or grant themselves permanent administrative access to the PC.

Help desk procedure for granting temporary administrative access:

Least Privilege Security for Windows 7, Vista and XP

Restricting access to firecall accounts
Consider restricting the number of help desk staff who have access to usernames and passwords for firecall accounts, to limit the reporting requirements for the purposes of SOX and PCI compliance, should these credentials be abused.

Bypassing user account control for selected operations

It may be necessary for a mobile user to perform an operation that requires administrative privileges on a regular basis. A real-world example of this that I encountered was on a notebook with a faulty wireless adapter. After the notebook resumed from hibernation, it was quite common that the adapter would not work. The only solutions were to reboot the notebook, a considerable nuisance for the user, or to disable and then enable the adapter in the Network and Sharing Center, but this operation requires administrative privileges.

Using Task Scheduler to run commands with elevated privileges

To solve this problem, log in to the notebook as an administrator and create a batch file that contains the necessary commands to disable and enable the wireless adapter.

@echo off

echo --- Restarting Wireless Adapter

netsh interface set interface
name="Wireless Network Connection" admin=disabled

netsh interface set interface
name="Wireless Network Connection" admin=enabled

Save the file, wireless.bat, to a trusted location on the user's notebook; for instance to a dedicated folder in C:\Program Files or C:\Windows. In this case, I've created a folder called Support in C:\Program Files.

  1. Type Task Scheduler in the Search programs and files box on the Start menu and press Enter.
  2. In the left pane of Task Scheduler, select Task Scheduler Library.
  3. Right-click on Task Scheduler Library and select New Folder from the menu.
  4. Call the folder Support and click OK.
  5. Expand Task Scheduler Library, right-click the Support folder, and select Create Task from the menu.
  6. In the Create Task dialog box, name the task Wireless.
  7. Click Change User or Group and in the Select User or Group dialog box, type SYSTEM and click OK.

    Least Privilege Security for Windows 7, Vista and XP

  8. Switch to the Actions tab and click New.
  9. In the New Action dialog box, enter the local path of the wireless.bat file in the Program/script box under Settings and click OK.

    Least Privilege Security for Windows 7, Vista and XP

  10. Switch to the Conditions tab and under Power, uncheck Start the task only if the computer is on AC power.

    Least Privilege Security for Windows 7, Vista and XP

  11. Click OK. In the central pane of Task Scheduler, right-click the Wireless task and select Run from the menu. Make sure that the wireless adapter is restarted as expected.

The challenge is now to allow a standard user to run this task, because, by default, standard users can't run tasks on demand that are created by an administrator. We need to change permissions on the Wireless task using Windows Explorer to allow Authenticated Users to run it.

  1. Launch Windows Explorer by pressing the Windows Key + E. Navigate to C:\Windows\System32\Tasks\Support, right-click on the Wireless file, and select Properties from the menu.
  2. In the Wireless Properties dialog box, switch to the Security tab.
  3. Click on Edit and in the Permissions for Wireless window, click Add.
  4. In the Selected Users, Computers, Service Accounts, or Groups dialog box, click on Locations, select the local computer, and click OK.
  5. Type Authenticated Users into the box and click OK.
  6. In the Permissions for Wireless window, select Authenticated Users and check Allow for Read & Execute and Read permissions.

    Least Privilege Security for Windows 7, Vista and XP

  7. Click OK and then Yes in the Windows Security dialog box.
  8. Click OK in the Wireless Properties dialog box.

Running the Scheduled Task as a standard user

Now that the task is in place and permissions have been set, let's set up a shortcut to allow the user to run the task on demand. Log in to the notebook using a standard user account, in this case user@ad.contoso.com.

  1. Open a command prompt and type schtasks /run /TN "Support\ Wireless" and press Enter.
  2. Schtasks should respond with SUCCESS: Attempted to run the scheduled task "Support\Wireless".
  3. Check that the wireless adapter has been restarted as expected.
  4. Right-click the user's desktop and select New | Shortcut from the menu.
  5. In the Create Shortcut dialog box, type schtasks /run /TN "Support\ Wireless" into the box and click Next.

    Least Privilege Security for Windows 7, Vista and XP

  6. Give the shortcut a name and click Finish.

Summary

In this article, we've learned how to cope with difficult support situations for standard users and run common processes without the need to elevate with administrative privileges all the time.


Further resources on this subject:


Least Privilege Security for Windows 7, Vista and XP Secure Microsoft Windows desktops with least privilege security for regulatory compliance and business agility with this security book and eBook for Windows 7, Vista and XP
Published: July 2010
eBook Price: $35.99
Book Price: $59.99
See more
Select your format and quantity:

About the Author :


Russell Smith

Russell Smith is an independent IT consultant who specializes in management and security of Microsoft-based IT systems. An MCSE with more than ten years experience, his recent projects include Active Directory Security Consultant for the UK Health Service National Programme for Information Technology (NPfIT) and Exchange Architect for Wipro Technologies.  Russell is a regular contributor to industry journals Windows IT Professional, Security Professional VIP, CDW's Biztech Magazine and a contributing author to Supporting and Troubleshooting Applications on a Microsoft Windows Vista Client for Enterprise Support Technicians from Microsoft's Official Academic Course (MOAC) series of books published by Wiley and Sons. Russell also has extensive experience as an IT trainer.

Books From Packt


Applied Architecture Patterns on the Microsoft Platform
Applied Architecture Patterns on the Microsoft Platform

.NET Compact Framework 3.5 Data Driven Applications
.NET Compact Framework 3.5 Data Driven Applications

Microsoft Silverlight 4 Data and Services Cookbook
Microsoft Silverlight 4 Data and Services Cookbook

Microsoft Dynamics NAV 2009 Application Design
Microsoft Dynamics NAV 2009 Application Design

Microsoft Visio 2010 Business Process Diagramming and Validation
Microsoft Visio 2010 Business Process Diagramming and Validation

Microsoft Office Live Small Business: Beginner’s Guide
Microsoft Office Live Small Business: Beginner’s Guide

WCF 4.0 Multi-tier Services Development with LINQ to Entities
WCF 4.0 Multi-tier Services Development with LINQ to Entities

Refactoring with Microsoft Visual Studio 2010
Refactoring with Microsoft Visual Studio 2010


No votes yet

Post new comment

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
X
7
W
b
Y
X
Enter the code without spaces and pay attention to upper/lower case.
Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Resources
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software