iOS Universal Links
Reading time: 9 minutes
tip
AWSハッキングを学び、実践する:HackTricks Training AWS Red Team Expert (ARTE)
GCPハッキングを学び、実践する:HackTricks Training GCP Red Team Expert (GRTE)
Azureハッキングを学び、実践する:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricksをサポートする
- サブスクリプションプランを確認してください!
- **💬 Discordグループまたはテレグラムグループに参加するか、Twitter 🐦 @hacktricks_liveをフォローしてください。
- HackTricksおよびHackTricks CloudのGitHubリポジトリにPRを提出してハッキングトリックを共有してください。
Introduction
ユニバーサルリンクは、ユーザーにシームレスなリダイレクション体験を提供し、Safariのリダイレクションをバイパスしてコンテンツをアプリ内で直接開きます。これらのリンクはユニークで安全であり、他のアプリによって主張されることはありません。これは、ウェブサイトのルートディレクトリにapple-app-site-association
JSONファイルをホスティングすることで保証され、ウェブサイトとアプリの間に検証可能なリンクが確立されます。アプリがインストールされていない場合、Safariが引き継ぎ、ユーザーをウェブページに誘導し、アプリの存在を維持します。
ペネトレーションテスターにとって、apple-app-site-association
ファイルは特に興味深いものであり、機密のパスを明らかにする可能性があり、未発表の機能に関連するものを含むことがあります。
関連ドメインの権限の分析
開発者は、XcodeのCapabilitiesタブで関連ドメインを設定するか、.entitlements
ファイルを検査することでユニバーサルリンクを有効にします。各ドメインはapplinks:
でプレフィックスされます。たとえば、Telegramの設定は次のように表示されるかもしれません:
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:telegram.me</string>
<string>applinks:t.me</string>
</array>
より包括的な洞察については、アーカイブされたApple Developer Documentationを参照してください。
コンパイルされたアプリケーションを扱う場合、権限はこのガイドに従って抽出できます。
Apple App Site Associationファイルの取得
apple-app-site-association
ファイルは、権限に指定されたドメインを使用してサーバーから取得する必要があります。ファイルがhttps://<domain>/apple-app-site-association
(または/.well-known/apple-app-site-association
)でHTTPS経由で直接アクセス可能であることを確認してください。Apple App Site Association (AASA) Validatorのようなツールがこのプロセスを支援できます。
macOS/Linuxシェルからのクイック列挙
# entitlementsを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 "[+] AASAを$dから取得中"; curl -sk "https://$d/.well-known/apple-app-site-association" | jq '.' done
アプリ内のユニバーサルリンクの処理
アプリはユニバーサルリンクを正しく処理するために特定のメソッドを実装する必要があります。探すべき主要なメソッドはapplication:continueUserActivity:restorationHandler:
です。処理されるURLのスキームがHTTPまたはHTTPSであることが重要であり、他のスキームはサポートされません。
データハンドラーメソッドの検証
ユニバーサルリンクがアプリを開くと、NSUserActivity
オブジェクトがURLと共にアプリに渡されます。このURLを処理する前に、セキュリティリスクを防ぐために検証およびサニタイズすることが重要です。以下は、プロセスを示すSwiftの例です:
func application(_ application: UIApplication, continue userActivity: NSUserActivity,
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
// Check for web browsing activity and valid URL
if userActivity.activityType == NSUserActivityTypeBrowsingWeb, let url = userActivity.webpageURL {
application.open(url, options: [:], completionHandler: nil)
}
return true
}
URLsは慎重に解析され、検証されるべきです。特にパラメータが含まれている場合、潜在的なスプーフィングや不正なデータから守るためです。NSURLComponents
APIはこの目的に役立ちます。以下に示します:
func application(_ application: UIApplication,
continue userActivity: NSUserActivity,
restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,
let incomingURL = userActivity.webpageURL,
let components = NSURLComponents(url: incomingURL, resolvingAgainstBaseURL: true),
let path = components.path,
let params = components.queryItems else {
return false
}
if let albumName = params.first(where: { $0.name == "albumname" })?.value,
let photoIndex = params.first(where: { $0.name == "index" })?.value {
// Process the URL with album name and photo index
return true
} else {
// Handle invalid or missing parameters
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
# | Weakness | How to test | Exploitation / Impact |
---|---|---|---|
1 | 過度に広範な paths / components in the AASA file (e.g. "/": "*" or wildcards such as "/a/*" ). | • ダウンロードしたAASAを検査し、* 、末尾のスラッシュ、または {"?": …} ルールを探します。• ルールに一致する未知のリソースをリクエストしてみます ( 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 browser’s URL-bar safety checks, leading to spoofing or unintended privileged actions. |
4 | ワイルドカードサブドメインの使用 (*.example.com ) in the entitlement. | 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: 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: 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: 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://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://nvd.nist.gov/vuln/detail/CVE-2024-10474
tip
AWSハッキングを学び、実践する:HackTricks Training AWS Red Team Expert (ARTE)
GCPハッキングを学び、実践する:HackTricks Training GCP Red Team Expert (GRTE)
Azureハッキングを学び、実践する:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricksをサポートする
- サブスクリプションプランを確認してください!
- **💬 Discordグループまたはテレグラムグループに参加するか、Twitter 🐦 @hacktricks_liveをフォローしてください。
- HackTricksおよびHackTricks CloudのGitHubリポジトリにPRを提出してハッキングトリックを共有してください。