ISAPI/CGI 制限 <isapiCgiRestriction>

  • 概要
  • 互換性
  • セットアップ
  • 方法
  • 構成
  • サンプル コード

※本ページに挿入されている画像をクリックすると、画像全体が別ウィンドウで表示されます。

概要

<security> 要素の <isapiCgiRestriction> 要素を使用すると、インターネット インフォメーション サービス (IIS) 7.0 上で実行できる Common Gateway Interface (CGI) と Internet Server Application Programming Interface (ISAPI) のアプリケーションの一覧を指定できます。この要素を使用して、悪意のあるユーザーが無許可の CGI および ISAPI バイナリを Web サーバーにコピーして実行できないように設定できます。

サイトまたはアプリケーションがクラシック モードで実行されるアプリケーション プールを使用する場合に限り、この要素を使用して Web サーバーを構成する必要があります。<isapiCgiRestriction> 要素内で構成する制限は、ISAPI および CGI コードにのみ適用されます。

<isapiCgiRestriction> 要素には、<add> 要素のコレクションが格納されます。各 <add> 要素は、クラシック モードで IIS 7.0 サーバー上で実行できない個別のバイナリを定義します。

たとえば、ASP.NET 2.0 アプリケーションを作成して、クラシック モードで実行されるアプリケーション プールを使用するようにそのアプリケーションを構成した場合、ASP.NET アプリケーションへのすべての要求を処理するには aspnet_isapi.dll を通過する必要があります。IIS では、ASP.NET 要求を確実に処理するために、値が true に設定された allowed 属性を持つ <add> 要素を <isapiCgiRestriction> 要素に含めます。

allowed 属性を false に変更して、アプリケーション プールをクラシック モードのままにすると、ASP.NET 要求は失敗します。ただし、アプリケーション プールを統合モードに変更すると、IIS は統合要求パイプラインを使用して ASP.NET 要求を処理します。この要求パイプラインは、構成した ISAPI および CGI 制限をバイパスします。

<isapiCgiRestriction> 要素は、<applicationDependencies> 要素と連携して機能します。これらの要素によって、1 つ以上の CGI または ISAPI 拡張制限に依存するアプリケーションが定義されます。

互換性

  IIS 7.0 IIS 6.0
注意 <isapiCgiRestriction> は IIS 7.0 で新たに導入された要素です。 <isapiCgiRestriction> コレクションは、IIS 6.0 の IIsWebService メタベース オブジェクトの WebSvcExtRestrictionList プロパティに代わるものです。

セットアップ

<isapiCgiRestriction> コレクションは、IIS 7.0 サーバーに CGI または ISAPI 拡張モジュールをインストールした後でのみ使用できます。これらの機能に依存しないでこれをインストールすることはできません。

Windows Server 2008

  1. タスク バーで [スタート] ボタンをクリックし、[管理ツール] をポイントして [サーバー マネージャー] をクリックします。

  2. [サーバー マネージャー] ウィンドウのツリー表示で、[役割] を展開して [Web サーバー (IIS)] をクリックします。

  3. [Web サーバー (IIS)] ウィンドウで、[役割サービス] セクションまでスクロールして [役割サービスの追加] をクリックします。

  4. 役割サービスの追加ウィザードの [役割サービスの選択] ページで、[CGI] または [ISAPI 拡張機能] を選択します。

    拡大

  5. [役割サービスの追加] ダイアログ ボックスが表示されたら、[必要な役割サービスを追加] をクリックします (このページは、前提条件の役割サービスをサーバーにまだインストールしていない場合にのみ表示されます)。

  6. [役割サービスの選択] ページで [次へ] をクリックします。

  7. [インストール オプションの確認] ページで [インストール] をクリックします。

  8. [結果] ページで [閉じる] をクリックします。

Windows Vista

  1. タスク バーで [スタート] ボタンをクリックし、[コントロール パネル] をクリックします。

  2. コントロール パネルで、[プログラムと機能][Windows の機能の有効化または無効化] の順にクリックします。

  3. [Windows の機能] ダイアログ ボックスで、[Internet Information Services][World Wide Web サービス][アプリケーション開発機能] の順に展開します。

  4. [CGI] または [ISAPI 拡張機能] を選択して、[OK] をクリックします。

    拡大

方法

ISAPI または CGI 制限を追加する方法

  1. タスク バーで [スタート] ボタンをクリックし、[管理ツール] をポイントして [インターネット インフォメーション サービス (IIS) マネージャー] をクリックします。

  2. [接続] ウィンドウで、該当サーバー名をクリックします。

  3. [ホーム] ウィンドウで [ISAPI および CGI の制限] をダブルクリックします。

    拡大

  4. [操作] ウィンドウで [追加] をクリックします。

  5. [ISAPI または CGI の制限の追加] ダイアログ ボックスで、追加するバイナリへのパスを [ISAPI または CGI パス] ボックスに入力し、バイナリの説明を [説明] ボックスに入力して、[拡張パスの実行を許可する] チェック ボックスをオンにしてサーバー上で実行するバイナリを許可し、[OK] をクリックします。

    拡大

構成

<isapiCgiRestriction> コレクションは、ApplicationHost.config ファイル内で、サーバー レベルでのみ構成できます。

属性

属性 説明
notListedIsapisAllowed オプションの Boolean 属性。

一覧に登録されていない ISAPI モジュールのこのサーバー上での実行を許可するかどうかを指定します。

既定値は false です。
notListedCgisAllowed オプションの Boolean 属性。

一覧に登録されていない CGI プログラムのこのサーバー上での実行を許可するかどうかを指定します。

既定値は false です。

子要素

要素 説明
add オプションの要素。

ISAPI および CGI 制限のコレクションに制限を追加します。
remove オプションの要素。

isapiCgiRestriction コレクションから 1 つの制限に対する参照を削除します。
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

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()