การใช้ Deep Link ที่ไม่ปลอดภัย
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
หมวดหมู่ OWASP: MASVS-PLATFORM: การโต้ตอบระหว่างแพลตฟอร์ม
ภาพรวม
ความเสี่ยงด้านความปลอดภัยที่เชื่อมโยงกับ Deep Link มาจากความสามารถหลักของ Deep Link ในการช่วยให้การไปยังส่วนต่างๆ และการโต้ตอบภายในแอปพลิเคชันบนอุปกรณ์เคลื่อนที่เป็นไปอย่างราบรื่น ช่องโหว่ของ Deep Link เกิดจากจุดอ่อนในการใช้งานหรือการจัดการ Deep Link ผู้ไม่ประสงค์ดีอาจใช้ช่องโหว่เหล่านี้เพื่อเข้าถึงฟังก์ชันหรือข้อมูลที่มีสิทธิ์ ซึ่งอาจส่งผลให้เกิดการละเมิดข้อมูล การละเมิดความเป็นส่วนตัว และการดําเนินการโดยไม่ได้รับอนุญาต ผู้โจมตีสามารถใช้ประโยชน์จากช่องโหว่เหล่านี้ผ่านเทคนิคต่างๆ เช่น การลักลอบใช้ Deep Link และการโจมตีการตรวจสอบข้อมูล
ผลกระทบ
การไม่มีกลไกการตรวจสอบ Deep Link ที่ถูกต้องหรือการใช้ Deep Link ที่ไม่ปลอดภัยอาจช่วยให้ผู้ใช้ที่เป็นอันตรายทำการโจมตีได้ เช่น การหลบเลี่ยงการตรวจสอบโฮสต์ การใช้สคริปต์ข้ามแอป และการดำเนินการกับโค้ดจากระยะไกลภายในบริบทสิทธิ์ของแอปพลิเคชันที่เปราะบาง ซึ่งอาจส่งผลให้มีการเข้าถึงข้อมูลที่ละเอียดอ่อนหรือฟังก์ชันโดยไม่ได้รับอนุญาต ทั้งนี้ขึ้นอยู่กับลักษณะของแอปพลิเคชัน
การผ่อนปรนชั่วคราว
ป้องกันการลักลอบใช้ Deep Link
Android ออกแบบมาให้แอปหลายแอปลงทะเบียนตัวกรอง Intent สําหรับ URI ของ Deep Link เดียวกันได้ หากต้องการป้องกันไม่ให้แอปที่เป็นอันตรายขัดขวาง Deep Link ที่มีไว้สำหรับแอปของคุณ ให้ใช้แอตทริบิวต์ android:autoVerify
ใน intent-filter
ภายใน AndroidManifest
ของแอปพลิเคชัน ซึ่งจะช่วยให้ผู้ใช้เลือกแอปที่ต้องการจัดการ Deep Link ได้ เพื่อให้การดำเนินการเป็นไปตามที่ต้องการและป้องกันไม่ให้แอปพลิเคชันที่เป็นอันตรายตีความ Deep Link โดยอัตโนมัติ
Android 12 เปิดตัวการจัดการ Intent บนเว็บที่เข้มงวดขึ้นเพื่อเพิ่มความปลอดภัย
ตอนนี้แอปต้องได้รับการยืนยันเพื่อจัดการลิงก์จากโดเมนที่เฉพาะเจาะจงผ่าน App Link ของ Android หรือการเลือกของผู้ใช้ในการตั้งค่าระบบ ซึ่งจะช่วยป้องกันไม่ให้แอปลักลอบใช้ลิงก์ที่ไม่ควรจัดการ
หากต้องการเปิดใช้การยืนยันการจัดการลิงก์สําหรับแอป ให้เพิ่มตัวกรอง Intent ที่ตรงกับรูปแบบต่อไปนี้ (ตัวอย่างนี้นำมาจากเอกสารประกอบยืนยัน Android App Link)
<!-- Make sure you explicitly set android:autoVerify to "true". -->
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- If a user clicks on a shared link that uses the "http" scheme, your
app should be able to delegate that traffic to "https". -->
<data android:scheme="http" />
<data android:scheme="https" />
<!-- Include one or more domains that should be verified. -->
<data android:host="..." />
</intent-filter>
ใช้การตรวจสอบข้อมูลที่มีประสิทธิภาพ
Deep Link สามารถมีพารามิเตอร์เพิ่มเติมที่แสดงต่อ Intent เป้าหมาย เช่น เพื่อดําเนินการเพิ่มเติม พื้นฐานของการจัดการ Deep Link ที่ปลอดภัย
คือการตรวจสอบข้อมูลที่เข้มงวด ข้อมูลขาเข้าทั้งหมดจาก Deep Link ควรได้รับการตรวจสอบและล้างออกอย่างพิถีพิถันโดยนักพัฒนาซอฟต์แวร์เพื่อป้องกันไม่ให้มีการแทรกโค้ดหรือค่าที่เป็นอันตรายภายในแอปพลิเคชันที่ถูกต้อง
ซึ่งทำได้โดยการตรวจสอบค่าของพารามิเตอร์ Deep Link กับรายการที่อนุญาตของค่าที่คาดไว้ซึ่งกําหนดไว้ล่วงหน้า
แอปควรตรวจสอบสถานะภายในอื่นๆ ที่เกี่ยวข้อง เช่น สถานะการตรวจสอบสิทธิ์หรือการให้สิทธิ์ ก่อนเปิดเผยข้อมูลที่ละเอียดอ่อน ตัวอย่างเช่น รางวัลสำหรับการผ่านด่านในเกม ในกรณีนี้ คุณควรตรวจสอบเงื่อนไขเบื้องต้นของการผ่านด่าน และเปลี่ยนเส้นทางไปยังหน้าจอหลักหากไม่ผ่านด่าน
แหล่งข้อมูล
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 2025-07-26 UTC"],[],[],null,["# Unsafe use of deep links\n\n\u003cbr /\u003e\n\n**OWASP category:** [MASVS-PLATFORM: Platform Interaction](https://mas.owasp.org/MASVS/09-MASVS-PLATFORM)\n\nOverview\n--------\n\nThe security risks associated with deep links stem from their core capability of\nenabling seamless navigation and interaction within mobile applications. Deep\nlink vulnerabilities arise from weaknesses in the implementation or handling of\ndeep links. These flaws can be exploited by malicious actors to gain access to\nprivileged functions or data, potentially resulting in data breaches, privacy\nviolations, and unauthorized actions. Attackers can exploit these\nvulnerabilities through various techniques, such as deep link hijacking and data\nvalidation attacks.\n\nImpact\n------\n\nThe lack of a proper deep link validation mechanism, or the unsafe use of\ndeeplinks, can aid malicious users in performing attacks such as host validation\nbypass, cross-app scripting, and remote code execution within the permissions\ncontext of the vulnerable application. Depending on the nature of the\napplication, this can result in unauthorized access to sensitive data or\nfunctions.\n\nMitigations\n-----------\n\n### Prevent deep link hijacking\n\nBy design, Android allows multiple apps to register intent filters for the same\ndeep link URI. To prevent malicious apps from intercepting deep links intended\nfor your app, implement the `android:autoVerify` attribute in `intent-filter`\nwithin the application's `AndroidManifest`. This allows users to select their\npreferred app for handling deep links, ensuring the intended operation and\npreventing malicious applications from automatically interpreting them.\n\nAndroid 12 [introduced](/about/versions/12/behavior-changes-all#web-intent-resolution) stricter handling of web intents to improve security.\nApps must now be verified to handle links from specific domains, either through\nAndroid App Links or user selection in system settings. This prevents apps from\nhijacking links they shouldn't handle.\n\nTo enable link handling verification for your app, add intent filters that match\nthe following format (this example is taken from the [Verify Android App\nLinks](/training/app-links/verify-android-applinks) documentation): \n\n \u003c!-- Make sure you explicitly set android:autoVerify to \"true\". --\u003e\n \u003cintent-filter android:autoVerify=\"true\"\u003e\n \u003caction android:name=\"android.intent.action.VIEW\" /\u003e\n \u003ccategory android:name=\"android.intent.category.DEFAULT\" /\u003e\n \u003ccategory android:name=\"android.intent.category.BROWSABLE\" /\u003e\n \n \u003c!-- If a user clicks on a shared link that uses the \"http\" scheme, your\n app should be able to delegate that traffic to \"https\". --\u003e\n \u003cdata android:scheme=\"http\" /\u003e\n \u003cdata android:scheme=\"https\" /\u003e\n \n \u003c!-- Include one or more domains that should be verified. --\u003e\n \u003cdata android:host=\"...\" /\u003e\n \u003c/intent-filter\u003e\n\n### Implement robust data validation\n\nDeep links can include additional parameters that are served to the target\nintent, for example, to perform further actions. The foundation of secure deep\nlink handling is stringent data validation. All incoming data from deep links\nshould be meticulously validated and sanitized by developers to prevent\nmalicious code or values from being injected within the legitimate application.\nThis can be implemented by checking the value of any deep link parameter against\na predefined allowlist of expected values.\n\nApps should check other relevant internal states, such as authentication state,\nor authorization, before exposing sensitive information. An example might be a\nreward for completing a level of a game. In this case it's worth validating the\nprecondition of having completed the level, and redirecting to the main screen\nif not.\n\nResources\n---------\n\n- [Verify Android App Links](/training/app-links/verify-android-applinks)\n- [Handling Android App Links](/training/app-links)\n- [Web intent resolution](/about/versions/12/behavior-changes-all#web-intent-resolution)\n- [Account takeover intercepting magic link for Arrive app](https://hackerone.com/reports/855618)\n- [Deep Links \\& WebViews Exploitations Part I](https://www.justmobilesec.com/en/blog/deep-links-webviews-exploitations-part-I)\n- [Deep Links \\& WebViews Exploitations Part II](https://www.justmobilesec.com/en/blog/deep-links-webviews-exploitations-part-II)\n- [Recent suggestion of a deep link issue in Jetpack Navigation](https://swarm.ptsecurity.com/android-jetpack-navigation-go-even-deeper/)"]]