ISAPI/CGI 制限 <isapiCgiRestriction>
概要
<security> 要素の <isapiCgiRestriction>
要素を使用すると、インターネット インフォメーション サービス (IIS) 7 で実行できる Common Gateway Interface (CGI) アプリケーションとインターネット サーバー アプリケーション プログラミング インターフェイス (ISAPI) アプリケーションの一覧を指定できます。 この要素を使用すると、悪意のあるユーザーが、承認されていない CGI および ISAPI バイナリを Web サーバーにコピーして実行できないように設定できます。
この要素を使用して Web サーバーを構成する必要があるのは、サイトまたはアプリケーションがクラシック モードで実行されるアプリケーション プールを使用する場合のみです。 <isapiCgiRestriction>
要素で構成する制限は、ISAPI および CGI コードにのみ適用されます。
<isapiCgiRestriction>
要素には、<add>
要素のコレクションが含まれます。 各 <add>
要素は、クラシック モードの IIS 7 サーバーでは実行できない個別のバイナリを定義します。
たとえば、ASP.NET 2.0 アプリケーションを作成し、クラシック モードで実行されるアプリケーション プールを使用するようにアプリケーションを構成した場合、ASP.NET アプリケーションに対するすべての要求は、処理する aspnet_isapi.dll を経由する必要があります。 IIS が ASP.NET 要求を確実に処理するために、IIS は、<isapiCgiRestriction>
要素に、値が true に設定された許可属性を格納する <add>
要素を設定します。
許可される属性を false に変更し、アプリケーション プールをクラシック モードのままにした場合、ASP.NET 要求は失敗します。 ただし、アプリケーション プールを統合モードに変更した場合、IIS は統合要求パイプラインを使用して ASP.NET 要求を処理します。このパイプラインは、構成した ISAPI と CGI の制限をバイパスします。
<isapiCgiRestriction>
要素は <applicationDependencies> 要素と連携して、1 つ以上の CGI または ISAPI 拡張制限に依存するアプリケーションを定義します。
互換性
バージョン | メモ |
---|---|
IIS 10.0 | <isapiCgiRestriction> 要素は、IIS 10.0 では変更されませんでした。 |
IIS 8.5 | <isapiCgiRestriction> 要素は、IIS 8.5 では変更されませんでした。 |
IIS 8.0 | <isapiCgiRestriction> 要素は IIS 8.0 では変更されませんでした。 |
IIS 7.5 | <isapiCgiRestriction> 要素は、IIS 7.5 では変更されませんでした。 |
IIS 7.0 | <isapiCgiRestriction> 要素が IIS 7.0 で導入されました。 |
IIS 6.0 | <isapiCgiRestriction> コレクションは、IIS 6.0 IIsWebService メタベース オブジェクトの WebSvcExtRestrictionList プロパティを置き換えます。 |
段取り
<isapiCgiRestriction>
コレクションは、IIS 7 以降のサーバーに CGI または ISAPI 拡張機能モジュールをインストールした後にのみ使用できます。 これらの機能と独立してインストールすることはできません。
Windows Server 2012 または Windows Server 2012 R2
- タスク バーで [サーバー マネージャー]をクリックします。
- [サーバー マネージャー] で、[管理] メニューを選択し、[役割と機能の追加] を選択します。
- [役割と機能の追加] ウィザードで、[次へ] をクリックします。 インストールの種類を選択し、[次へ] をクリックします。 対象サーバーを選択し、[次へ] を選択します。
- [サーバーの役割] ページで [Web サーバー (IIS)] を展開し、[Web サーバー]、[アプリケーション開発] の順に展開し、[CGI] または [ISAPI 拡張機能] を選択します。 次へ をクリックします。
.
- [機能の選択] ページで、[次へ] をクリックします。
- [インストール オプションの確認] ページで、[インストール] をクリックします。
- [結果] ページで、 [閉じる]をクリックします。
Windows 8 または Windows 8.1
- [スタート] 画面で、ポインターを左下隅まで移動し、[スタート] ボタンを右クリックし、[コントロール パネル] をクリックします。
- [コントロール パネル] で [プログラムと機能] を選択し、[Windows の機能の有効化または無効化] を選択します。
- [インターネット インフォメーション サービス]、[World Wide Web サービス]、[アプリケーション開発機能] の順に展開し、[CGI] または [ISAPI 拡張機能] を選択します。
- OK をクリックします。
- 閉じるをクリックします。
Windows Server 2008 または Windows Server 2008 R2
- タスク バーで [スタート] をクリックし、[管理ツール] をポイントして、[サーバー マネージャ] をクリックします。
- [サーバー マネージャ] 階層ウィンドウで [役割] を展開し、[Web サーバー (IIS)] をクリックします。
- [Web サーバー (IIS)] ウィンドウで、[役割サービス] セクションまでスクロールし、[役割サービスの追加] を選択します。
- 役割サービスの追加ウィザードの [役割サービスの選択] ページで [CGI] または [ISAPI 拡張機能] を選択します。
- [役割サービスの追加] ダイアログが表示されたら、[必要な役割サービスの追加] を選択します。 (このページは、前提条件となる役割サービスをサーバーにまだインストールしていない場合にのみ表示されます)。
- [役割サービスの選択] ページで、[次へ] を選択します。
- [インストール オプションの確認] ページで、[インストール] をクリックします。
- [結果] ページで、 [閉じる]をクリックします。
Windows Vista または Windows 7
- タスク バーで、[スタート]、[コントロール パネル] の順にクリックします。
- [コントロール パネル] で [プログラムと機能] をクリックし、[Windows の機能の有効化または無効化] をクリックします。
- [Windows 機能] ダイアログ ボックスで、[インターネット インフォメーション サービス]、[World Wide Web サービス]、[アプリケーション開発機能] の順に展開します。
- [CGI] または [ISAPI 拡張機能] を選択し、[OK] を選択します。
操作方法
ISAPI または CGI の制限を追加する方法
インターネット インフォメーション サービス (IIS) マネージャーを開きます。
Windows Server 2012 または Windows Server 2012 R2 を使用している場合:
- タスク バーで、[サーバー マネージャー] をクリックし、[ツール]、[インターネット インフォメーション サービス (IIS) マネージャー] の順にクリックします。
Windows 8 または Windows 8.1 を使用している場合:
- Windows キーを押しながら文字 X を押し、[コントロール パネル] をクリックします。
- [管理ツール] をクリックし、[インターネット インフォメーション サービス (IIS) マネージャー] をダブルクリックします。
Windows Server 2008 または Windows Server 2008 R2 を使用している場合:
- タスク バーで、[スタート] ボタンをクリックし、[管理ツール]、[インターネット インフォメーション サービス (IIS) マネージャー] の順にクリックします。
Windows Vista または Windows 7 を使用している場合:
- タスク バーで、[スタート]、[コントロール パネル] の順にクリックします。
- [管理ツール] をダブルクリックし、[インターネット インフォメーション サービス (IIS) マネージャー] をダブルクリックします。
[接続] ウィンドウで、サーバー名を選択します。
[ホーム] ウィンドウで、[ISAPI および CGI の制限] をダブルクリックします。
[操作] ウィンドウで、[追加] を選択します。
[Add ISAPI or CGI Restriction]\(ISAPI または CGI の制限の追加\) ダイアログ ボックスで、ISAPI または CGI パス ボックスに追加するバイナリへのパスを入力し、[説明] ボックスにバイナリの説明を入力し、[Allow extension path option to execute]\(実行する拡張パスを許可する\) チェック ボックスをオンにして、バイナリをサーバー上で実行できるようにし、[OK] を選択します。
構成
<isapiCgiRestriction>
コレクションは、ApplicationHost.config ファイルのサーバー レベルでのみ構成できます。
属性
属性 | 説明 |
---|---|
notListedIsapisAllowed |
省略可能な Boolean 属性です。 このサーバーで、一覧に含まれない ISAPI モジュールの実行を許可するかどうかを指定します。 既定値は false です。 |
notListedCgisAllowed |
省略可能な Boolean 属性です。 このサーバーで一覧に含まれない CGI プログラムの実行を許可するかどうかを指定します。 既定値は false です。 |
子要素
要素 | 説明 |
---|---|
add |
省略可能な要素です。 ISAPI および CGI の制限のコレクションに制限を追加します。 |
remove |
省略可能な要素です。 isapiCgiRestriction コレクションから制限への参照を削除します。 |
clear |
省略可能な要素です。 isapiCgiRestriction コレクションから制限へのすべての参照を削除します。 |
構成サンプル
次の構成例は、ASP と ASP.NET バージョン 2.0 をインストールした後の IIS 7.0 の <isapiCgiRestriction>
要素構成です。
<security>
<isapiCgiRestriction>
<add allowed="true" groupId="ASP"
path="%windir%\system32\inetsrv\asp.dll"
description="Active Server Pages" />
<add allowed="true" groupId="ASP.NET v2.0.50727"
path="%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll"
description="ASP.NET v2.0.50727" />
</isapiCgiRestriction>
</security>
サンプル コード
次の例では、C:\Inetpub\www.contoso.com\wwwroot 内の Web サイトのコンテンツ フォルダーにあるカスタム ISAPI 拡張機能の ISAPI/CGI 制限を追加します。 この例では、ISAPI 拡張機能の名前、パス、グループを指定し、拡張機能を有効にします。
AppCmd.exe
appcmd.exe set config -section:system.webServer/security/isapiCgiRestriction /+"[path='C:\Inetpub\www.contoso.com\wwwroot\isapi\custom.dll',allowed='True',groupId='ContosoGroup',description='Contoso Extension']" /commit:apphost
Note
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 isapiCgiRestrictionSection = config.GetSection("system.webServer/security/isapiCgiRestriction");
ConfigurationElementCollection isapiCgiRestrictionCollection = isapiCgiRestrictionSection.GetCollection();
ConfigurationElement addElement = isapiCgiRestrictionCollection.CreateElement("add");
addElement["path"] = @"C:\Inetpub\www.contoso.com\wwwroot\isapi\custom.dll";
addElement["allowed"] = true;
addElement["groupId"] = @"ContosoGroup";
addElement["description"] = @"Contoso Extension";
isapiCgiRestrictionCollection.Add(addElement);
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 isapiCgiRestrictionSection As ConfigurationSection = config.GetSection("system.webServer/security/isapiCgiRestriction")
Dim isapiCgiRestrictionCollection As ConfigurationElementCollection = isapiCgiRestrictionSection.GetCollection
Dim addElement As ConfigurationElement = isapiCgiRestrictionCollection.CreateElement("add")
addElement("path") = "C:\Inetpub\www.contoso.com\wwwroot\isapi\custom.dll"
addElement("allowed") = True
addElement("groupId") = "ContosoGroup"
addElement("description") = "Contoso Extension"
isapiCgiRestrictionCollection.Add(addElement)
serverManager.CommitChanges()
End Sub
End Module
JavaScript
var adminManager = new ActiveXObject('Microsoft.ApplicationHost.WritableAdminManager');
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST";
var isapiCgiRestrictionSection = adminManager.GetAdminSection("system.webServer/security/isapiCgiRestriction", "MACHINE/WEBROOT/APPHOST");
var isapiCgiRestrictionCollection = isapiCgiRestrictionSection.Collection;
var addElement = isapiCgiRestrictionCollection.CreateNewElement("add");
addElement.Properties.Item("path").Value = "C:\\Inetpub\\www.contoso.com\\wwwroot\\isapi\\custom.dll";
addElement.Properties.Item("allowed").Value = true;
addElement.Properties.Item("groupId").Value = "ContosoGroup";
addElement.Properties.Item("description").Value = "Contoso Extension";
isapiCgiRestrictionCollection.AddElement(addElement);
adminManager.CommitChanges();
VBScript
Set adminManager = createObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST"
Set isapiCgiRestrictionSection = adminManager.GetAdminSection("system.webServer/security/isapiCgiRestriction", "MACHINE/WEBROOT/APPHOST")
Set isapiCgiRestrictionCollection = isapiCgiRestrictionSection.Collection
Set addElement = isapiCgiRestrictionCollection.CreateNewElement("add")
addElement.Properties.Item("path").Value = "C:\Inetpub\www.contoso.com\wwwroot\isapi\custom.dll"
addElement.Properties.Item("allowed").Value = True
addElement.Properties.Item("groupId").Value = "ContosoGroup"
addElement.Properties.Item("description").Value = "Contoso Extension"
isapiCgiRestrictionCollection.AddElement(addElement)
adminManager.CommitChanges()