> For the complete documentation index, see [llms.txt](https://docs.payments.thalescloud.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.payments.thalescloud.io/classic-push-provisioning/ja/gaido/sekyuritigaidorain/ios.md).

# iOS

### iOS01. 機微なデータ漏洩の防止 <a href="#ios01-preventing-sensitive-data-leaks" id="ios01-preventing-sensitive-data-leaks"></a>

アプリケーションのライフサイクルで機微なデータを管理するために、次の方法を使用してください：

* `applicationWillResignActive`：画面をクリアし、表示されている機微なデータを暗号化します。表示をクリアするには、次のコードを使用して表示コンテンツを非表示にできます：

```
UIApplication.shared.keyWindow.hidden = true
```

* `applicationDidBecomeActive`：機微なデータを表示および復号化するために使用します。
* `UIScreenCapturedDidChangeNotification`：画面録画を検出します。表示をクリアし、機微なデータを暗号化してください。

### iOS02. Xcode出力からシンボルを削除する <a href="#ios02-remove-symbols-from-xcode-output" id="ios02-remove-symbols-from-xcode-output"></a>

アプリケーションは最終リリースのバイナリからすべてのシンボルを削除する必要があります。

デバッグ情報やその他のシンボルを削除するために、Xcodeプロジェクトで次の設定を行うことを推奨します：

```
DEPLOYMENT_POSTPROCESSING = YES
GCC_GENERATE_DEBUGGING_SYMBOLS = NO
STRIP_INSTALLED_PRODUCT = YES
STRIP_STYLE = all
COPY_PHASE_STRIP = YES
```

### iOS03. Swiftでの機微なデータ管理 <a href="#ios03-management-of-sensitive-data-in-swift" id="ios03-management-of-sensitive-data-in-swift"></a>

アプリケーションは機微なデータが適切に管理されることを保証しなければなりません。Swiftでは、 [Data](https://developer.apple.com/documentation/foundation/data) は値型です。追加の参照を代入すると、割り当てられたバイトの新しいコピーが作成される可能性があります。

これらのパターンを最小限にして、割り当てられる機微なバイト数を減らしてください。

割り当てられたバイトを `inout` 引数として渡して参照渡しにし、使用後にワイプしてください。

以下のコードスニペットは、割り当てられたバイトを `inout` 引数として渡す方法を示しています：

```swift
func helloWorld(_ data: inout Data) {	...}
var data = Data()helloWorld(&data)
```

次のコードスニペットは、 `Data` 変数をワイプする方法を示しています：

```swift

extension Data {
    internal mutating func wipe() {
        guard count > 0 else {
            return
        }
        let length = count
        withUnsafeMutableBytes { ptr in
            if let mutableRawPtr = ptr.baseAddress {
                memset_s(mutableRawPtr, length, 0, length)
            }
        }
    }
}
```

### iOS04. 機微な入力に対する自動補正キャッシュを無効にする <a href="#ios04-disable-auto-correction-cache-for-sensitive-input" id="ios04-disable-auto-correction-cache-for-sensitive-input"></a>

アプリケーションは機微なデータを要求する入力に対して自動補正キャッシュを無効にする必要があります。これにより、デバイスにアクセスできる攻撃者がオートコンプリートの候補文字列を使って機微なテキスト入力データを閲覧することを防ぎます。

アプリケーションは自動補正キャッシュを無効にするために次のいずれかの操作を行うことができます：

* 次のフィールドを設定します： `secureTextEntry` フィールドを `true`.
* 次のフィールドを設定します： `autoCorrectionType` フィールドを `UITextAutocorrectionType.no`.

### iOS05. 機微なデータのコピー＆ペーストを無効にする <a href="#ios05-disable-data-copypaste-for-sensitive-data" id="ios05-disable-data-copypaste-for-sensitive-data"></a>

アプリケーションは機微なデータに対するコピー/ペーストメニューを無効にする必要があります。これにより、デバイスにアクセスできる攻撃者がコピーされたデータをペーストして閲覧することを防ぎます。次のサンプルコードはコピー/ペーストメニューを無効にします：

```swift
override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
    let menuController = UIMenuController.shared
    menuController.isMenuVisible = false
}

```

### iOS06. App Storeでのアプリバージョン管理 <a href="#ios06-managing-app-versions-in-the-app-store" id="ios06-managing-app-versions-in-the-app-store"></a>

エンドユーザーは既に購入またはインストールした過去のアプリバージョンを再ダウンロードできます。これにより、現在のバージョンでサポートされなくなった古いデバイスでの利用が可能になります。これらのバージョンを利用可能にしたくない場合は、App Store ConnectのManage Your AppsモジュールのRights and Pricingセクションで過去のアプリバージョンの可用性を管理してください。

詳細は、次を参照してください： [AppStore Connect](https://developer.apple.com/support/app-store-connect/).

セキュリティの観点から、攻撃対象面はできる限り小さく保ってください。古いバージョンを残すと到達範囲が広がります。また、既知の弱点を持つ古いファームウェアにソリューションをさらす可能性もあります。可能であれば一度に1つのバージョン（最新）だけを利用可能にすることを推奨します。ビルド設定を調整してより広い範囲のiOSバージョンをサポートすることでデバイス対応を拡張してください。

**App Store Connectでアプリの「Apple Silicon Macの利用可能性」を無効にする**

Mac M1上でiOSアプリケーションを実行することは、アプリケーションのバイナリとサンドボックスデータの両方にアクセスしやすくなるため、はるかに安全性が低くなります。

AppleシリコンMacへのインストールを防ぎリスクを軽減するために、App Store Connectでアプリの「Apple Silicon Macの利用可能性」を無効にしてください。

詳細については、次の [Appleのドキュメント](https://developer.apple.com/documentation/apple-silicon/running-your-ios-apps-on-macos).

### iOS07. アプリケーション改ざんの防止 <a href="#ios07-preventing-the-tampering-of-the-application" id="ios07-preventing-the-tampering-of-the-application"></a>

アプリケーションコードへの悪意あるハッキングを防ぐために、実行時にアプリケーションのバイナリの整合性を検証することを推奨します。これは、\_\_TEXTセグメントの\_\_textセクションのチェックサムを計算することでアプリ内で実装できます。

実装の詳細については、次を参照してください： [github link](https://github.com/OWASP/owasp-mstg/blob/master/Document/0x06j-Testing-Resiliency-Against-Reverse-Engineering.md)。チェックサムを計算するコードを保護するためには強力な難読化が必要です。

改ざん攻撃に関連するリスクについては、次を参照してください： [OWASP](https://www.owasp.org/index.php/Mobile_Top_10_2016-M8-Code_Tampering).

### iOS08. Xcodeコンパイラのセキュリティおよび難読化オプション <a href="#ios08-xcode-compiler-security-and-obfuscation-options" id="ios08-xcode-compiler-security-and-obfuscation-options"></a>

セキュリティを高め、逆アセンブルを複雑にするXcodeオプションを使用してください。

Xcodeプロジェクトで次の設定を行うことを推奨します：

```
GCC_UNROLL_LOOPS = YES
GCC_OPTIMIZATION_LEVEL = 3
OTHER_CFLAGS = -fstack-protector-all -finline-functions
CLANG_ENABLE_OBJC_ARC = YES
GCC_DYNAMIC_NO_PIC = NO
LD_NO_PIE = NO
RUN_CLANG_STATIC_ANALYZER = YES
CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES
CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES
CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES
CLANG_ANALYZER_SECURITY_INSECUREAPI_GETPW_GETS = YES
CLANG_ANALYZER_SECURITY_INSECUREAPI_MKSTEMP = YES
CLANG_ANALYZER_SECURITY_INSECUREAPI_VFORK = YES
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.payments.thalescloud.io/classic-push-provisioning/ja/gaido/sekyuritigaidorain/ios.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
