Translated ['src/mobile-pentesting/ios-pentesting/ios-universal-links.md

This commit is contained in:
Translator 2025-07-17 14:10:03 +00:00
parent 12c795dac6
commit ad57b1359f

View File

@ -4,13 +4,13 @@
## Introduction
ユニバーサルリンクは、ユーザーに**シームレスなリダイレクション**体験を提供し、Safariのリダイレクションをバイパスしてアプリ内のコンテンツを直接開きます。これらのリンクは**ユニーク**で安全であり、他のアプリによって主張されることはありません。これは、ウェブサイトのルートディレクトリに`apple-app-site-association` JSONファイルをホスティングすることで保証され、ウェブサイトとアプリの間に検証可能なリンクが確立されます。アプリがインストールされていない場合、Safariが引き継ぎ、ユーザーをウェブページに誘導し、アプリの存在を維持します。
ユニバーサルリンクは、ユーザーに**シームレスなリダイレクション**体験を提供し、Safariのリダイレクションをバイパスしてコンテンツをアプリ内で直接開きます。これらのリンクは**ユニーク**で安全であり、他のアプリによって主張されることはありません。これは、ウェブサイトのルートディレクトリに`apple-app-site-association` JSONファイルをホスティングすることで保証され、ウェブサイトとアプリの間に検証可能なリンクが確立されます。アプリがインストールされていない場合、Safariが引き継ぎ、ユーザーをウェブページに誘導し、アプリの存在を維持します。
ペネトレーションテスターにとって、`apple-app-site-association`ファイルは特に興味深いものであり、**機密パス**を明らかにする可能性があり、未発表の機能に関連するものが含まれることもあります。
ペネトレーションテスターにとって、`apple-app-site-association`ファイルは特に興味深いものであり、**機密パス**を明らかにする可能性があり、未発表の機能に関連するものを含むことがあります。
### **関連ドメイン権限の分析**
### **Analyzing the Associated Domains Entitlement**
開発者は、XcodeのCapabilitiesタブで**関連ドメイン**を設定するか、`.entitlements`ファイルを検査することでユニバーサルリンクを有効にします。各ドメインは`applinks:`始まります。例えば、Telegramの設定は次のように表示されるかもしれません:
開発者は、XcodeのCapabilitiesタブで**関連ドメイン**を設定するか、`.entitlements`ファイルを検査することでユニバーサルリンクを有効にします。各ドメインは`applinks:`プレフィックスされます。たとえば、Telegramの設定は次のように表示されるかもしれません:
```xml
<key>com.apple.developer.associated-domains</key>
<array>
@ -20,15 +20,27 @@
```
より包括的な洞察については、[アーカイブされたApple Developer Documentation](https://developer.apple.com/library/archive/documentation/General/Conceptual/AppSearch/UniversalLinks.html#//apple_ref/doc/uid/TP40016308-CH12-SW2)を参照してください。
コンパイルされたアプリケーションを使用している場合、[このガイド](extracting-entitlements-from-compiled-application.md)に従って権限を抽出できます。
コンパイルされたアプリケーションを扱う場合、権限は[このガイド](extracting-entitlements-from-compiled-application.md)に従って抽出できます。
### **Apple App Site Associationファイルの取得**
`apple-app-site-association`ファイルは、権限に指定されたドメインを使用してサーバーから取得する必要があります。このファイルは、`https://<domain>/apple-app-site-association`でHTTPS経由で直接アクセスできることを確認してください。[Apple App Site Association (AASA) Validator](https://branch.io/resources/aasa-validator/)のようなツールがこのプロセスを支援できます。
`apple-app-site-association`ファイルは、権限に指定されたドメインを使用してサーバーから取得する必要があります。ファイルが`https://<domain>/apple-app-site-association`(または`/.well-known/apple-app-site-association`でHTTPS経由で直接アクセス可能であることを確認してください。[Apple App Site Association (AASA) Validator](https://branch.io/resources/aasa-validator/)のようなツールがこのプロセスを支援できます。
> **macOS/Linuxシェルからのクイック列挙**
>
> ```bash
> # ent.xmlに権限を抽出したと仮定
> doms=$(plutil -extract com.apple.developer.associated-domains xml1 -o - ent.xml | \
> grep -oE 'applinks:[^<]+' | cut -d':' -f2)
> for d in $doms; do
> echo "[+] $dのAASAを取得中";
> curl -sk "https://$d/.well-known/apple-app-site-association" | jq '.'
> done
> ```
### **アプリ内のユニバーサルリンクの処理**
アプリは、ユニバーサルリンクを正しく処理するために特定のメソッドを実装する必要があります。探すべき主なメソッドは[`application:continueUserActivity:restorationHandler:`](https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1623072-application)です。処理されるURLのスキームはHTTPまたはHTTPSであることが重要であり、他のスキームはサポートされません。
アプリはユニバーサルリンクを正しく処理するために特定のメソッドを実装する必要があります。探すべき主なメソッドは[`application:continueUserActivity:restorationHandler:`](https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1623072-application)です。処理されるURLのスキームHTTPまたはHTTPSであることが重要であり、他のスキームはサポートされません。
#### **データハンドラーメソッドの検証**
@ -70,15 +82,36 @@ return false
}
}
```
開発者は、**勤勉な構成と検証**を通じて、ユニバーサルリンクがユーザーエクスペリエンスを向上させると同時に、セキュリティとプライバシー基準を維持することを確実にできます。
Through **diligent configuration and validation**, developers can ensure that universal links enhance user experience while maintaining security and privacy standards.
## ツール
## Common Vulnerabilities & Pentesting Checks
- [GetUniversal.link](https://getuniversal.link/): アプリのユニバーサルリンクとAASAファイルのテストと管理を簡素化するのに役立ちます。ドメインを入力するだけでAASAファイルの整合性を確認したり、カスタムダッシュボードを使用してリンクの動作を簡単にテストできます。このツールは、Appleが次にAASAファイルをインデックスする時期を判断するのにも役立ちます。
| # | Weakness | How to test | Exploitation / Impact |
|---|----------|------------|-----------------------|
| 1 | **過度に広範な `paths` / `components`** in the AASA file (e.g. `"/": "*"` or wildcards such as `"/a/*"`). | • ダウンロードしたAASAを検査し、`*`、末尾のスラッシュ、または `{"?": …}` ルールを探します。<br>• ルールに一致する未知のリソースをリクエストしてみます (`https://domain.com/a/evil?_p_dp=1`)。 | Universal-link hijacking: a malicious iOS app that registers the same domain could claim all those links and present phishing UI. A real-world example is the May 2025 Temu.com bug-bounty report where an attacker could redirect any `/a/*` path to their own app. |
| 2 | **深いリンクパスのサーバー側検証の欠如**。 | 許可されたパスを特定した後、存在しないリソースに対して `curl`/Burpリクエストを発行し、HTTPステータスコードを観察します。`404` 以外のもの(例: 200/302は疑わしいです。 | An attacker can host arbitrary content behind an allowed path and serve it via the legitimate domain, increasing the success rate of phishing or session-token theft. |
| 3 | **スキーム/ホストのホワイトリストなしのアプリ側URL処理** (CVE-2024-10474 Mozilla Focus < 132)。 | 直接の `openURL:`/`open(_:options:)` 呼び出しや任意のURLを転送するJavaScriptブリッジを探します | Internal pages can smuggle `myapp://` or `https://` URLs that bypass the browsers URL-bar safety checks, leading to spoofing or unintended privileged actions. |
| 4 | **権限でのワイルドカードサブドメインの使用** (`*.example.com`)。 | 権限内で `*.``grep` します。 | If any sub-domain is taken over (e.g. via an unused S3 bucket), the attacker automatically gains the Universal Link binding. |
## 参考文献
### Quick Checklist
* [ ] Extract entitlements and enumerate every `applinks:` entry.
* [ ] Download AASA for each entry and audit for wildcards.
* [ ] Verify the web server returns **404** for undefined paths.
* [ ] In the binary, confirm that **only** trusted hosts/schemes are handled.
* [ ] If the app uses the newer `components` syntax (iOS 11+), fuzz query-parameter rules (`{"?":{…}}`).
## Tools
- [GetUniversal.link](https://getuniversal.link/): Helps simplify the testing and management of your app's Universal Links and AASA file. Simply enter your domain to verify AASA file integrity or use the custom dashboard to easily test link behavior. This tool also helps you determine when Apple will next index your AASA file.
- [Knil](https://github.com/ethanhuang13/knil): Open-source iOS utility that fetches, parses and lets you **tap-test** every Universal Link declared by a domain directly on device.
- [universal-link-validator](https://github.com/urbangems/universal-link-validator): CLI / web validator that performs strict AASA conformance checks and highlights dangerous wildcards.
## References
- [https://mas.owasp.org/MASTG/tests/ios/MASVS-PLATFORM/MASTG-TEST-0070/#static-analysis](https://mas.owasp.org/MASTG/tests/ios/MASVS-PLATFORM/MASTG-TEST-0070/#static-analysis)
- [https://mobile-security.gitbook.io/mobile-security-testing-guide/ios-testing-guide/0x06h-testing-platform-interaction#testing-object-persistence-mstg-platform-8](https://mobile-security.gitbook.io/mobile-security-testing-guide/ios-testing-guide/0x06h-testing-platform-interaction#testing-object-persistence-mstg-platform-8)
- [https://medium.com/@m.habibgpi/universal-link-hijacking-via-misconfigured-aasa-file-on-temu-com-eadfcb745e4e](https://medium.com/@m.habibgpi/universal-link-hijacking-via-misconfigured-aasa-file-on-temu-com-eadfcb745e4e)
- [https://nvd.nist.gov/vuln/detail/CVE-2024-10474](https://nvd.nist.gov/vuln/detail/CVE-2024-10474)
{{#include ../../banners/hacktricks-training.md}}