Microsoft Windows Security
- 3/15/2012
Account Rights and Privileges
Many operations performed by processes as they execute cannot be authorized through object access protection because they do not involve interaction with a particular object. For example, the ability to bypass security checks when opening files for backup is an attribute of an account, not of a particular object. Windows uses both privileges and account rights to allow a system administrator to control what accounts can perform security-related operations.
A privilege is the right of an account to perform a particular system-related operation, such as shutting down the computer or changing the system time. An account right grants or denies the account to which it’s assigned the ability to perform a particular type of logon, such as a local logon or interactive logon, to a computer.
A system administrator assigns privileges to groups and accounts using tools such as the Active Directory Users and Groups MMC snap-in for domain accounts or the Local Security Policy Editor (%SystemRoot%\System32\secpol.msc). You access the Local Security Policy Editor in the Administrative Tools folder of the Control Panel or the Start menu (if you’ve configured your Start menu to contain an Administrative Tools link). Figure 6-8 shows the User Rights Assignment configuration in the Local Security Policy Editor, which displays the complete list of privileges and account rights available on Windows. Note that the tool makes no distinction between privileges and account rights. However, you can differentiate between them because any user right that does not contain the words log on is an account privilege.
Figure 6-8 Local Security Policy Editor user rights assignment
Account Rights
Account rights are not enforced by the security reference monitor, nor are they stored in tokens. The function responsible for logon is LsaLogonUser. Winlogon, for example, calls the LogonUser API when a user logs on interactively to a computer, and LogonUser calls LsaLogonUser. LogonUser takes a parameter that indicates the type of logon being performed, which includes interactive, network, batch, service, and Terminal Server client.
In response to logon requests, the Local Security Authority (LSA) retrieves account rights assigned to a user from the LSA policy database at the time that a user attempts to log on to the system. LSA checks the logon type against the account rights assigned to the user account logging on and denies the logon if the account does not have the right that permits the logon type or it has the right that denies the logon type. Table 6-8 lists the user rights defined by Windows.
Windows applications can add and remove user rights from an account by using the LsaAddAccountRights and LsaRemoveAccountRights functions, and they can determine what rights are assigned to an account with LsaEnumerateAccountRights.
Table 6-8 Account Rights
User Right |
Role |
Deny logon locally, Allow logon locally |
Used for interactive logons that originate on the local machine |
Deny logon over the network, Allow logon over the network |
Used for logons that originate from a remote machine |
Deny logon through Terminal Services, Allow logon through Terminal Services |
Used for logons through a Terminal Server client |
Deny logon as a service, Allow logon as a service |
Used by the service control manager when starting a service in a particular user account |
Deny logon as a batch job, Allow logon as a batch job |
Used when performing a logon of type batch |
Privileges
The number of privileges defined by the operating system has grown over time. Unlike user rights, which are enforced in one place by the LSA, different privileges are defined by different components and enforced by those components. For example, the debug privilege, which allows a process to bypass security checks when opening a handle to another process with the OpenProcess Windows API, is checked for by the process manager. Table 6-9 is a full list of privileges, and it describes how and when system components check for them.
When a component wants to check a token to see whether a privilege is present, it uses the PrivilegeCheck or LsaEnumerateAccountRights APIs if running in user mode and SeSinglePrivilegeCheck or SePrivilegeCheck if running in kernel mode. The privilege-related APIs are not account-right aware, but the account-right APIs are privilege-aware.
Unlike account rights, privileges can be enabled and disabled. For a privilege check to succeed, the privilege must be in the specified token and it must be enabled. The idea behind this scheme is that privileges should be enabled only when their use is required so that a process cannot inadvertently perform a privileged security operation.
Table 6-9 Privileges
Privilege |
User Right |
Privilege Usage |
SeAssignPrimaryTokenPrivilege |
Replace a process-level token |
Checked for by various components, such as NtSetInformationJob, that set a process’ token. |
SeAuditPrivilege |
Generate security audits |
Required to generate events for the Security event log with the ReportEvent API. |
SeBackupPrivilege |
Back up files and directories |
Causes NTFS to grant the following access to any file or directory, regardless of the security descriptor that’s present: READ_CONTROL, ACCESS_SYSTEM_SECURITY, FILE_GENERIC_READ, FILE_TRAVERSE Note that when opening a file for backup, the caller must specify the FILE_FLAG_BACKUP_SEMANTICS flag. Also allows corresponding access to registry keys when using RegSaveKey. |
SeChangeNotifyPrivilege |
Bypass traverse checking |
Used by NTFS to avoid checking permissions on intermediate directories of a multilevel directory lookup. Also used by file systems when applications register for notification of changes to the file system structure. |
SeCreateGlobalPrivilege |
Create global objects |
Required for a process to create section and symbolic link objects in the directories of the object manager namespace that are assigned to a different session than the caller. |
SeCreatePagefilePrivilege |
Create a pagefile |
Checked for by NtCreatePagingFile, which is the function used to create a new paging file. |
SeCreatePermanentPrivilege |
Create permanent shared objects |
Checked for by the object manager when creating a permanent object (one that doesn’t get deallocated when there are no more references to it). |
SeCreateSymbolicLinkPrivilege |
Create symbolic links |
Checked for by NTFS when creating symbolic links on the file system with the CreateSymbolicLink API. |
SeCreateTokenPrivilege |
Create a token object |
NtCreateToken, the function that creates a token object, checks for this privilege. |
SeDebugPrivilege |
Debug programs |
If the caller has this privilege enabled, the process manager allows access to any process or thread using NtOpenProcess or NtOpenThread, regardless of the process’ or thread’s security descriptor (except for protected processes). |
SeEnableDelegationPrivilege |
Enable computer and user accounts to be trusted for delegation |
Used by Active Directory services to delegate authenticated credentials. |
SeImpersonatePrivilege |
Impersonate a client after authentication |
The process manager checks for this when a thread wants to use a token for impersonation and the token represents a different user than that of the thread’s process token. |
SeIncreaseBasePriorityPrivilege |
Increase scheduling priority |
Checked for by the process manager and is required to raise the priority of a process. |
SeIncreaseQuotaPrivilege |
Adjust memory quotas for a process |
Enforced when changing a process’ working set thresholds, a process’ paged and nonpaged pool quotas, and a process’ CPU rate quota. |
SeIncreaseWorkingSetPrivilege |
Increase a process working set |
Required to call SetProcessWorkingSetSize to increase the minimum working set. This indirectly allows the process to lock up to the minimum working set of memory using VirtualLock. |
SeLoadDriverPrivilege |
Load and unload device drivers |
Checked for by the NtLoadDriver and NtUnloadDriver driver functions. |
SeLockMemoryPrivilege |
Lock pages in memory |
Checked for by NtLockVirtualMemory, the kernel implementation of VirtualLock. |
SeMachineAccountPrivilege |
Add workstations to the domain |
Checked for by the Security Accounts Manager on a domain controller when creating a machine account in a domain. |
SeManageVolumePrivilege |
Perform volume maintenance tasks |
Enforced by file system drivers during a volume open operation, which is required to perform disk checking and defragmenting activities. |
SeProfileSingleProcessPrivilege |
Profile single process |
Checked by Superfetch and the prefetcher when requesting information for an individual process through the NtQuerySystemInformation API. |
SeRelabelPrivilege |
Modify an object label |
Checked for by the SRM when raising the integrity level of an object owned by another user, or when attempting to raise the integrity level of an object higher than that of the caller’s token. |
SeRemoteShutdownPrivilege |
Force shutdown from a remote system |
Winlogon checks that remote callers of the InitiateSystemShutdown function have this privilege. |
SeRestorePrivilege |
Restore files and directories |
This privilege causes NTFS to grant the following access to any file or directory, regardless of the security descriptor that’s present: WRITE_DAC WRITE_OWNER ACCESS_SYSTEM_SECURITY FILE_GENERIC_WRITE FILE_ADD_FILE FILE_ADD_SUBDIRECTORY DELETE Note that when opening a file for restore, the caller must specify the FILE_FLAG_BACKUP_SEMANTICS flag. Allows corresponding access to registry keys when using RegSaveKey. |
SeSecurityPrivilege |
Manage auditing and security log |
Required to access the SACL of a security descriptor, and to read and clear the security event log. |
SeShutdownPrivilege |
Shut down the system |
This privilege is checked for by NtShutdownSystem and NtRaiseHardError, which presents a system error dialog box on the interactive console. |
SeSyncAgentPrivilege |
Synchronize directory service data |
Required to use the LDAP directory synchronization services. It allows the holder to read all objects and properties in the directory, regardless of the protection on the objects and properties. |
SeSystemEnvironmentPrivilege |
Modify firmware environment variables |
Required by NtSetSystemEnvironmentValue and NtQuerySystemEnvironmentValue to modify and read firmware environment variables using the hardware abstraction layer (HAL). |
SeSystemProfilePrivilege |
Profile system performance |
Checked for by NtCreateProfile, the function used to perform profiling of the system. This is used by the Kernprof tool, for example. |
SeSystemtimePrivilege |
Change the system time |
Required to change the time or date. |
SeTakeOwnershipPrivilege |
Take ownership of files and other objects |
Required to take ownership of an object without being granted discretionary access. |
SeTcbPrivilege |
Act as part of the operating system |
Checked for by the security reference monitor when the session ID is set in a token, by the Plug and Play manager for Plug and Play event creation and management, by BroadcastSystemMessageEx when called with BSM_ALLDESKTOPS, by LsaRegisterLogonProcess, and when specifying an application as a VDM with NtSetInformationProcess. |
SeTimeZonePrivilege |
Change the time zone |
Required to change the time zone. |
SeTrustedCredManAccessPrivilege |
Access credential manager as a trusted caller |
Checked by the credential manager to verify that it should trust the caller with credential information that can be queried in plain text. It is granted only to Winlogon by default. |
SeUndockPrivilege |
Remove computer from a docking station |
Checked for by the user-mode Plug and Play manager when either a computer undock is initiated or a device eject request is made. |
SeUnsolicitedInputPrivilege |
Receive unsolicited data from a terminal device |
This privilege isn’t currently used by Windows. |
Super Privileges
Several privileges are so powerful that a user to which they are assigned is effectively a “super user” who has full control over a computer. These privileges can be used in an infinite number of ways to gain unauthorized access to otherwise off-limit resources and to perform unauthorized operations. However, we’ll focus on using the privilege to execute code that grants the user privileges not assigned to the user, with the knowledge that this capability can be leveraged to perform any operation on the local machine that the user desires.
This section lists the privileges and discusses the ways that they can be exploited. Other privileges, such as Lock Pages In Physical Memory, can be exploited for denial-of-service attacks on a system, but these are not discussed. Note that on systems with UAC enabled, these privileges will be granted only to applications running at high integrity level or higher, even if the account possesses them:
Debug programs A user with this privilege can open any process on the system (except for a Protected Process) without regard to the security descriptor present on the process. The user could implement a program that opens the LSASS process, for example, copy executable code into its address space, and then inject a thread with the CreateRemoteThread Windows API to execute the injected code in a more-privileged security context. The code could grant the user additional privileges and group memberships.
Take ownership This privilege allows a holder to take ownership of any securable object (even protected processes and threads) by writing his own SID into the owner field of the object’s security descriptor. Recall that an owner is always granted permission to read and modify the DACL of the security descriptor, so a process with this privilege could modify the DACL to grant itself full access to the object and then close and reopen the object with full access. This would allow the owner to see sensitive data and to even replace system files that execute as part of normal system operation, such as LSASS, with his own programs that grant a user elevated privileges.
Restore files and directories A user assigned this privilege can replace any file on the system with her own. She could exploit this power by replacing system files as described in the preceding paragraph.
Load and unload device drivers A malicious user could use this privilege to load a device driver into the system. Device drivers are considered trusted parts of the operating system that can execute within it with System account credentials, so a driver could launch privileged programs that assign the user other rights.
Create a token object This privilege can be used in the obvious way to generate tokens that represent arbitrary user accounts with arbitrary group membership and privilege assignment.
Act as part of operating system LsaRegisterLogonProcess, the function a process calls to establish a trusted connection to LSASS, checks for this privilege. A malicious user with this privilege can establish a trusted-LSASS connection and then execute LsaLogonUser, a function used to create new logon sessions. LsaLogonUser requires a valid user name and password and accepts an optional list of SIDs that it adds to the initial token created for a new logon session. The user could therefore use her own user name and password to create a new logon session that includes the SIDs of more privileged groups or users in the resulting token.
Note that the use of an elevated privilege does not extend past the machine boundary to the network, because any interaction with another computer requires authentication with a domain controller and validation of domain passwords. Domain passwords are not stored on a computer either in plain text or encrypted form, so they are not accessible to malicious code.