XMLThreatProtection ポリシー

このページは ApigeeApigee ハイブリッドに適用されます。

Apigee Edge のドキュメントを表示する。

ポリシー アイコン

概要

XML の脆弱性を解決し、API に対する攻撃を最小限に抑えます。また、構成済みの制限に基づいて、XML ペイロードによる攻撃を検出します。XML の脅威を次の方法でスクリーニングします。

  • 除外する特定のキーワードやパターンのメッセージ内容を評価する
  • メッセージの解析前に、破損したメッセージや不正な形式のメッセージを検出する

このポリシーは拡張可能なポリシーであり、Apigee ライセンスによっては、このポリシーの使用によって費用や使用率に影響する場合があります。ポリシータイプと使用量への影響については、ポリシータイプをご覧ください。

セキュリティ対策についての動画を見る

動画: デベロッパー向けの 4 分間動画(4MV4D)シリーズの脅威対策ポリシーに関する短い動画をご覧ください。

要素リファレンス

要素リファレンスでは、XMLThreatProtection ポリシーの要素と属性について説明します。

<XMLThreatProtection async="false" continueOnError="false" enabled="true" name="XML-Threat-Protection-1">
   <DisplayName>XML Threat Protection 1</DisplayName>
   <NameLimits>
      <Element>10</Element>
      <Attribute>10</Attribute>
      <NamespacePrefix>10</NamespacePrefix>
      <ProcessingInstructionTarget>10</ProcessingInstructionTarget>
   </NameLimits>
   <Source>request</Source>
   <StructureLimits>
      <NodeDepth>5</NodeDepth>
      <AttributeCountPerElement>2</AttributeCountPerElement>
      <NamespaceCountPerElement>3</NamespaceCountPerElement>
      <ChildCount includeComment="true" includeElement="true" includeProcessingInstruction="true" includeText="true">3</ChildCount>
   </StructureLimits>
   <ValueLimits>
      <Text>15</Text>
      <Attribute>10</Attribute>
      <NamespaceURI>10</NamespaceURI>
      <Comment>10</Comment>
      <ProcessingInstructionData>10</ProcessingInstructionData>
   </ValueLimits> 
</XMLThreatProtection>

<XMLThreatProtection> 属性

<XMLThreatProtection async="false" continueOnError="false" enabled="true" name="XML-Threat-Protection-1"> 

次の表に、すべてのポリシーの親要素に共通する属性を示します。

属性 説明 デフォルト 要否
name

ポリシーの内部名。name 属性の値には、英字、数字、スペース、ハイフン、アンダースコア、ピリオドを使用できます。この値は 255 文字を超えることはできません。

管理 UI プロキシ エディタで <DisplayName> 要素を追加して、ポリシーのラベルに使用する別の自然言語名を指定することもできます。

なし 必須
continueOnError

ポリシーが失敗したときにエラーを返す場合は、false に設定します。これは、ほとんどのポリシーで想定される動作です。

ポリシーが失敗した後もフローの実行を続行する場合は、true に設定します。関連項目:

false 省略可
enabled

ポリシーを適用するには、true に設定します。

ポリシーを無効にするには、false に設定します。ポリシーがフローに接続されている場合でも適用されません。

true 省略可
async

この属性は非推奨となりました。

false 非推奨

<DisplayName> 要素

管理 UI プロキシ エディタで name 属性と一緒に使用して、ポリシーのラベルに使用する自然言語名を指定します。

<DisplayName>Policy Display Name</DisplayName>
デフォルト

なし

この要素を省略した場合、ポリシーの name 属性の値が使用されます。

要否 省略可
タイプ 文字列

<NameLimits> 要素

ポリシーで確認して適用する文字数制限を指定します。

<NameLimits>
   <Element>10</Element>
   <Attribute>10</Attribute>
   <NamespacePrefix>10</NamespacePrefix>
   <ProcessingInstructionTarget>10</ProcessingInstructionTarget>     
</NameLimits>
デフォルト: なし
プレゼンス: 省略可
型: なし

<NameLimits>/<Element> 要素

XML ドキュメントの要素名に許可する最大文字数を指定します。

たとえば、次の XML について考えてみましょう。

<book category="WEB">
   <title>Learning XML</title>
   <author>Erik T. Ray</author>
   <year>2003</year>
