> ## Documentation Index
> Fetch the complete documentation index at: https://auth0.generaltranslation.app/llms.txt
> Use this file to discover all available pages before exploring further.

# アプリケーションなりすましへの対策

ネイティブアプリケーションは [Authorization Code Flow with PKCE](/docs/ja-JP/get-started/authentication-and-authorization-flow/authorization-code-flow-with-pkce) 認証フローを使用し、ログイン後にアプリケーションへ制御を戻すために `redirect_uri` を利用します。URI がデバイスのブラウザーで読み込まれた後、アプリケーションは通常自動的に起動し、ユーザーが操作を続行できるようにします。

従来、モバイルアプリケーションは [カスタム URI スキーム](https://developers.google.com/identity/protocols/oauth2/native-app#installed_app_redirect_methods)（例: `com.mycompany.myapp://oauth2redirect`）を使用していました。しかし、カスタム URI スキームには、同一のスキームをデバイス上の複数のアプリケーションが登録できるというリスクがあります。モバイル OS には、リダイレクトを受け取るアプリケーションが意図したものであることを保証するための仕組みが組み込まれていません。この状況では、不正なアプリが正規のアプリになりすまして認可レスポンス（トークンを含む）を受け取る可能性があります。特に、以前の正規セッションが存在することでシングルサインオン (SSO) が有効になっており、追加のユーザー操作が不要な場合に顕著です。PKCE は、このようなシナリオでは実質的に有効ではありません。不正なアプリケーションがログインフローを開始し、ユーザー操作なしでコールバックを受け取るのを待つことができてしまうためです。

ローカルマシン上で動作するアプリケーション（例: デスクトップアプリ、CLI）は、コールバックにループバックインターフェース（例: [http://127.0.0.1:51089/callback](http://127.0.0.1:51089/callback) や [http://localhost:61024/callback）を使用するため、同様のリスクがあります。この場合、同じマシン上の別のアプリケーションが同じポートで待ち受けてレスポンスを傍受する可能性があります。](http://localhost:61024/callback）を使用するため、同様のリスクがあります。この場合、同じマシン上の別のアプリケーションが同じポートで待ち受けてレスポンスを傍受する可能性があります。)

カスタム URI スキームとループバック URI の両方を総称して、「Non-Verifiable Callback URIs（検証不能なコールバック URI）」と呼びます。これは、どちらのシナリオにおいても、認可サーバーがレスポンスを受信するアプリケーションを検証できないためです。

<div id="recommended-mitigations-for-mobile-applications">
  ## モバイルアプリケーション向けの推奨対策
</div>

<div id="claimed-https-uris-universal-links-app-links">
  ### クレーム済み HTTPS URI（Universal Links / App Links）
</div>

最新のモバイル OS は **クレーム済み HTTPS URI** をサポートしており、管理しているウェブサイトのドメインをモバイルアプリと関連付けることができます。クレーム済み HTTPS URI は、次のように呼ばれます。

* iOS では Universal Links
* Android では App Links

クレーム済み HTTPS URI を使用すると、関連付けられたコールバック URL を処理できるのが該当するアプリケーションのみとなり、機密性の高い認証データへの不正アクセスを防ぐことができます。

<Note>
  Auth0 は、すべてのネイティブアプリケーションのリダイレクト URI としてクレーム済み HTTPS URI を使用することを**強く推奨**します。

  * iOS の場合: [Support Universal Links](https://developer.apple.com/documentation/xcode/allowing-apps-and-websites-to-link-to-your-content/#Support-universal-links) を参照してください。
  * Android の場合: [Android App Links](https://developer.android.com/training/app-links#android-app-links) を参照してください。
</Note>

<div id="recommended-mitigations-for-all-application">
  ## すべてのアプリケーションに推奨される対策
</div>

次のいずれかに該当する場合、Auth0 は認証トランザクション結果を受け取るアプリケーションの正当性を検証できません。

* 古いモバイル OS バージョンとの互換性要件により、アプリケーションが申告した HTTPS URI をサポートできない場合
* アプリケーションがデスクトップまたは CLI アプリケーションである場合

[OAuth2 for Native Apps](https://datatracker.ietf.org/doc/html/rfc8252#section-8.6) 仕様で定義されているとおり、Auth0 はユーザーに確認プロンプトを表示する仕組みを提供します。ユーザーは、認証結果を受け取るアプリケーションが、自分がアクセスしようとしていたアプリケーションであることを確認します。検証不可能なコールバック URI が使用されている場合、ユーザーは認証トランザクションごとにアプリケーションの確認を求められます。

確認画面が表示されるのは次のような場合です。

1. リクエストに含まれる `redirect_uri` が、検証不可能な URI（カスタム URI スキームやループバック URI など）を使用している場合。
2. 現在のログイントランザクションにおいて、ユーザーに他のいずれの画面もまだ表示されていない場合（サードパーティ アプリケーション向けの [同意画面](/docs/ja-JP/get-started/applications/confidential-and-public-applications/user-consent-and-third-party-applications) が表示される場合や、MFA（多要素認証）が必要な場合など）。

これらの場合、アプリケーションはエンドユーザーに確認プロンプトを提示します。

<Frame>
  <img src="https://mintcdn.com/generaltranslationinc/GMqg_oKRfWVB3GIg/docs/images/cdy7uua7fh8z/consent-pompt-uris.png?fit=max&auto=format&n=GMqg_oKRfWVB3GIg&q=85&s=0a6c5cda8459f314336e69842bb7ecd6" alt="アプリなりすまし対策 - 確認プロンプト" width="298" height="408" data-path="docs/images/cdy7uua7fh8z/consent-pompt-uris.png" />
</Frame>

この確認プロンプトは、レガシーの非 OIDC 準拠フローでは表示されません。テナントおよびアプリケーションに対して保護を強化する方法については、[OIDC 準拠認証の採用](/docs/ja-JP/authenticate/login/oidc-conformant-authentication)を参照してください。

<div id="prompt-customization">
  #### プロンプトのカスタマイズ
</div>

確認プロンプトには、既存のサードパーティ アプリケーション向けの同意画面で使用されているカスタムブランディングと設定が適用されます。詳細については、[Customize Universal Login Page Templates](/docs/ja-JP/customize/login-pages/universal-login/customize-templates) の **Prompts** セクションを参照してください。

<Warning>
  Auth0 は、本番環境ではこの保護を無効にしないことを**強く推奨します**。デバイス上の悪意のあるアプリケーションが、ユーザーの操作やその他の気づける兆候が一切ないまま `id_tokens` や `access_tokens` を要求できてしまう可能性があります。
</Warning>

確認プロンプトは、グローバルなテナント設定、またはアプリケーションレベルで構成できます。アプリケーションレベルの設定は、グローバルなテナントレベルの設定より優先されます。

**アプリケーションレベル**

1. [Auth0 Dashboard > Applications > Application Settings > Advanced > OAuth](https://manage.auth0.com/#/applications/settings) に移動します。
2. **Non-Verifiable Callback URI End-User Confirmation** 設定までスクロールします。
3. トグルをオンにしてプロンプトを有効にするか、トグルをオフにしてプロンプトを無効にします。

<Frame>
  <img src="https://mintcdn.com/generaltranslationinc/GMqg_oKRfWVB3GIg/docs/images/cdy7uua7fh8z/custom-uri-override.png?fit=max&auto=format&n=GMqg_oKRfWVB3GIg&q=85&s=2a439951f06eec606cd62ff673ae099a" alt="Auth0 Dashboard>Settings>Advanced" data-og-width="602" width="602" data-og-height="227" height="227" data-path="docs/images/cdy7uua7fh8z/custom-uri-override.png" data-optimize="true" data-opv="3" srcset="https://mintcdn.com/generaltranslationinc/GMqg_oKRfWVB3GIg/docs/images/cdy7uua7fh8z/custom-uri-override.png?w=280&fit=max&auto=format&n=GMqg_oKRfWVB3GIg&q=85&s=de50bf7222a3d002f75820462cc042a5 280w, https://mintcdn.com/generaltranslationinc/GMqg_oKRfWVB3GIg/docs/images/cdy7uua7fh8z/custom-uri-override.png?w=560&fit=max&auto=format&n=GMqg_oKRfWVB3GIg&q=85&s=7a7bb5f203d44e63bad0c31649184c16 560w, https://mintcdn.com/generaltranslationinc/GMqg_oKRfWVB3GIg/docs/images/cdy7uua7fh8z/custom-uri-override.png?w=840&fit=max&auto=format&n=GMqg_oKRfWVB3GIg&q=85&s=fbdfc3ff09f1e0bc04c4969976eed442 840w, https://mintcdn.com/generaltranslationinc/GMqg_oKRfWVB3GIg/docs/images/cdy7uua7fh8z/custom-uri-override.png?w=1100&fit=max&auto=format&n=GMqg_oKRfWVB3GIg&q=85&s=cee46c89ab26eae4cc5bf4682c6fa4c0 1100w, https://mintcdn.com/generaltranslationinc/GMqg_oKRfWVB3GIg/docs/images/cdy7uua7fh8z/custom-uri-override.png?w=1650&fit=max&auto=format&n=GMqg_oKRfWVB3GIg&q=85&s=b8dbf53f6c9d87ef168c80b9ce74f89b 1650w, https://mintcdn.com/generaltranslationinc/GMqg_oKRfWVB3GIg/docs/images/cdy7uua7fh8z/custom-uri-override.png?w=2500&fit=max&auto=format&n=GMqg_oKRfWVB3GIg&q=85&s=97f157c3dd8583d8925881eb833ea05e 2500w" />
</Frame>

**グローバル**

1. [Auth0 Dashboard > Settings > Advanced](https://manage.auth0.com/#/tenant/advanced) に移動します。
2. **Non-Verifiable Callback URI End-User Confirmation** 設定を探します。
3. トグルをオンにしてプロンプトを無効にするか、トグルをオフにしてプロンプトを有効にします。

<Frame>
  <img src="https://mintcdn.com/generaltranslationinc/md6b8ua1hdYa2pM7/docs/images/cdy7uua7fh8z/skip-custom-uri.png?fit=max&auto=format&n=md6b8ua1hdYa2pM7&q=85&s=a3ec41f07f5da076fdec8ba3aaa144b4" alt="Auth0 Dashboard>Tenant Settings>Advanced>Skip Custom URI toggle" data-og-width="500" width="500" data-og-height="99" height="99" data-path="docs/images/cdy7uua7fh8z/skip-custom-uri.png" data-optimize="true" data-opv="3" srcset="https://mintcdn.com/generaltranslationinc/md6b8ua1hdYa2pM7/docs/images/cdy7uua7fh8z/skip-custom-uri.png?w=280&fit=max&auto=format&n=md6b8ua1hdYa2pM7&q=85&s=d8a773a8f83e62cf0ac56421c3e572b3 280w, https://mintcdn.com/generaltranslationinc/md6b8ua1hdYa2pM7/docs/images/cdy7uua7fh8z/skip-custom-uri.png?w=560&fit=max&auto=format&n=md6b8ua1hdYa2pM7&q=85&s=63c4decf24e48f0a81b25d8c1ca5ee9c 560w, https://mintcdn.com/generaltranslationinc/md6b8ua1hdYa2pM7/docs/images/cdy7uua7fh8z/skip-custom-uri.png?w=840&fit=max&auto=format&n=md6b8ua1hdYa2pM7&q=85&s=a959ba91978b6e386bf55f963620fd47 840w, https://mintcdn.com/generaltranslationinc/md6b8ua1hdYa2pM7/docs/images/cdy7uua7fh8z/skip-custom-uri.png?w=1100&fit=max&auto=format&n=md6b8ua1hdYa2pM7&q=85&s=b9f5a289f8d96a3a34afd27e477c6235 1100w, https://mintcdn.com/generaltranslationinc/md6b8ua1hdYa2pM7/docs/images/cdy7uua7fh8z/skip-custom-uri.png?w=1650&fit=max&auto=format&n=md6b8ua1hdYa2pM7&q=85&s=11a8bce021c50525c050aa10df4209cc 1650w, https://mintcdn.com/generaltranslationinc/md6b8ua1hdYa2pM7/docs/images/cdy7uua7fh8z/skip-custom-uri.png?w=2500&fit=max&auto=format&n=md6b8ua1hdYa2pM7&q=85&s=c91726541f04129c6937656d6e916a22 2500w" />
</Frame>
