JSONThreatProtection ポリシー

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

Apigee Edge のドキュメントはこちらをご覧ください。

ポリシー アイコン

内容

配列や文字列など JSON のさまざまな構造に制限を指定して、内容レベルの攻撃によるリスクを最小限に抑えます。

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

動画: JSONThreatProtection ポリシーでコンテンツ レベルの攻撃から API を保護する方法の詳細については、短い動画をご覧ください。

動画: Apigee クロスクラウド API プラットフォームに関する短い動画をご覧ください。

要素リファレンス

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

<JSONThreatProtection async="false" continueOnError="false" enabled="true" name="JSON-Threat-Protection-1">
   <DisplayName>JSONThreatProtection 1</DisplayName>
   <ArrayElementCount>20</ArrayElementCount>
   <ContainerDepth>10</ContainerDepth>
   <ObjectEntryCount>15</ObjectEntryCount>
   <ObjectEntryNameLength>50</ObjectEntryNameLength>
   <Source>request</Source>
   <StringValueLength>500</StringValueLength>
</JSONThreatProtection>

<JSONThreatProtection> 属性

<JSONThreatProtection async="false" continueOnError="false" enabled="true" name="JSON-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 属性の値が使用されます。

要否 省略可
タイプ 文字列

<ArrayElementCount> 要素

配列の最大要素数を指定します。

<ArrayElementCount>20</ArrayElementCount>
デフォルト: この要素を指定しないか、負の整数を指定した場合、システムは制限を適用しません。
要否: 省略可
型: 整数

<ContainerDepth> 要素

コンテナ(オブジェクトか配列)の入れ子の深さの最大値を指定します。たとえば、オブジェクトを入れたオブジェクトの配列は、深さ 3 です。

<ContainerDepth>10</ContainerDepth>
デフォルト: この要素を指定しないか、負の整数を指定した場合、システムはいかなる制限も適用しません。
要否: 省略可
型: 整数

<ObjectEntryCount> 要素

オブジェクトに許可される最大エントリ数を指定します。

<ObjectEntryCount>15</ObjectEntryCount>
デフォルト: この要素を指定しないか、負の整数を指定した場合、システムはいかなる制限も適用しません。
要否: 省略可
型: 整数

<ObjectEntryNameLength> 要素

オブジェクトのプロパティ名の最大文字列長を指定します。

<ObjectEntryNameLength>50</ObjectEntryNameLength>
デフォルト: この要素を指定しないか、負の整数を指定した場合、システムは制限を適用しません。
要否: 省略可
型: 整数

<Source> 要素

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

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

文字列。

(有効な値: request、response、message)

<StringValueLength> 要素

文字列の最大長を指定します。

<StringValueLength>500</StringValueLength>
デフォルト: この要素を指定しないか、負の整数を指定した場合、システムは制限を適用しません。
要否: 省略可
型: 整数

エラー リファレンス

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.jsonthreatprotection.ExecutionFailed 500 The JSONThreatProtection 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: object entry name length, object entry count, array element count, container depth, string string value length. This error also occurs when the payload contains an invalid JSON object.
steps.jsonthreatprotection.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.jsonthreatprotection.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 this policy triggers an error. 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"
jsonattack.policy_name.failed policy_name is the user-specified name of the policy that threw the fault. jsonattack.JTP-SecureRequest.failed = true

Example error response

{
  "fault": {
    "faultstring": "JSONThreatProtection[JPT-SecureRequest]: Execution failed. reason: JSONThreatProtection[JTP-SecureRequest]: Exceeded object entry name length at line 2",
    "detail": {
      "errorcode": "steps.jsonthreatprotection.ExecutionFailed"
    }
  }
}

Example fault rule

<FaultRule name="JSONThreatProtection Policy Faults">
    <Step>
        <Name>AM-CustomErrorResponse</Name>
        <Condition>(fault.name Matches "ExecutionFailed") </Condition>
    </Step>
    <Condition>(jsonattack.JPT-SecureRequest.failed = true) </Condition>
</FaultRule>

スキーマ

使用上の注意

XML ベースのサービスのように、JSON(JavaScript Object Notation)をサポートする API は、コンテンツ レベルの攻撃に対して脆弱です。単純な JSON 攻撃では、JSON パーサーに過剰な負荷をかける構造を使用してサービスをクラッシュさせ、アプリケーション レベルの DoS 攻撃を引き起こそうとします。どの設定も省略可能で、潜在的な脆弱性に対するサービス要件を最適化するよう調整する必要があります。

関連トピック

JSONtoXML ポリシー

XMLThreatProtection ポリシー

RegularExpressionProtection ポリシー