コンテンツにスキップ

Index

安全でないネットワーク構成設定

説明

Androidのネットワークセキュリティ構成 (Network Security Configuration) を使用すると、アプリケーションのネットワークセキュリティを宣言的に設定できます。

Androidのネットワークセキュリティ構成が欠落しているか、安全でない方法で構成されている場合、アプリケーションがMiTM攻撃に対して脆弱になる可能性があります。

推奨事項

Androidのネットワークセキュリティ構成は、アプリケーションのネットワークセキュリティの宣言的な設定を可能にするXMLファイルです。

アプリケーションにネットワークセキュリティ構成を追加する:

1- アプリの res/xml ディレクトリに新しいXMLファイルを作成します。network_security_config.xml または他の適切な名前を付けます。 2- セキュリティ構成を定義します。以下の例を参照してください。 3- マニフェストに構成を適用します。

<application
        android:networkSecurityConfig="@xml/network_security_config"
        <!-- Other attributes -->
        >
        <!-- Other configurations -->
</application>  

ネットワークセキュリティ構成の例

  • デバッグ専用設定をサポートするカスタム認証局
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <debug-overrides>
        <trust-anchors>
            <certificates src="@raw/debug_cas"/>
        </trust-anchors>
    </debug-overrides>
</network-security-config>
  • クリアテキストトラフィックの宣言的オプトアウト
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <domain-config cleartextTrafficPermitted="false">
        <domain includeSubdomains="true">secure.example.com</domain>
    </domain-config>
</network-security-config>
  • 証明書のピン留めキーの宣言的設定
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <domain-config>
        <domain includeSubdomains="true">example.com</domain>
        <pin-set expiration="2018-01-01">
            <pin digest="SHA-256">7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y=</pin>
            <!-- backup pin -->
            <pin digest="SHA-256">fwza0LRMXouZHRC8Ei+4PyuldPDcf3UKgO/04cDM1oE=</pin>
        </pin-set>
    </domain-config>
</network-security-config>

リンク

基準

  • OWASP_MASVS_L1:
    • MSTG_NETWORK_1
  • OWASP_MASVS_v2_1:
    • MASVS_NETWORK_1
  • HIPAA_CONTROLS:
    • SECURITY252
    • SECURITY212
    • SECURITY213
  • OWASP_MASVS_L2:
    • MSTG_NETWORK_1
  • PCI_STANDARDS:
    • REQ_1_2
    • REQ_2_2
  • CNIL_FOR_DEVELOPERS:
    • DEVELOPERS_4_1_4