Windows 扩展保护 <extendedProtection>
概述
<extendedProtection>
元素指定在 IIS 7.5 中为 Windows 身份验证配置扩展保护的设置。
扩展保护增强了现有的 Windows 身份验证功能,以缓解身份验证中继或“中间人”攻击。 这种缓解措施是通过两种安全机制实现的安全信息来实现的:
- 通过通道绑定令牌 (CBT) 指定的通道绑定信息,主要用于 SSL 连接。
- 通过服务主体名称 (SPN) 指定的服务绑定信息,主要用于不使用 SSL 的连接,或是在以下情况下使用:建立连接的场景中提供了 SSL 卸载(如代理服务器或负载平衡器)。
该<extendedProtection>
元素可能包含一组 <spn>
元素,其中每个元素都包含服务绑定信息的唯一 SPN。 每个 SPN 表示连接路径中的唯一终结点,该终结点可以是目标服务器或代理服务器的完全限定域名 (FQDN) 或 NetBIOS 名称。 例如,如果客户端通过代理服务器连接到目标服务器,则目标服务器上的 SPN 集合需要包含代理服务器的 SPN。 集合中的每个 SPN 都必须以“HTTP”为前缀,因此,为“www.contoso.com”生成的 SPN 将为“HTTP/www.contoso.com”。
<extendedProtection>
元素可为 IIS 扩展保护配置通道绑定和其他行为,此元素有两个属性:
tokenChecking 属性配置通道绑定令牌检查行为。 此属性的值可能包括:
名称 描述 None
此值指定 IIS 不会执行通道绑定令牌检查。 此设置模拟在扩展保护之前存在的行为。
数值为0
。Allow
此值指定启用通道绑定令牌检查,但此值不是必需的。 此设置允许与支持扩展保护的客户端进行安全通信,但仍支持无法使用扩展保护的客户端。
数值为1
。Require
此值指定需要通道绑定令牌检查。 如果客户端不支持扩展保护,则客户端也不支持此设置。
数值为2
。flags 属性配置扩展保护的其他行为。 可能的标志包括:
名称 描述 None
此标志指定不为扩展保护启用任何其他行为。 (例如,未使用代理服务器,并且启用了 SPN 检查,并且需要 FQDN。)
数值为0
。Proxy
此标志指定部分通信路径将通过代理,或者指定客户端通过 HTTP 直接连接到目标服务器。
数值为1
。NoServiceNameCheck
此标志指定禁用 SPN 检查;如果是仅检查 SPN,则不应使用此标志。
数值为2
。AllowDotlessSpn
此标志指定不需要 SPN 才能成为 FQDN。 设置此标志可允许基于 NetBIOS 的 SPN。 注意:设置此标志不是安全方案;非基于 FQDN 的名称易受名称解析中毒攻击。
数值为4
。ProxyCohosting
此标志指定整个客户端到服务器通信路径将仅使用 HTTP;通信路径中没有任何部分使用 SSL,并且将使用 SPN 检查。 注意:指定此标志时,还必须指定 Proxy
标志。
数值为32
。
扩展保护方案
假设以下示例方案:
- 在以下每种方案中,如果你的网络环境支持基于 NetBIOS 的 SPN,则还可以指定
AllowDotlessSpn
标志。但是,基于 NetBIOS 的 SPN 并不安全。 - 在以下情况中,将使用 SPN 检查,而不使用通道绑定令牌检查,因此不应指定
NoServiceNameCheck
标志。
场景 | 标记 | 说明 |
---|---|---|
客户端使用 HTTP 直接连接到目标服务器 | Proxy 、ProxyCohosting |
将使用 SPN 检查,并且不使用通道绑定令牌检查。 |
客户端使用 SSL 直接连接到目标服务器 | None |
使用通道绑定令牌检查,并且不使用 SPN 检查。 |
客户端连接到目标服务器时,在整个路径中使用 HTTP | Proxy 、ProxyCohosting |
将使用 SPN 检查,并且不使用通道绑定令牌检查。 |
客户端连接到目标服务器时,在整个路径中使用 SSL | Proxy |
将使用 SPN 检查,并且不使用通道绑定令牌检查。 |
客户端使用 SSL 连接到代理服务器,而代理服务器使用 HTTP 连接到目标服务器(SSL 卸载) | Proxy |
将使用 SPN 检查,并且不使用通道绑定令牌检查。 |
其他信息
有关扩展保护的详细信息,请参阅以下主题:
兼容性
版本 | 说明 |
---|---|
IIS 10.0 | <extendedProtection> 元素在 IIS 10.0 中未进行修改。 |
IIS 8.5 | <extendedProtection> 元素在 IIS 8.5 中未进行修改。 |
IIS 8.0 | <extendedProtection> 元素在 IIS 8.0 中未进行修改。 |
IIS 7.5 | <extendedProtection> 元素是在 IIS 7.5 中引入的。 |
IIS 7.0 | 空值 |
IIS 6.0 | 空值 |
安装
IIS 7 及更高版本的默认安装不包括 Windows 身份验证角色服务。 要在 IIS 上使用 Windows 身份验证,必须安装角色服务,为网站或应用程序禁用匿名身份验证,然后为网站或应用程序启用 Windows 身份验证。
注意
安装角色服务后,IIS 7 会将以下配置设置提交到 ApplicationHost.config 文件。
<windowsAuthentication enabled="false" />
Windows Server 2012 或 Windows Server 2012 R2
- 在任务栏上,单击 “服务器管理器”。
- 在“服务器管理器”中,单击“管理”菜单,然后单击“添加角色和功能”。
- 在“添加角色和功能”向导中,单击“下一步”。 选择安装类型,然后单击“下一步”。 选择目标服务器,然后单击“下一步”。
- 在“服务器角色”页上,依次展开“Web 服务器 (IIS)”、“Web 服务器”和“安全性”,然后选择“Windows 身份验证”。 单击 “下一步” 。
。
- 在“选择功能”页上,单击“下一步”。
- 在“确认安装选择”页上,单击“安装”。
- 在“结果” 页面中单击“关闭” 。
Windows 8 或 Windows 8.1
- 在“开始”屏幕上,将指针一直移动到左下角,右键单击“开始”按钮,然后单击“控制面板”。
- 在“控制面板”中,单击“程序与功能”,然后单击“打开或关闭 Windows 功能”。
- 依次展开“Internet Information Services”、“万维网服务”和“安全性”,然后选择“Windows 身份验证”。
- 单击“确定”。
- 单击“关闭” 。
Windows Server 2008 或 Windows Server 2008 R2
- 在任务栏上,单击“开始”,指向“管理工具”,然后单击“服务器管理器”。
- 在“服务器管理器”层次结构窗格中,展开“角色”,然后单击“Web 服务器(IIS)”。
- 在“Web 服务器(IIS)”窗格中,滚动到“角色服务”部分,然后单击“添加角色服务”。
- 在“添加角色服务向导”的“选择角色服务”页上,选择“Windows 身份验证”,然后单击“下一步”。
- 在“确认安装选择”页中,单击“安装”。
- 在“结果” 页面中单击“关闭” 。
Windows Vista 或 Windows 7
- 在任务栏上,单击“开始”,然后单击“控制面板”。
- 在“控制面板”中,单击“程序与功能”,然后单击“打开或关闭 Windows 功能”。
- 扩展“Internet Information Services”,展开“万维网服务”,然后展开“安全性”。
- 选择“Windows 身份验证”,然后单击“确定”。
操作方式
如何为 Windows 身份验证启用扩展保护
打开 Internet Information Services (IIS) 管理器:
如果使用的是 Windows Server 2012 或 Windows Server 2012 R2:
- 在任务栏上,单击“服务器管理器”,单击“工具”,然后单击“Internet Information Services (IIS)管理器”。
如果使用的是 Windows 8 或 Windows 8.1:
- 按住 Windows 键,按字母 X,然后单击“控制面板”。
- 单击“管理工具”,然后双击“Internet Information Services (IIS) 管理器”。
如果使用的是 Windows Server 2008 或 Windows Server 2008 R2:
- 在任务栏上,单击“开始”,指向“管理工具”,然后单击“Internet Information Services (IIS)管理器”。
如果使用的是 Windows Vista 或 Windows 7:
- 在任务栏上,单击“开始”,然后单击“控制面板”。
- 双击“管理工具”,然后双击“Internet Information Services (IIS) 管理器”。
在“连接”窗格中,展开服务器名称、“站点”,然后展开要为其启用 Windows 身份验证扩展保护的站点、应用程序或 Web 服务。
滚动到“主页”窗格中的“安全性”部分,然后双击“身份验证”。
在“身份验证”页中,选择“Windows 身份验证”。
在“操作”窗格中,单击“高级设置”。
出现“高级设置”对话框时,在“扩展保护”下拉菜单中选择以下选项之一:
单击“确定”,关闭“高级设置”对话框。
配置
<extendedProtection>
元素可在 ApplicationHost.config 文件中进行配置(在站点、应用程序或虚拟目录级别)。
特性
属性 | 说明 | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
flags |
可选 flags 属性。 指定扩展保护的其他行为设置。 flags 属性可以是以下值的组合;默认值为 None 。
|
||||||||||||
tokenChecking |
可选 enum 属性。 指定通道绑定信息的检查行为。 tokenChecking 属性可以是下列值之一;默认值为 None 。
|
子元素
元素 | 说明 |
---|---|
spn |
将 SPN 添加到集合。 |
clearSpns |
清除 SPN 的集合。 |
removeSpn |
从集合中移除 SPN。 |
配置示例
以下示例显示了一个 <extendedProtection>
元素,该元素演示如何为默认网站启用 Windows 身份验证,并将两个 SPN 条目添加到 SPN 集合中。
<location path="Default Web Site">
<system.webServer>
<security>
<authentication>
<windowsAuthentication enabled="true">
<extendedProtection tokenChecking="Allow" flags="None">
<spn name="HTTP/www.contoso.com" />
<spn name="HTTP/contoso.com" />
</extendedProtection>
</windowsAuthentication>
</authentication>
</security>
</system.webServer>
</location>
代码示例
以下示例演示如何为默认网站配置具有扩展保护的 Windows 身份验证,以及如何向 SPN 集合添加两个 SPN 条目。
AppCmd.exe
appcmd.exe set config "Default Web Site" -section:system.webServer/security/authentication/windowsAuthentication /enabled:"True" /commit:apphost
appcmd.exe set config "Default Web Site" -section:system.webServer/security/authentication/windowsAuthentication /extendedProtection.tokenChecking:"Allow" /extendedProtection.flags:"None" /commit:apphost
appcmd.exe set config "Default Web Site" -section:system.webServer/security/authentication/windowsAuthentication /+"extendedProtection.[name='HTTP/www.contoso.com']" /commit:apphost
appcmd.exe set config "Default Web Site" -section:system.webServer/security/authentication/windowsAuthentication /+"extendedProtection.[name='HTTP/contoso.com']" /commit:apphost
注意
使用 AppCmd.exe 配置这些设置时,必须确保将 commit 参数设置为 apphost
。 这会将配置设置提交到 ApplicationHost.config 文件中的相应位置部分。
C#
using System;
using System.Text;
using Microsoft.Web.Administration;
internal static class Sample
{
private static void Main()
{
using (ServerManager serverManager = new ServerManager())
{
Configuration config = serverManager.GetApplicationHostConfiguration();
ConfigurationSection windowsAuthenticationSection = config.GetSection("system.webServer/security/authentication/windowsAuthentication", "Default Web Site");
windowsAuthenticationSection["enabled"] = true;
ConfigurationElement extendedProtectionElement = windowsAuthenticationSection.GetChildElement("extendedProtection");
extendedProtectionElement["tokenChecking"] = @"Allow";
extendedProtectionElement["flags"] = @"None";
ConfigurationElementCollection extendedProtectionCollection = extendedProtectionElement.GetCollection();
ConfigurationElement spnElement = extendedProtectionCollection.CreateElement("spn");
spnElement["name"] = @"HTTP/www.contoso.com";
extendedProtectionCollection.Add(spnElement);
ConfigurationElement spnElement1 = extendedProtectionCollection.CreateElement("spn");
spnElement1["name"] = @"HTTP/contoso.com";
extendedProtectionCollection.Add(spnElement1);
serverManager.CommitChanges();
}
}
}
VB.NET
Imports System
Imports System.Text
Imports Microsoft.Web.Administration
Module Sample
Sub Main()
Dim serverManager As ServerManager = New ServerManager
Dim config As Configuration = serverManager.GetApplicationHostConfiguration
Dim windowsAuthenticationSection As ConfigurationSection = config.GetSection("system.webServer/security/authentication/windowsAuthentication", "Default Web Site")
windowsAuthenticationSection("enabled") = True
Dim extendedProtectionElement As ConfigurationElement = windowsAuthenticationSection.GetChildElement("extendedProtection")
extendedProtectionElement("tokenChecking") = "Allow"
extendedProtectionElement("flags") = "None"
Dim extendedProtectionCollection As ConfigurationElementCollection = extendedProtectionElement.GetCollection
Dim spnElement As ConfigurationElement = extendedProtectionCollection.CreateElement("spn")
spnElement("name") = "HTTP/www.contoso.com"
extendedProtectionCollection.Add(spnElement)
Dim spnElement1 As ConfigurationElement = extendedProtectionCollection.CreateElement("spn")
spnElement1("name") = "HTTP/contoso.com"
extendedProtectionCollection.Add(spnElement1)
serverManager.CommitChanges()
End Sub
End Module
JavaScript
var adminManager = new ActiveXObject('Microsoft.ApplicationHost.WritableAdminManager');
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST";
var windowsAuthenticationSection = adminManager.GetAdminSection("system.webServer/security/authentication/windowsAuthentication", "MACHINE/WEBROOT/APPHOST/Default Web Site");
windowsAuthenticationSection.Properties.Item("enabled").Value = true;
var extendedProtectionElement = windowsAuthenticationSection.ChildElements.Item("extendedProtection");
extendedProtectionElement.Properties.Item("tokenChecking").Value = "Allow";
extendedProtectionElement.Properties.Item("flags").Value = "None";
var extendedProtectionCollection = extendedProtectionElement.Collection;
var spnElement = extendedProtectionCollection.CreateNewElement("spn");
spnElement.Properties.Item("name").Value = "HTTP/www.contoso.com";
extendedProtectionCollection.AddElement(spnElement);
var spnElement1 = extendedProtectionCollection.CreateNewElement("spn");
spnElement1.Properties.Item("name").Value = "HTTP/contoso.com";
extendedProtectionCollection.AddElement(spnElement1);
adminManager.CommitChanges();
VBScript
Set adminManager = createObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST"
Set windowsAuthenticationSection = adminManager.GetAdminSection("system.webServer/security/authentication/windowsAuthentication", "MACHINE/WEBROOT/APPHOST/Default Web Site")
windowsAuthenticationSection.Properties.Item("enabled").Value = True
Set extendedProtectionElement = windowsAuthenticationSection.ChildElements.Item("extendedProtection")
extendedProtectionElement.Properties.Item("tokenChecking").Value = "Allow"
extendedProtectionElement.Properties.Item("flags").Value = "None"
Set extendedProtectionCollection = extendedProtectionElement.Collection
Set spnElement = extendedProtectionCollection.CreateNewElement("spn")
spnElement.Properties.Item("name").Value = "HTTP/www.contoso.com"
extendedProtectionCollection.AddElement(spnElement)
Set spnElement1 = extendedProtectionCollection.CreateNewElement("spn")
spnElement1.Properties.Item("name").Value = "HTTP/contoso.com"
extendedProtectionCollection.AddElement(spnElement1)
adminManager.CommitChanges()