Microsoft Windows Security Resource Kit

Using Tools to Secure IIS

Two tools are available to secure an IIS server: the IIS Lockdown tool and the URLScan filter. These tools remove known weaknesses in the IIS configuration and provide filters to prevent known attacks against the IIS server.

The IIS Lockdown Tool

By default, Windows 2000 includes the installation of IIS. The IIS Lockdown tool allows you to secure IIS configuration without removing and reinstalling the service. The IIS Lockdown tool can be run by an administrator or can be scripted to allow the unattended application of IIS Lockdown settings to an IIS server. The installation of the tool is broken down into security configuration sections:

Selecting a Server Template

The Select Server Template page provides a list of predefined IIS configuration templates. Each template contains IIS settings designed for the software in the IIS Server template name. By selecting a server template from the list, the IIS Lockdown tool will apply the necessary settings to secure IIS in that environment.

When you select a server template, you can view the specific settings by enabling the View Template Settings check box. This option allows you to review the configured settings and apply any modifications necessary for your IIS environment.

Creating a Custom Server Template

You can create custom server templates in the IISlockd.ini file for use with the IIS Lockdown tool. All custom server templates appear in the IIS Lockdown tool as available templates. You can create a custom server template by editing the IISlockd.ini file to include your custom settings.

The first step is to include pointers to your custom server template section. You must declare your custom template in either the ServerTypesNT4, the ServerTypes, or UnattendedServerType lines in the [Info] section, as shown next. In this case, CustomTemplate is available for both manual and unattended installations.

[Info] ServerTypesNT4=sbs4.5,exchange5.5,frontpage,proxy,staticweb,dynamicweb, other,iis_uninstalled ServerTypes=CustomTemplate,sbs2000,exchange5.5,exchange2k, sharepoint_portal,frontpage,biztalk,commerce,proxy,staticweb, dynamicweb,other,iis_uninstalled UnattendedServerType=CustomTemplate Unattended=TRUE Undo=FALSE

Once you define the pointers, you must create a section based on the referral in the [Info] section that details the settings for the custom server template. The following example ensures that

These settings are all defined in the [CustomTemplate] section, which enforces the previous settings and is shown next. The section name is based on the tag assigned to the section in the [Info] section shown earlier.

[CustomTemplate] label="A Custom Server Template" Enable_iis_http=TRUE Enable_iis_ftp= FALSE Enable_iis_smtp= FALSE Enable_iis_nntp= FALSE Enable_asp= TRUE Enable_index_server_web_interface= FALSE Enable_server_side_includes= FALSE Enable_internet_data_connector= FALSE Enable_internet_printing= FALSE Enable_HTR_scripting= FALSE Enable_webDAV= FALSE Disable_Anonymous_user_system_utility_execute_rights= TRUE Disable_Anonymous_user_content_directory_write_rights= TRUE Remove_iissamples_virtual_directory=TRUE Remove_scripts_directory=TRUE Remove_MSADC_virtual_directory=TRUE Remove_iisadmin_virtual_directory=TRUE Remove_iishelp_virtual_directory=TRUE UrlScan_Install=ENABLED UrlScan_IniFileLocation=%Windir%\System32\Inetsrv\Urlscan AdvancedSetup = UninstallServices=FALSE

Configuring Internet Services

If you enable the View Template Settings check box or choose to configure the other server template, you can configure which Internet services are available at the IIS server. You can select whether each service is enabled or disabled, as shown in Figure 21-5.

Figure 21-5. Defining the startup state for IIS

An enabled service is indicated by a selected check box. A disabled service is indicated by an unselected check box. If a service is grayed out, it is not installed on the IIS server.

You can also remove unselected services by enabling the Remove Unselected Services check box. This option removes any unselected services, rather than leaving the services disabled.

We recommend you leave services disabled. Many applications depend on dynamic-link libraries (DLLs) enabled by IIS. If a service is disabled, the DLLs remain available for other applications. If the service is removed, some applications will reinstall and enable IIS to gain access to the required DLLs.

Enabling Script Maps

IIS can limit what scripts can be executed on an IIS server by defining script maps. Script maps associate script files, such as ASP pages, with a specific scripting engine for processing. Script maps are implemented by using Internet Server Application Programming Interface (ISAPI).

