アカウントの乗っ取りの検出と阻止

このページでは、reCAPTCHA を使用してアカウントの乗っ取り(ATO)を検出して阻止する方法について説明します。

ATO 攻撃は通常、攻撃者がデータ侵害(パスワード ダンプとも呼ばれる)から取得された認証情報を使用して API エンドポイントへのログイン リクエストを送信した場合に発生します。人は複数のアカウントでパスワードを再利用する傾向があるため、パスワードダンプが無関係のサイトからのものであっても、このタイプの攻撃は成功する可能性があります。このタイプの攻撃は、パスワード マネージャーの使用など、適切なパスワードの衛生管理を行うユーザーに対しては影響しません。

始める前に

reCAPTCHA 用に環境を準備します

ATO の検出と阻止

reCAPTCHA では、次のいずれかのオプションを使用して ATO を検出して阻止できます。

「私はロボットではありません」チェックボックスを使用する

[私はロボットではありません] チェックボックスの追加は、SMS やメールの検証などの追加機能を構築することなく、ATO に対する保護が得られる最も速くて簡単な方法です。攻撃者がこの保護を破るにはコストがかかります。サイトによっては、このオプションで十分です。

ウェブページに「私はロボットではありません」チェックボックスを追加します

チェックボックスを使用したシンプルなログイン ページの実例を以下のコードに示します。

function onSuccess(token) {
  // The token is included in the POST data in the g-recaptcha-response
  // parameter. The backend must create an Assessment with the token
  // and verify the token is valid.
  console.log(token);
}
<form id="loginForm" action="?" method="POST">
  Username: <input type="text" name="username"/><br/>
  Password: <input type="password" name="password"/><br/>
  <div class="g-recaptcha" data-sitekey="reCATCHA_sitekey"
       data-action="account_login" data-callback="onSuccess"></div>
</form>
<script src="https://www.google.com/recaptcha/enterprise.js" async defer></script>

コード ウィンドウの右上にある <> アイコンをクリックすると、JSFiddle でこのコードを試すことができます。

<html>
  <head>
    <title>Account Login - Checkbox</title>
    <script src="https://www.google.com/recaptcha/enterprise.js" async defer></script>
    <script>
    function onSuccess(token) {
      // The token is included in the POST data in the g-recaptcha-response
      // parameter. The backend must create an Assessment with the token
      // and verify the token is valid.
      console.log(token);
    }
    </script>
  </head>
  <body>
    <form id="loginForm" action="?" method="POST">
      Username: <input type="text" name="username"/><br/>
      Password: <input type="password" name="password"/><br/>
      <div class="g-recaptcha" data-sitekey="6LeAkOgUAAAAACcy3uY6N9H9SJMS27n3Zx2OOnYK"
           data-action="account_login" data-callback="onSuccess"></div>
    </form>
  </body>
</html>

スコアとカスタム チャレンジを使用する

ATO から保護するには、reCAPTCHA スコアベースのキーを使用して、ワンタイム コード(OTP)をユーザーに送信するメールや SMS によるチャレンジなどの多要素認証(MFA)チャレンジを使用します。

スコアベースのキーとカスタム チャレンジを使用するには、次のオプションを検討してください。

ユースケースに応じて、MFA 単独で使用することも、スコアベースのキーと組み合わせて使用することもできます。たとえば、摩擦を減らすためにスコアが特定のしきい値を下回る場合にのみ、MFA チャレンジを使用することをおすすめします。

次の例は、スコアベースのキーをログイン シナリオに統合する方法を示しています。

function submitForm() {
  grecaptcha.enterprise.ready(function() {
    grecaptcha.enterprise.execute(
      'reCAPTCHA_site_key', {action: 'account_login'}).then(function(token) {
       document.getElementById("token").value = token;
       document.getElementByID("loginForm").submit();
    });
  });
}
<form id="loginForm" action="?" method="POST">
  Username: <input type="text" name="username"/><br/>
  Password: <input type="password" name="password"/><br/>
  <input type="hidden" id="token" name="recaptcha_token"/>
  <button onclick="submitForm()">Login</button>
</form>
<script src="https://www.google.com/recaptcha/enterprise.js" async defer></script>

コード ウィンドウの右上にある <> アイコンをクリックすると、JSFiddle でこのコードを試すことができます。

<html>
  <head>
    <title>Account Login - Score</title>
    <script src="https://www.google.com/recaptcha/enterprise.js" async defer></script>
    <script>
    function submitForm() {
      grecaptcha.enterprise.ready(function() {
        grecaptcha.enterprise.execute(
          'reCAPTCHA_site_key', {action: 'account_login'}).then(function(token) {
           document.getElementById("token").value = token;
           document.getElementByID("loginForm").submit();
        });
      });
    }
    </script>
  </head>
  <body>
    <form id="loginForm" action="?" method="POST">
      Username: <input type="text" name="username"/><br/>
      Password: <input type="password" name="password"/><br/>
      <input type="hidden" id="token" name="recaptcha_token"/>
      <button onclick="submitForm()">Login</button>
    </form>
  </body>
</html>

次のステップ