Skip to content

MASWE-0029: Insecure Deep Links

MAS Requirement

The app securely handles deep links.

Mappings

MASVS V1: MSTG-PLATFORM-3

MASVS V2: MASVS-PLATFORM-1, MASVS-STORAGE-2, MASVS-CODE-4

CWE: CWE-939: Improper Authorization in Handler for Custom URL Scheme, CWE-917: Improper Neutralization of Special Elements used in an Expression Language Statement

Android Risks: unsafe-use-of-deeplinks

Overview

This weakness occurs when an app handles deep links insecurely, relying on unverified schemes or trusting the attacker-controllable data they carry.

Deep links (Android App Links, iOS Universal Links and custom URL schemes) let other apps and websites launch the app, trigger an in-app action and pass parameters. They become insecure when the app relies on custom URL schemes that any app can claim, does not verify App Links or Universal Links through domain association, or fails to validate and sanitize the incoming URL and its parameters. Because deep link input is attacker-controllable, a malformed URI or parameter can trigger injection or logic abuse at various points in the app.

Modes of Introduction

  • Unverified Custom URL Schemes: Relying on custom URL schemes for sensitive flows even though any installed app can claim the same scheme.
  • Missing Domain Association: Declaring App Links without autoVerify and Digital Asset Links, or Universal Links without a valid apple-app-site-association file, so links are not cryptographically tied to the app's domain.
  • Unvalidated Deep Link Input: Passing the deep link URL and its parameters into navigation decisions, WebViews, or queries without validation and sanitization.

Impact

  • Compromise of Sensitive Data: Attackers can intercept tokens or personal data carried in deep links, or exfiltrate data through injected parameters, resulting in unauthorized disclosure of user data.
  • Authentication or Authorization Bypass: Attackers can capture authentication material delivered via hijacked links (e.g. login or password-reset links), resulting in account takeover.
  • Execution of Unauthorized Code: Attackers can inject expressions or script through unsanitized deep link parameters that reach interpreters or WebViews, resulting in attacker-controlled behavior inside the app.

Mitigations

  • Use Verified Link Mechanisms: Handle sensitive flows only through verified Android App Links (with autoVerify and Digital Asset Links) and iOS Universal Links, not through claimable custom schemes.
  • Validate and Sanitize Deep Link Input: Treat every deep link URL and parameter as untrusted input; validate against an allowlist of expected destinations and value formats before use.
  • Validate the Source Where Possible: Verify the calling application or referrer for custom scheme invocations when the platform allows it.
  • Keep Secrets Out of Deep Links: Avoid transporting session tokens or other secrets in links; where unavoidable, make them single-use and short-lived.

Knowledge

MASTG-KNOW-0019: Deep Links MASTG-KNOW-0080: Universal Links MASTG-KNOW-0079: Custom URL Schemes

Tests

MASTG-TEST-0393: Use of Unverified App Links MASTG-TEST-0394: Missing Input Validation in Custom URL Scheme Handlers MASTG-TEST-0395: Missing Input Validation in Universal Link Handlers MASTG-TEST-0371: Missing Source Validation in Custom URL Scheme Handlers MASTG-TEST-0370: Missing Input Validation in Custom URL Scheme Handlers

Best Practices

MASTG-BEST-0070: Verify Android App Links with autoVerify and Digital Asset Links MASTG-BEST-0071: Validate Input Parameters in Deep Link and Custom URL Scheme Handlers MASTG-BEST-0072: Validate Input Parameters in Universal Link Handlers MASTG-BEST-0045: Limit Sensitive Data Exposure Through iOS IPC Channels MASTG-BEST-0055: Validate Source Application in Custom URL Scheme Handlers MASTG-BEST-0054: Validate Input Parameters in Custom URL Scheme Handlers