</book>

上記の XML を分析する場合、以下のポリシー スニペットの <Element> 要素値は、要素名(booktitleauthoryear))が 10 文字以下であることを検証します。

<NameLimits>
   <Element>10</Element>
   <Attribute>10</Attribute>
   <NamespacePrefix>10</NamespacePrefix>
   <ProcessingInstructionTarget>10</ProcessingInstructionTarget>     
</NameLimits>
デフォルト: 制限を指定しない場合、デフォルト値の -1 が適用されます。この値は無制限に相当します。
要否: 省略可
型: 整数

<NameLimits>/<Attribute> 要素

XML ドキュメントの属性名に許可する最大文字数を指定します。

たとえば、次の XML について考えてみましょう。

<book category="WEB">
   <title>Learning XML</title>
   <author>Erik T. Ray</author>
   <year>2003</year>
</book>

上記の XML を分析する場合、以下のポリシー スニペットの <Attribute> 要素値は、属性名 category10 文字以下であることを検証します。

<NameLimits>
   <Element>10</Element>
   <Attribute>10</Attribute>
   <NamespacePrefix>10</NamespacePrefix>
   <ProcessingInstructionTarget>10</ProcessingInstructionTarget>     
</NameLimits>
デフォルト: 制限を指定しない場合、デフォルト値の -1 が適用されます。この値は無制限に相当します。
要否: 省略可
型: 整数

<NameLimits>/<NamespacePrefix> 要素

XML ドキュメントの名前空間の接頭辞に許可する最大文字数を指定します。

たとえば、次の XML について考えてみましょう。

<ns1:myelem xmlns:ns1="http://ns1.com"/>

上記の XML を分析する場合、以下のポリシー スニペットの <NamespacePrefix> 要素値は、名前空間の接頭辞 ns110 文字以下であることを検証します。

<NameLimits>
   <Element>10</Element>
   <Attribute>10</Attribute>
   <NamespacePrefix>10</NamespacePrefix>
   <ProcessingInstructionTarget>10</ProcessingInstructionTarget>     
</NameLimits>
デフォルト: 制限を指定しない場合、デフォルト値の -1 が適用されます。この値は無制限に相当します。
要否: 省略可
型: 整数

<NameLimits>/<ProcessingInstructionTarget> 要素

XML ドキュメントの処理命令のターゲットに許可される最大文字数を指定します。

たとえば、次の XML について考えてみましょう。

<?xml-stylesheet type="text/xsl" href="style.xsl"?>

上記の XML を分析する場合、以下のポリシー スニペットの <ProcessingInstructionTarget> 要素値は、上記の手順のターゲット xml-stylesheet10 文字以下であることを検証します。

<NameLimits>
   <Element>10</Element>
   <Attribute>10</Attribute>
   <NamespacePrefix>10</NamespacePrefix>
   <ProcessingInstructionTarget>10</ProcessingInstructionTarget>     
</NameLimits>
デフォルト: 制限を指定しない場合、デフォルト値の -1 が適用されます。この値は無制限に相当します。
要否: 省略可
型: 整数

<Source> 要素

XML ペイロード攻撃に対してスクリーニングされるメッセージ。通常、クライアント アプリからのインバウンド リクエストを検証する必要があるため、これは一般的に request に設定されます。message に設定すると、この要素ではリクエスト フローに接続されたときにリクエスト メッセージが自動的に評価され、レスポンス フローに接続されたときにレスポンス メッセージが評価されます。

<Source>request</Source>
デフォルト: request
要否: 省略可
型:

文字列。

requestresponsemessage から選択します。

<StructuralLimits> 要素

ポリシーで確認し、適用する構造上の制限を指定します。

<StructureLimits>
   <NodeDepth>5</NodeDepth>
   <AttributeCountPerElement>2</AttributeCountPerElement>
   <NamespaceCountPerElement>3</NamespaceCountPerElement>
   <ChildCount includeComment="true" includeElement="true" includeProcessingInstruction="true" includeText="true">3</ChildCount>
</StructureLimits>
デフォルト: なし
プレゼンス: 省略可
型: なし

<StructuralLimits>/<NodeDepth> 要素

XML で許可される最大ノード深度を指定します。

