- Security Model
- Securing Objects
- SAM Database
- The Flow of a User Logon
- Summary
Components
The security functionality in Windows 2000 has several components. I looked briefly at some of these components in Chapter 1, "Architecture"; now it's time to really dig in:
Security Reference Monitor (SRM)The component of the Windows 2000 Executive (kernel) that actually performs the security access checks, adjusts privileges, and generates audit messages when necessary.
Local Security Authority (LSA)A privileged user-mode process that enforces local security policy. This includes logon, password, and audit policies and privileges affecting the local system (such as the right to back up and the right to debug programs). Also works with the SRM to process logons and audits. Implemented in LSASS.EXE.
Logon Process (WINLOGON.EXE)A privileged user-mode process that handles the SAS, retrieves username and password credentials, passes them to the LSA for authorization, and creates the user's initialization process (USERINT.EXE).
Graphical Identification and Authentication (GINA)Implements the user interface portion of providing logon credentials.
Network Logon ServiceA user-mode process that responds to network logon requests.
Security PackagesProvide security services (such as authentication) to the systemand native applications.
Security Support Provider Interface (SSPI)A Win32 API that provides the interface between applications and the security packages.
Security Account Manager (SAM)Database where local account and policy information is stored. This hasn't changed from previous versions of Windows NT.
Active Directory (AD)Where the domainwide account and policy information is stored. The AD is new to Windows 2000 and is covered in detail in Chapter 14, "Active Directory Services."
Figure 3.9 shows how the security components fit in the overall scheme of things.
Figure 3.9 Windows 2000 security components.
Let's take a look at each component in detail.
The Security Reference Monitor (SRM)
The SRM lives in the Windows 2000 Executive. Its responsibilities are to monitor object access and generate security audits (in the system event log) when necessary.
The SRM ensures that every object access is consistent with the security descriptor (SD) attached to it. To do this, the SRM works closely with the Object Manager, another component of the Windows 2000 Executive.
The SRM checks security at the time of handle creation, not at each accessfor obvious performance reasons. You can imagine the performance hit if each time you accessed an (already open) file the security was parsed. The SRM makes the assumption that the security won't change while the handle is open; if access was allowed at the time of handle creation, then access will be allowed until the handle is closed. This is important to remember if you're ever playing with security and wonder why the changes aren't taking effect immediately; you might already have an open handle to the object in question.
The algorithm that the SRM uses to determine whether access will be granted follows:
If the object has no DACL, the object is not protected and thus full access is allowed.
If the caller has the SE_TAKE_OWNERSHIP_NAME privilege, the SRM immediately grants the caller the right to modify the owner field in the SD before further examining the DACL.
If the caller is the owner of the object, the caller is granted read-control and write-control on the DACL (the ability to view and modify the DACL) before further evaluating the DACL.
Each ACE in the DACL is examined in order. (ACE order is important, as you'll see in a moment.) If the SID in the ACE matches an enabled SID in the token (primary or impersonation), the ACE is processed.
If all of the access rights the caller requested can be granted, the object access succeeds. If any one of the requested access rights can't be granted, the object access fails.
NOTE
Folks familiar with UNIX will notice a difference here. In UNIX, there is a special account called root that has a UID (user ID, same idea as an SID) of 0. Root is equivalent to administrator in the Windows world. However, there is a difference: The UNIX kernel does not evaluate security when UID 0 makes a request; it just gives it whatever it wants. In Windows 2000, however, it is possible for the administrator to be denied access to objects because the SRM processes the administrator account just like any other account. However, because the administrator has the SE_TAKE_OWNERSHIP_NAME privilege, he is free to take ownership and rewrite the DACL to allow himself access as desired.
In Windows 2000, the order of the ACEs is important. Non-inherited ACEs go before inherited ACEs, and within each group access-denied ACEs go before access-granted ACEs. This ordering ensures, for example, that a non-inherited access-denied ACE is enforced regardless of any inherited ACE that allows access. I discussed this earlier in the chapter.
It's also important to keep in mind that it is impossible to protect an object from code running in kernel mode. You'll remember from Chapter 1 that kernel-mode components share one common 2GB memory space. Because all kernel objects live in that space, processes running in kernel mode can directly modify an object without supervision by the SRM (or even Object Manager). This makes perfect sense because anything running in kernel mode already owns the system, so there isn't any point in applying protections.
NOTE
You'll remember from Chapter 1 that device drivers run in kernel mode. You'll also remember from the discussion a few moments ago that the SE_LOAD_DRIVER_NAME privilege is required to load device drivers. This is a powerful privilege that should only be given to administrators. Although it is tempting to allow users to install drivers themselves (for printers, sound cards, and so on), this is a huge security risk because a Trojan driver could easily gain free reign over the local system.
All user-mode processes, on the other hand, interact with kernel objects via a pseudo-handle. The Object Manager is the only process that actually touches the kernel memory structures where the object physically lives. It is not possible to bypass the Object Manager (and thus the SRM) when accessing kernel objects from user mode. This is the desired behavior.
The SRM also evaluates the SACL in a similar fashion and writes audit events to the event log as necessary. The SRM does not actually write to the audit log directly; rather it passes a message to the LSA, which then adds some additional information and writes the audit. What a perfect transition into our discussion about the LSA!
The Local Security Authority (LSA)
The Local Security Authority (LSA), a user-mode process, works closely with the SRM to execute some tasks that are better accomplished from user mode.
The LSA (user mode) and the SRM (kernel mode) communicate using the Local Procedure Call (LPC) facility. Although a careful discussion of LPC is beyond the scope of this text, for our purposes just consider it a general-purpose communications channel.
During Windows 2000 system initialization, the SRM creates an LPC port called SeRmCommandPort. When the LSA service starts, it connects to SeRmCommandPort and creates a port called SeLsaCommandPort, to which the SRM connects. After both connections are established, they exchange information about a shared section of memory. Once these communication channels are established, both processes stop listening for new connects on the named ports to prevent a malicious process from sending messages to either process. Figure 3.10 shows the communication channels.
Figure 3.10 The LSA and the SRM communicate using two LPC ports and a shared memory section.
The LSA also performs many other, miscellaneous, security-related tasks. It is responsible for enforcing (and informing the SRM of) local policy. As you saw a moment ago, the LSA is responsible for writing events to the audit log. It is also the front end for user authentication, which I get to in a moment.
WINLOGON.EXE
The logon process, WINLOGON.EXE, is a user-mode process that handles most of the user's interaction with the Windows 2000 security architecture. WINLOGON captures the username and password and creates the initial user process. It also handles managing the screensaver, locking the local terminal, and changing passwords.
On system initialization, before any other user-mode code has run, WINLOGON does the following:
It creates and opens a window station to represent the local console. The SD on the window station object has only one ACE that grants WINLOGON's SID full control. This ensures that no other process can gain access to the keyboard, monitor, or mouse unless allowed by WINLOGON.
It creates three desktops: a WINLOGON desktop, a screensaver desktop, and a standard desktop. The SD on the WINLOGON desktop grants only WINLOGON full control. This means that any time the WINLOGON desktop is active, only the WINLOGON process can access it. The two other desktops allow other users to access them.
It establishes an LPC connection with the LSA.
It loads the authentication packages listed in HKLM\System\CurrentControlSet\Control\LSA.
Then, WINLOGON performs some operations to set up the WINLOGON desktop and the environment as a whole:
It builds and registers a window class associating the WINLOGON procedure with this class.
It registers the Secure Attention Sequence (SAS) associating it with the window class created in step 1. This guarantees that whenever the SAS is invoked, WINLOGON's window procedure will gain control of the terminal.
It registers the window class so that the associated procedure is called if the user logs off or the screensaver times out. As an extra check, the Win32 subsystem checks to be sure that the WINLOGON process is the one making this requestand Win32 will not fill the request for any other process.
Once the WINLOGON desktop is created, it becomes the active desktop. WINLOGON is the only process that can switch desktops. On successful user logon, the standard desktop is swapped in and built. Whenever the SAS is invoked, WINLOGON springs into action and swaps the WINLOGON desktop back in.
Graphical Identification and Authentication (GINA)
The GINA is a replaceable DLL that contains the user interface for providing logon credentials (username and password). The default GINA, MSGINA.DLL, draws the ever-familiar logon screen. However, what if I were using a retinal scanner for authentication or a smart card? Simple, just replace the GINA. All the GINA does is draw the UI and hand the information to the LSA for verification. Developers interested in writing a custom GINA will find a wealth of information, including samples, in the SDK.
Network Logon Service
The Network Logon Service, or NetLogon, is a user-mode service (as they all are) that supports pass-through authentication of logons (and supporting events) for computers in a domain. Network logon requests are handled just like any other logon request except that an impersonation token is built in place of a primary token, and the USERINIT.EXE process, which builds the local shell, is not started. You'll look at an interactive logon in detail in just a few pages; I point out the differences between an interactive logon and network logon while you work through the example.
Security Packages
The packages that ship with Windows 2000 are
Kerberos
MSV1_0
Schannel
Kerbero is a well-known protocol that I talk about in great detail in Chapter 12, "X.500/LDAP."
MSV1_0 is a Microsoft-proprietary protocol that is a throwback to the old LanManager days. I talk about MSV1_0 in Chapter 15, "Authentication."
Schannel implements secure channel protocols such as Secure Socket Layer (SSL) or Private Communications Technology (PCT), as well as public key infrastructure (PKI). Schannel is discussed in Chapter 17, "CryptoAPI," and PKI is discussed in Chapter 11, "Kerberos Protocol."
SSPI
Let's face it: Good security is hard. Why do you think so many developers (me included) use plain-text password files or passwords stored in unencrypted database fields in their applications? Easybecause the developers don't or can't take the time/energy/effort to learn and implement the strong crypto required for good security.
Windows 2000's SSPI makes good security easy for developers. The Security Support Provider Interface (SSPI) is a common API for obtaining integrated security services for authentication, integrity, and privacy for any distributed application protocol. Application developers can take advantage of this interface to easily obtain security services right from the operating system.
I look at the SSPI in detail when I discuss using Windows 2000 security in your applications in Chapter 17.