In the Script Maps page, you can enable and disable predefined script maps. If a script map is disabled, the default script map is replaced with a script that causes the server to respond with a HTTP 404 File not found error. The following script maps can be enabled or disabled:

You must determine whether each script map is required for your IIS environment. Some script maps (such as server-side includes and .idc scripts) can be updated to use ASP pages.

Applying Additional Security

The Additional Security page allows you to implement extra measures for your IIS server, as shown in Figure 21-6.

Figure 21-6. Defining additional security settings in the IIS Lockdown tool

The extra measures that you can take include the following:

URLScan

URLScan is an ISAPI filter that screens and analyzes HTTP requests as Microsoft IIS receives them. The URLScan filter will apply settings based on the IIS Server template selected in the IIS Lockdown tool.

The URLScan Filter

As mentioned in the description of the IIS Lockdown tool, URLScan is an ISAPI filter that screens and analyzes inbound HTTP requests as IIS receives them. The URLScan filter will apply settings based on the IIS Server template selected in the IIS Lockdown tool. This ISAPI filter can be installed on IIS. If you install the Internet Security and Acceleration (ISA) Server Feature Pack, the ISAPI filter can be installed on an ISA server that protects multiple IIS servers.

URLScan analyzes all incoming HTTP requests against a URLScan filter configuration file to determine whether the request should be allowed. If the request is allowed, the Web server responds with the requested resource. If the request is denied, the Web server sends an Object not found response to the client, rather than sending details about why the request is denied.

Installing URLScan

URLScan can be automatically installed when you run the IIS Lockdown tool or manually installed by modifying the properties of the IIS server. When you install the IIS Lockdown tool, you have the option to install URLScan. In this case, the URLScan filter is configured to match the server environment selected in the IIS Lockdown tool. After you complete installation, you can manually modify the configuration of the URLScan.ini file to customize Web server security.

Configuring URLScan

The URLScan ISAPI filter screens incoming HTTP requests and blocks requests based on the configuration of the URLScan.ini file. By default, this file is stored in the %systemroot%\system32\Inetsrv\URLScan folder and must reside in the same folder as URLScan.dll if you modify the default storage location.

You must restart the WWW Publishing service to enable any configuration changes in the URLScan.ini file.

The URLScan.ini file consists of seven sections:

Options Section

The Options section defines the main options for the URLScan filter. It also designates which additional sections are used while processing incoming HTTP requests. You can define the following options:

AllowVerbs Section

The AllowVerbs section contains a list of HTTP verbs that are allowed in HTTP requests. If the UseAllowVerbs option is set to 1, URLScan rejects any HTTP requests containing a verb not explicitly listed. The entries in this section are case sensitive.

DenyVerbs Section

The DenyVerbs section contains a list of HTTP verbs that are explicitly not allowed in HTTP requests. If the UseAllowVerbs option is set to 0, URLScan rejects any HTTP requests that contain a listed verb. The entries in this section are case insensitive.

DenyHeaders Section

The DenyHeaders section contains a list of request headers. Any HTTP requests that contain a request header listed in this section are rejected. The entries in this section are case insensitive.

AllowExtensions Section

The AllowExtensions section contains a list of allowed file extensions. If the UseAllowExtensions option is set to a value of 1, any request containing a URL with an extension not listed is rejected. You can specify URLs that do not have an extension by adding an extension represented by a dot and no trailing characters.

DenyExtensions Section

The DenyExtensions section contains a list of disallowed file extensions. If the UseAllowExtensions option is set to 0, any request containing a URL with an extension in the listing is rejected. The entries in this section are case insensitive.

RequestLimits Section

This section allows you to enforce limits on the size of an HTTP request. The size definitions can be defined for each section of an HTTP request. The size restrictions are defined in the following three entries:

In addition to these settings, you can create custom limitations by request header type by creating an entry based on the header name and adding the prefix Max- . For example, to limit the length of the Content-Type header to 200 bytes, you can add the entry Max-Content-Type=200 in the RequestLimits section.

URLScan Logging

If URLScan denies a Web request, it will log the action into the %systemroot%\ system32\inetsrv\urlscan\URLScan.log file. The log file will include the reason for the denial and additional information about the request:

Категории