<StructureLimits>
   <NodeDepth>5</NodeDepth>
   <AttributeCountPerElement>2</AttributeCountPerElement>
   <NamespaceCountPerElement>3</NamespaceCountPerElement>
   <ChildCount includeComment="true" includeElement="true" includeProcessingInstruction="true" includeText="true">3</ChildCount>
</StructureLimits>
デフォルト: 制限を指定しない場合、デフォルト値の -1 が適用されます。この値は無制限に相当します。
要否: 省略可
型:

整数

<StructuralLimits>/<AttributeCountPerElement> 要素

要素で許可される最大属性数を指定します。

たとえば、次の XML について考えてみましょう。

<book category="WEB">
   <title>Learning XML</title>
   <author>Erik T. Ray</author>
   <year>2003</year>
</book>
上記の XML を分析する場合、以下のポリシー スニペットの <AttributeCountPerElement> 要素値は、要素 booktitleauthoryear がそれぞれ 2 属性を超えていないことを検証します。名前空間の定義に使用される属性は対象外です。
<StructureLimits>
   <NodeDepth>5</NodeDepth>
   <AttributeCountPerElement>2</AttributeCountPerElement>
   <NamespaceCountPerElement>3</NamespaceCountPerElement>
   <ChildCount includeComment="true" includeElement="true" includeProcessingInstruction="true" includeText="true">3</ChildCount>
</StructureLimits>
デフォルト: 制限を指定しない場合、デフォルト値の -1 が適用されます。この値は無制限に相当します。
要否: 省略可
型:

整数

<StructuralLimits>/<NameSpaceCountPerElement> 要素

要素で許可される名前空間定義の最大数を指定します。

たとえば、次の XML について考えてみましょう。

<e1 attr1="val1" attr2="val2">
    <e2 xmlns="http://apigee.com" xmlns:yahoo="http://yahoo.com" one="1" yahoo:two="2"/>
</e1>

上記の XML を分析する場合、以下のポリシー スニペットの <NamespaceCountPerElement> 要素値は、要素 e1e2 がそれぞれ 2 名前空間定義を超えていないことを検証します。この場合、<e1> の名前空間定義が 0 個で、<e2> の名前空間定義が 2 個(xmlns="http://apigee.com"xmlns:yahoo="http://yahoo.com")です。

<StructureLimits>
   <NodeDepth>5</NodeDepth>
   <AttributeCountPerElement>2</AttributeCountPerElement>
   <NamespaceCountPerElement>3</NamespaceCountPerElement>
   <ChildCount includeComment="true" includeElement="true" includeProcessingInstruction="true" includeText="true">3</ChildCount>
</StructureLimits>
デフォルト: 制限を指定しない場合、デフォルト値の -1 が適用されます。この値は無制限に相当します。
要否: 省略可
型:

整数

<StructuralLimits>/<ChildCount> 要素

要素で許可される子要素の最大数を指定します。

<StructureLimits>
   <NodeDepth>5</NodeDepth>
   <AttributeCountPerElement>2</AttributeCountPerElement>
   <NamespaceCountPerElement>3</NamespaceCountPerElement>
   <ChildCount includeComment="true" includeElement="true" includeProcessingInstruction="true" includeText="true">3</ChildCount>
</StructureLimits>
デフォルト: 制限を指定しない場合、デフォルト値の -1 が適用されます。この値は無制限に相当します。
要否: 省略可
型:

整数

属性

属性 デフォルト 要否
includeComment true 省略可
includeElement true 省略可
includeProcessingInstructions true 省略可
includeText true 省略可

<ValueLimits> 要素

ポリシーで確認して適用する値の文字数制限を指定します。

<ValueLimits>
   <Text>15</Text>
   <Attribute>10</Attribute>
   <NamespaceURI>10</NamespaceURI>
   <Comment>10</Comment>
   <ProcessingInstructionData>10</ProcessingInstructionData>
</ValueLimits>
デフォルト: なし
プレゼンス: 省略可
型:

なし

<ValueLimits>/<Text> 要素

XML ドキュメントのテキストノードの文字数制限を指定します。

たとえば、次の XML について考えてみましょう。

<book category="WEB">
   <title>Learning XML</title>
   <author>Erik T. Ray</author>
   <year>2003</year>
