メインコンテンツへスキップ
なりすまし攻撃やリプレイ攻撃 (subject_token を不正に侵害または再利用しようとする試行) を防ぐため、Custom Token Exchange は Suspicious IP Throttling をサポートしています。これにより、Actions コード内で subject_token が無効であることを示せるため、Auth0 はその外部 IP から送信された失敗試行の回数をカウントできます。 ある IP アドレスからの失敗試行回数が事前設定されたしきい値に達すると、Auth0 はその IP からの Custom Token Exchange リクエストを、次のエラーでブロックします。
HTTP/1.1 429 Too Many Requests
Content-Type: application/json
{
    "error": "too_many_attempts",
    "error_description": "We have detected suspicious login behavior and further attempts will be blocked. Please contact the administrator."
}
IP アドレスは、設定された一定時間が経過すると再びリクエストを送信できるようになります。 すべての Custom Token Exchange のユースケース、特にネイティブアプリケーションおよびシングルページアプリケーション (SPA) では、Suspicious IP Throttling を使用することを推奨します。ネイティブアプリケーションや SPA などの非機密アプリケーションは、自身を認証するためのシークレットを安全に保存できないため、攻撃者は盗難または漏えいしたサブジェクトトークンをより容易に再利用できます。
Suspicious IP Throttling 保護を実装するには、受信したサブジェクトトークンが十分に検証を通過しなかった場合に、Actions コードで api.access.rejectInvalidSubjectToken を使用します。
Suspicious IP Throttling は、Auth0 テナントでデフォルトで有効化されています。有効化されている場合、Custom Token Exchange には次のデフォルト設定が適用されます。
  • しきい値: 10。IP アドレスごとに許可される失敗試行の最大回数です。
  • スロットリングレート: 1 時間あたり 6 回。しきい値が回復するまで、10 分ごとに追加の試行が 1 回可能になります。

Custom Token Exchange の Suspicious IP Throttling を設定する

Management API を使用して、Custom Token Exchange のカスタムしきい値とスロットリングレートを設定できます。 まず、API を利用するために Management API トークンを取得 します。次に、Get Suspicious IP Throttling settings endpoint に対して、次の GET リクエストを実行します。
curl --location 'https://{yourDomain}/api/v2/attack-protection/suspicious-ip-throttling' \
--header 'Authorization: Bearer <YOUR_MANAGEMENT_API_TOKEN>' \
以下のようなレスポンスが返されます。
{
  "enabled": true,
  "shields": [
    "admin_notification",
    "block"
  ],
  "allowlist": [],
  "stage": {
    "pre-login": {
      "max_attempts": 100,
      "rate": 864000
    },
    "pre-user-registration": {
      "max_attempts": 50,
      "rate": 1200
    },
    "pre-custom-token-exchange": {
      "max_attempts": 10,
      "rate": 600000
    }
  }
}
次のPATCHリクエストを使用して、pre-custom-token-exchangeステージを必要な値で更新します。なお、レートは新しい試行が許可される時間間隔をミリ秒単位で指定します。
curl --location --request PATCH 'https://{yourDomain}/api/v2//attack-protection/suspicious-ip-throttling' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <YOUR_MANAGEMENT_API_TOKEN>' \
--data '{"stage":{"pre-custom-token-exchange":{"max_attempts":10,"rate":600000}}}'