Securing IIS 5.0 Using Batch-Oriented Command Files Operating System White Paper AbstractThis white paper describes the use of command files or batch programs to automate the security settings on a Web server running Windows 2000 Server or Windows 2000 Advanced Server and Internet Information Services 5.0 in an enterprise environment. This white paper is intended for system administrators and assumes familiarity with Windows 2000 Server and IIS 5.0, registry settings in the operating system, and metadata settings in IIS 5.0. This paper will not attempt a detailed explanation of registry settings or metadata settings. For that information, turn to the documentation for Windows 2000 Server and IIS 5.0. The command files and supporting utilities discussed in this white paper can be found on the Windows 2000 Web Server Rapid Deployment Guide CD, or on the Web in this zip file: http://www.microsoft.com/windows2000/zipdocs/security.exe It is important to note that the Windows Management Interface (WMI) provides a more robust interface for managing the server operating system than provided by command files and utilities. The use of command files is discussed here because many administrators are familiar with using these in legacy operating systems.
This white paper draws on experience gained by Microsoft engineers who upgraded Web servers to Windows 2000 Advanced Server at the MSN Hotmail® Web-based e-mail service. The security and performance considerations in that upgrade are relevant for many Web hosting environments, including large e-commerce enterprises. The performance and security settings outlined in this paper are not exhaustive. There are excellent resources and related links available on http://www.microsoft.com/windows2000/. A list of related articles can be found in the For More Information section at the end of this white paper. However, a good starting point for further reading is the Microsoft Security Web site at http://www.microsoft.com/security/. For information on performance tuning, read The Art and Science of Web Server Tuning with Internet Information Services 5.0 at http://www.microsoft.com/TechNet/iis/iis5tune.asp. Caution Do not use these tools indiscriminately. These settings will create a highly secure Web server. However, applying them to a Web server will most likely break existing applications. The settings may restrict customer access to Web sites. Before configuring security, system administrators must understand the effect and proper use of each setting. This paper includes command files that contain the types of performance and security settings used in the Hotmail deployment. These are not identical to the actual command files used at Hotmail, but they are similar enough to be used as a model. It is strongly recommended that one tests proposed modifications to security or performance settings in a lab environment prior to implementing on production systems.
Understanding Security NeedsAdministrators should be keenly aware of the security needs and considerations at their organization before configuring security settings. As mentioned, the settings that are included in command files in this paper are for illustration purposes only. These command files can be modified as needed before they are applied to Web servers in other organizations. For example, an organization running Web applications that require less restrictive access to public Web servers must amend the settings in the command files to allow such access. Otherwise, the Web applications will not work. Additionally, these command files were built specifically for use on Web servers, running the Windows 2000 Server operating system and IIS 5. They need to be modified if used on servers supporting different roles. Modifying the Command File to Match Specific NeedsAdministrators should study all of the parameters being modified in the command file and understand the effects of those modifications on Web applications. The command files described in this white paper illustrate how to automate common administrative tasks, such as maintaining security, tuning performance and preventing denial of service (DOS) attacks. For more information on aspects of a Web server that should be secured, along with why and how to secure them, read the article titled Secure Internet Information Services 5 Checklist at http://www.microsoft.com/technet/security/iis5chk.asp. System administrators can use the checklist in that article to help them determine security goals and requirements for their organizations. They can customize the command file herein to automate the implementation of those requirements.
Two Options for Securing ServersWhen thinking about deploying Windows 2000 Server in a Web hosting environment, many system administrators face the questions: How can we make this system secure? How do we keep hackers out? Those questions are usually followed by another: How can we make this system secure in a quick, automated and consistent fashion? System administrators can choose from two methods to answer those questions. As they migrate front-end Web servers to Windows 2000 with IIS 5.0, they can configure security on each server using the Microsoft Management Console. Alternatively, all security settings can be handled via the command line. Some administrators prefer to use command files, also known as batch files, because they are familiar with using command files in legacy operating systems. Administrators who oversee hundreds or thousands of Web servers want as much automation as possible when configuring security as they upgrade, and command files can provide additional automation. The command files in this paper use commands available natively in the Windows 2000 Server operating system (OS), along with native OS utilities, and utilities available in the Windows 2000 Resource Kit. Some of the security settings are implemented by making changes directly to the Windows 2000 registry and the IIS 5.0 metadata information.
Use the File as a TemplateAny Web-hosting enterprise, including most e-commerce enterprises, can follow a process similar to that used at MSN Hotmail to make servers highly secure when upgrading to Windows 2000 Server and IIS 5.0. The command file in Appendix 1, w2kseccfg.cmd, will automatically apply security settings very similar to those used on the Hotmail servers. That is not recommended. As mentioned previously, these settings will most likely break some Web applications. The recommended best practice is for administrators to use the command file as a template for the most common security settings to modify on a Web server. For example, the command file provides a setting necessary to change password expiration policy on Web servers. This setting can be customized to fit the needs of any organization. It should not be necessary to manually copy the files to each computer. There are several automated ways to do this. At Hotmail, administrators used the command file to apply the settings to a master build image. Interim updates can be distributed via a software distribution utility, or with the rdist.exe utility available with Windows 2000 Services for Unix. Disable Unnecessary Security CommandsIf the command file is applied without modification, a Web server may stop functioning as expected and/or some remote administration functionality may become inoperable. For example, the command file disables remote access to the registry for some users. If an administrative function requires remote access to the registry, that function would become inoperable. To prevent this, administrators should:
Similar consideration and customization should be used with each of the settings in the command file. Several of the settings in the command file could disable a Web server application. Therefore, administrators should thoroughly test their custom configurations on servers in a lab before deploying them on production Web servers. Administrators should install Windows 2000 Server Service Pack 1 on all servers before running the command file. As Microsoft releases future hot fixes, these should be added to the command file and installed on Web servers to maintain security and performance. The default security settings in Windows 2000 Server and Windows 2000 Advanced Server with IIS 5.0 are more secure than in previous operating systems. The default security settings in the previous version of IIS were designed for greater ease of connectivity, and were more appropriate security settings for small businesses, home users, or intranets. The default settings in Windows 2000 with IIS 5.0 are designed for the greater security required in Web-hosting enterprises. IIS 5.0, out of the box, is very, very secure. At the same time, however, IIS 5.0 includes sample applications to help developers write programs. IIS 5.0 also includes ActiveX controls to make development easier. These aids, although useful, open potential security gaps that must be closed on Web servers before the public is granted access. White papers on the Windows 2000 Web Server Rapid Deployment Guide CD and the Microsoft.com Web site provide security checklists for system administrators preparing to host Web applications. These address items such as sample applications and ActiveX controls. The command file, w2kseccfg.cmd, provides an automated implementation of the checklists.
The files in Appendix 1 contain the commands and utilities that were used on the Hotmail Web site to apply more restrictive security settings than the defaults, and to install fixes for security vulnerabilities which were identified after the commercial release of Windows 2000. The command file, commands, and utilities include: w2kseccfg.cmdThe w2kseccfg.cmd file is the main command file, which implements several enforcements. For example, it can modify the services that will run on the system (services.cmd); set audit policy (auditpol.exe); and apply hot fixes such as Q262694_W2K_SP2_x86_en.EXE. It uses regini.exe for modifying the Windows 2000 registry in an unattended fashion. For the latest list of security and denial of service advisories see http://www.microsoft.com/security/. The w2kseccfg.cmd file assumes that W2KregSec.dat and the executables referenced by the command file are saved to the same directory as w2kseccfg.cmd. This file contains the nested utilities and commands for settings discussed in this white paper. Regini.exeThis is a tool for editing the registry in Windows 2000. The registry is a database for information about a computer's configuration. Registry setting modifications for security include such things as restricting hidden file system shares, and modifying TCP/IP settings to optimize the server for attachment to the public Internet. By running regini.exe, administrators can automate any of the registry-related security settings. The w2kregsec.dat file provides the input. Administrators must edit the registry keys in the w2kregsec.dat file to make the appropriate security modifications for a particular system. For more information, see the Windows 2000 Server Resource Kit at http://www.microsoft.com/windows2000/library/resources/reskit/default.asp. w2kregsec.datThis is the primary input file used by regini.exe. This file contains the registry keys that will be modified. For more information about registry keys and their values, see the Windows 2000 Server Resource Kit. Cryptpwd.exeThis is a resource kit utility that can be used for renaming the administrator account. The following command line provides an example of how the utility is used.
This command renames the local administrator account to jimbob. Passprop.exeNormally, the Administrator account cannot be locked out if a hacker attempts to guess the password. However, this tool in the Windows 2000 Resource Kit, passprop, supports the lockout option for logons to the administrator account over the network. The command below locks out the Administrator account from network access if a hacker attempts a brute force or dictionary attack, but the administrator can still log on locally at the server using this account:
This setting also enforces complex passwords. A complex password is one that requires at least one upper case, one lower case and numeric or special characters. Auditpol.exeThis is a resource kit utility for setting the audit policy on a server. It enables the user to modify the audit policy of the local computer or of any remote computer. To run AuditPol, the user must have administrator privileges on the target computer. AuditPol can set the computer to monitor such things as system events, logon/logoff events, use of privileges, security policy changes and more. For further explanation of this utility's function, type auditpol.exe /? at the command prompt and Windows 2000 will display help text. Q262694_W2K_SP2_x86_en.EXE -z -q -m File names in this format are Windows 2000 operating system fixes. The file name given here is one example; there are several fixes with similarly structured names. Periodically Microsoft releases service packs that contain applicable fixes. Normally administrators install individual patches only when instructed to do so by a premier support professional or a Microsoft security advisory. When Microsoft identifies a security vulnerability the most current information is posted at the Microsoft Security Web site at http://www.microsoft.com/security/. Q262694 _W2K_SP2_x86_en.EXE is a self-extracting executable, an example of a fix issued from Microsoft. The switches; -z, -q, -m do the following: -z: Do not reboot after running the hot fix -q: Quiet mode – No user interface -m: unattended Mode Q262694 is the reference number that describes what this particular fix does. For more information, search for the reference number on the Microsoft Knowledge Base Web at http://search.support.microsoft.com/kb/c.asp. If any of the fixes listed here are included in Service Pack 2 when it is released, it would no longer be necessary to include the patch in the command file. Windows 2000 IIS 5.0 Hot fix Checking Tool This is a useful tool, HFCINST.exe, for auditing a Web server. The HFCheck tool allows IIS 5.0 administrators to ensure that their servers are up to date on all security patches. The tool can be run continuously or periodically, on a local machine or a remote one, using either a database on the Microsoft Web site or a locally-hosted copy. When the tool finds a patch missing, it can display a dialogue box or write a warning to the event log. Administrators can run this tool on their reference machine after executing w2kseccfg.cmd to validate that all of the pertinent hot fixes were applied. Visit this Web site to download the Windows 2000 IIS 5.0 Hotfix Checking Tool at http://www.microsoft.com/Downloads/Release.asp?ReleaseID=24168. Windows 2000 CommandsThe Windows 2000 commands used by the command file in Appendix 1 include basic commands such as reg.exe, cmd.exe, and Net.exe. Other examples include:
For more information about any command, type the command name followed by /? in a command prompt. For a complete list of Windows 2000 commands, see Windows 2000 Server Help Adsutil.vbsAdsutil.vbs can be used to modify IIS 5.0 metadata settings. A detailed list of metadata settings can be found in the IIS 5.0 Help. Adsutil.vbs can be found in the \inetpub directory on an IIS 5.0-based server. IIS 5.0 Help describes how administrators can use the adsutil.vbs command, and the following list of commands to modify various metadata settings in IIS 5.0:
For specific examples of how adsutil.vbs commands can be used in security configuration, see the appendix. XcAcls.exeThis tool allows administrators to set file-system security options for NTFS partitions, from the command line. XcAcls does this by displaying and modifying the access control lists (ACLs) of files. With this tool, administrators can set the initial access rights for folders in which the operating system resides. The ACLs determine which users have permission to read, write, execute or modify a particular file. When administrators distribute software to servers or workstations, XcAcls also offers one-step protection against deletion of directories or files by users. Although this procedure is somewhat application-dependent, some rules of thumb apply. Guides for setting the appropriate ACLs can be found in the IIS 5.0 Resource Guide and in the Windows NT Security Guidelines study for NSA Research by Trusted Systems Services Inc. at http://www.trustedsystems.com/tss_nsa_guide.htm. In the command file w2kseccfg.cmd, the following command line is an example of modifying the ACLs on all of the .asp files. cmd /c "xcacls.exe *.asp /t /e /c /p everyone:x administrators:f system:f" Administrators should extensively test any modified ACLs in a lab before moving the configuration into a production environment. For more information on setting up a test lab, see Chapter 4 of the Windows 2000 Deployment Planning Guide at http://www.microsoft.com/windows2000/library/resources/reskit/dpg/default.asp Table 1 on the following page lists the most common types of files for which Web administrators modify ACLs, and the recommended ACL settings for those file types. On the left are the file types. On the right are the recommended ACL settings. Table 1.
The command files discussed in this paper also provide the means for accomplishing other modifications recommended for security on a Web server. These recommendations can be found in the IIS 5 Security Checklist white paper. The command files automate such things as the deleting of sample applications, disabling of unneeded COM components, and removal of unnecessary directories. Disabling or Removing All Sample ApplicationsSamples are just that, samples. They should never be installed on a production server. Note that some samples install so that they can be accessed only from http://localhost, or 127.0.0.1; however, these should also be removed. Table 2 below lists the default locations for some of the samples. The command file in Appendix 1 automatically deletes these directories. Table 2 Sample files included with IIS 5.
Disabling or Removing Unneeded COM ComponentsSome COM components are not required for most applications and should be removed. Most notably, consider disabling the File System Object component, but note that this will also remove the Dictionary object. Be aware that some programs might require components you're disabling. For example, Site Server 3.0 uses the File System Object. The following command will disable File System Object:
Removing the IISADMPWD Virtual DirectoryThis directory allows administrators to reset Windows NT and Windows 2000 passwords. It's designed primarily for intranet scenarios and is not installed as part of IIS 5, but it is not removed when an IIS 4.0 server is upgraded to IIS 5.0. It should be removed if it is not used for an intranet or if the server is connected to the Web. Refer to Microsoft Knowledge Base article Q184619 for more information about this functionality. Post Implementation AuditingAlthough not specifically used in the command files illustrated in this paper, there are several Windows 2000 tools that can help administrators identify vulnerabilities. Some examples include:
More information on security auditing can be found in the Microsoft Press book Designing Secure Web-Based Applications for Microsoft® Windows 2000
System administrators must carefully plan security requirements for their enterprise and study the security settings and configurations available in IIS 5.0 and Windows 2000 Server. Then administrators can use the command files in Appendix 1, as a sample template, to automate the configuration of security settings on Web servers. While the Microsoft Management Console provides a more intuitive method of configuring security, some administrators may prefer to use this method system for convenience because they are familiar with using command files on legacy Web server operating systems or changes must be implemented concurrently, on dozens or thousands of Web servers.
For the latest information on Windows 2000 Server, check out our Web site at http://www.microsoft.com/windows2000/ and the Windows 2000/NT Forum at http://computingcentral.msn.com/topics/windowsnt/. Other Related Links include:
Command FilesAll of the command files and supporting utilities can be found on the Windows 2000 Web Server Rapid Deployment Guide CD, or in this zip file: http://www.microsoft.com/windows2000/zipdocs/security.exe W2kseccfg.cmd
Services.cmd
The information contained in this document represents the current view of Microsoft Corporation on the issues discussed as of the date of publication. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information presented after the date of publication. This white paper is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS DOCUMENT. Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under copyright, no part of this document may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or for any purpose, without the express written permission of Microsoft Corporation. Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document. Except as expressly provided in any written license agreement from Microsoft, the furnishing of this document does not give you any license to these patents, trademarks, copyrights, or other intellectual property. © 2000 Microsoft Corporation. All rights reserved. Microsoft, BackOffice, Windows, and Windows NT are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries. Other product and company names mentioned herein may be the trademarks of their respective owners. Microsoft Corporation • One Microsoft Way • Redmond, WA 98052-6399 • USA 9/2000
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||