</book>
上記の XML を分析する場合、以下のポリシー スニペットの <Text> 要素値は、要素テキスト値 Learning XMLErik T. Ray,2003 がそれぞれ 15 文字以下であることを検証します。
<ValueLimits>
   <Text>15</Text>
   <Attribute>10</Attribute>
   <NamespaceURI>10</NamespaceURI>
   <Comment>10</Comment>
   <ProcessingInstructionData>10</ProcessingInstructionData>
</ValueLimits>
デフォルト: 制限を指定しない場合、デフォルト値の -1 が適用されます。この値は無制限に相当します。
要否: 省略可
型:

整数

<ValueLimits>/<Attribute> 要素

XML ドキュメントの属性値も文字数制限を指定します。

たとえば、次の XML について考えてみましょう。

<book category="WEB">
   <title>Learning XML</title>
   <author>Erik T. Ray</author>
   <year>2003</year>
</book>
上記の XML を分析する場合、以下のポリシー スニペットの <Attribute> 要素値は、属性値 WEB10 文字以下であることを検証します。
<ValueLimits>
   <Text>15</Text>
   <Attribute>10</Attribute>
   <NamespaceURI>10</NamespaceURI>
   <Comment>10</Comment>
   <ProcessingInstructionData>10</ProcessingInstructionData>
</ValueLimits>
デフォルト: 制限を指定しない場合、デフォルト値の -1 が適用されます。この値は無制限に相当します。
要否: 省略可
型:

整数

<ValueLimits>/<NamespaceURI> 要素

XML ドキュメントの名前空間 URI の文字数制限を指定します。

たとえば、次の XML について考えてみましょう。

<ns1:myelem xmlns:ns1="http://ns1.com"/>
上記の XML を分析する場合、以下のポリシー スニペットの <NamespaceURI> 要素値は、名前空間 URI 値 http://ns1.com10 文字以下であることを検証します。
<ValueLimits>
   <Text>15</Text>
   <Attribute>10</Attribute>
   <NamespaceURI>10</NamespaceURI>
   <Comment>10</Comment>
   <ProcessingInstructionData>10</ProcessingInstructionData>
</ValueLimits>
デフォルト: 制限を指定しない場合、デフォルト値の -1 が適用されます。この値は無制限に相当します。
要否: 省略可
型:

整数

<ValueLimits>/<Comment> 要素

XML ドキュメントのコメントの文字数制限を指定します。

たとえば、次の XML について考えてみましょう。

<book category="WEB">
   <!-- This is a comment -->
   <title>Learning XML</title>
   <author>Erik T. Ray</author>
   <year>2003</year>
</book>
上記の XML を分析する場合、以下のポリシー スニペットの <Comment> 要素値は、コメントのテキスト This is a comment10 文字以下であることを検証します。
<ValueLimits>
   <Text>15</Text>
   <Attribute>10</Attribute>
   <NamespaceURI>10</NamespaceURI>
   <Comment>10</Comment>
   <ProcessingInstructionData>10</ProcessingInstructionData>
</ValueLimits>
デフォルト: 制限を指定しない場合、デフォルト値の -1 が適用されます。この値は無制限に相当します。
要否: 省略可
型:

整数

<ValueLimits>/<ProcessingInstructionData> 要素

XML ドキュメントの処理命令テキストの文字数制限を指定します。

たとえば、次の XML について考えてみましょう。

<?xml-stylesheet type="text/xsl" href="style.xsl"?>
上記の XML を分析する場合、以下のポリシー スニペットの <ProcessingInstructionData> 要素値は、上記の手順のテキスト type="text/xsl" href="style.xsl"10 文字以下であることを検証します。
<ValueLimits>
   <Text>15</Text>
   <Attribute>10</Attribute>
   <NamespaceURI>10</NamespaceURI>
   <Comment>10</Comment>
   <ProcessingInstructionData>10</ProcessingInstructionData>
</ValueLimits>
デフォルト: 制限を指定しない場合、デフォルト値の -1 が適用されます。この値は無制限に相当します。
要否: 省略可
型:

整数

エラー リファレンス

This section describes the fault codes and error messages that are returned and fault variables that are set by Apigee when this policy triggers an error. This information is important to know if you are developing fault rules to handle faults. To learn more, see What you need to know about policy errors and Handling faults.

