21.03.2013 Views

Problem - Kevin Tafuro

Problem - Kevin Tafuro

Problem - Kevin Tafuro

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

which the service is running. The token contains a list of all of the groups to which<br />

the user belongs (the user and each group in the list is represented by a Security ID or<br />

SID), as well as a set of privileges that any thread running with the token has. The set<br />

of privileges is initialized from the privileges assigned by the system administrator to<br />

the user and the groups to which the user belongs.<br />

Beginning with Windows 2000, it is possible to create a restricted token and force<br />

threads to run using that token. Once a restricted token has been applied to a running<br />

thread, any restrictions imposed by the restricted token cannot be lifted; however,<br />

it is possible to revert the thread back to its original unrestricted token. With<br />

restricted tokens, it’s possible to remove privileges, restrict the SIDs that are used in<br />

access checking, and deny SIDs access. The use of restricted tokens is more useful<br />

when combined with the CreateProcessAsUser( ) API to create a new process with a<br />

restricted token that cannot be reverted to a more permissive token.<br />

Beginning with Windows .NET Server 2003, it is possible to permanently remove<br />

privileges from a process’s token. Once the privileges have been removed, they cannot<br />

be added back. Any new processes created by a process running with a modified<br />

token will inherit the modified token; therefore, the same restrictions imposed upon<br />

the parent process are also imposed upon the child process. Note that modifying a<br />

token is quite different from creating a restricted token. In particular, only privileges<br />

can be removed; SIDs can be neither restricted nor denied.<br />

Discussion<br />

Tokens contain a list of SIDs, composed of the user’s SID and one SID for each<br />

group of which the user is a member. SIDs are assigned by the system when users<br />

and groups are created. In addition to the SIDs, tokens also contain a list of restricted<br />

SIDs. When access checks are performed and the token contains a list of restricted<br />

SIDs, the intersection of the two lists of SIDs contained in the token is used to perform<br />

the access check. Finally, tokens also contain a list of privileges. Privileges<br />

define specific access rights. For example, for a process to use the Win32 debugging<br />

API, the process’s token must contain the SeDebugPrivilege privilege.<br />

The primary list of SIDs contained in a token cannot be modified. The token is created<br />

for a particular user, and the token must always contain the user’s SID along<br />

with the SIDs for each group of which the user is a member. However, each SID in<br />

the primary list can be marked with a “deny” attribute, which causes access to be<br />

denied when an access control list (ACL) contains a SID that is marked as “deny” in<br />

the active token.<br />

Creating restricted tokens<br />

Using the CreateRestrictedToken( ) API, a restricted token can be created from an<br />

existing token. The resulting token can then be used to create a new process or to set<br />

8 | Chapter 1: Safe Initialization<br />

This is the Title of the Book, eMatter Edition<br />

Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!