Runtime errors

These errors can occur when the policy executes.

Fault code HTTP status Cause Fix
steps.xmlthreatprotection.ExecutionFailed 500 The XMLThreatProtection policy can throw many different types of ExecutionFailed errors. Most of these errors occur when a specific threshold set in the policy is exceeded. These types of errors include: element name length, child count, node depth, attribute count, attribute name length, and many others. You can see the complete list in the XMLThreatProtection policy runtime error troubleshooting topic.
steps.xmlthreatprotection.InvalidXMLPayload 500 This error occurs if the input message payload specified by the XMLThreatProtection policy's <Source> element is not a valid XML Document.
steps.xmlthreatprotection.SourceUnavailable 500 This error occurs if the message variable specified in the <Source> element is either:
  • Out of scope (not available in the specific flow where the policy is being executed)
  • Is not one of the valid values request, response, or message
steps.xmlthreatprotection.NonMessageVariable 500 This error occurs if the <Source> element is set to a variable which is not of type message.

Deployment errors

None.

Fault variables

These variables are set when a runtime error occurs. For more information, see What you need to know about policy errors.

Variables Where Example
fault.name="fault_name" fault_name is the name of the fault, as listed in the Runtime errors table above. The fault name is the last part of the fault code. fault.name Matches "SourceUnavailable"
xmlattack.policy_name.failed policy_name is the user-specified name of the policy that threw the fault. xmlattack.XPT-SecureRequest.failed = true

Example error response

{
  "fault": {
    "faultstring": "XMLThreatProtection[XPT-SecureRequest]: Execution failed. reason: XMLThreatProtection[XTP-SecureRequest]: Exceeded object entry name length at line 2",
    "detail": {
      "errorcode": "steps.xmlthreatprotection.ExecutionFailed"
    }
  }
}

Example fault rule

<FaultRule name="XML Threat Protection Policy Faults">
    <Step>
        <Name>AM-CustomErrorResponse</Name>
        <Condition>(fault.name Matches "ExecutionFailed") </Condition>
    </Step>
    <Condition>(xmlattack.XPT-SecureRequest.failed = true) </Condition>
</FaultRule>

スキーマ

使用上の注意

意図的なものかどうかは関係なく、オンライン データを受信するサーバーは攻撃を受ける可能性があります。XML の柔軟性に目を付け、無効なドキュメントを作成してバックエンド システムへの侵入を試みる攻撃も発生しています。破損している XML ドキュメントや非常に複雑な XML ドキュメントにより、サーバーの負荷が増大し、CPU やメモリリソースの不足により、パーサーがクラッシュする可能性があります。また、メッセージ処理が不能になり、アプリケーション レベルでのサービス拒否状態になる可能性もあります。

脅威対策のエラー構成

このポリシーの FaultRules を作成する場合の重要な情報: デフォルトでは、メッセージが JSON または XML の脅威対策ポリシーに一致しない場合、HTTP 500 Internal Server Error(内部サーバーエラー)のステータス コードと ExecutionFailed エラーコードがスローされます。このエラー動作を変更するには、新しい組織レベルのプロパティを使用します。組織プロパティ features.isPolicyHttpStatusEnabled を true に設定すると、次のように動作します。

  • リクエスト: リクエスト フローに脅威保護ポリシーが関連付けられている場合、無効なメッセージは 400 Bad Request(不正なリクエスト)ステータス コードと、対応するポリシー エラー コード(ExecutionFailed のみ)を返します。
  • レスポンス: レスポンス フローに適用された脅威対策ポリシーにより、無効なメッセージであっても 500 内部サーバーエラー ステータス コードが返され、ExecutionFailed だけでなく、対応するポリシー エラーコードのいずれかがスローされます。

Cloud のお客様は、Google Cloud カスタマーケアに連絡して組織のプロパティを設定する必要があります。

curl -u email:password -X POST -H "Content-type:application/xml" http://host:8080/v1/o/myorg -d \
"<Organization type="trial" name="MyOrganization">
    <Environments/>
    <Properties>
        <Property name="features.isPolicyHttpStatusEnabled">true</Property>
        ...
    </Properties>
</Organization>"

関連トピック

JSONThreatProtection ポリシー

RegularExpressionProtection ポリシー