Pattern: Share links and deep links
Note for AI agents: This page is baseline guidance, not an exact prescription. Read it, tell your owner what applies to their project, and get their approval before you change anything. Your project's own rules take precedence. If something important for this project is missing here, suggest it to your owner.
For agents
- Offer as a suggestion. Values are examples.
- Core ideas: share only public content, use long unguessable ids, open the installed app directly, show no content on the web (only a download page), re-check visibility at every open, and keep the preview card generic.
- Related: reports and moderation, multiple domains, media ratios.
1. Problem
A share link crosses the boundary between the app and the open web. If it leaks private content, reveals whether an item exists, or breaks when the app is not installed, the feature harms privacy and growth at once.
2. Options
| Topic | Option | Upside | Downside |
|---|---|---|---|
| Web fallback | Show the content on the web | Good reach; search indexing | Content leaves the app; moderation and privacy burden |
| Web fallback | Only an “install the app” page (recommended where content is private-ish) | Content stays in the app | Less reach |
| Link ids | Sequential ids | Simple | Guessable (IDOR risk) |
| Link ids | Long random ids (recommended) | Not guessable | Cannot be remembered |
| Opening | Custom URL scheme | Easy | Any app can claim it; no web fallback |
| Opening | App Links (Android) and Universal Links (iOS) (recommended) | Opens the verified app; falls back to the web | Needs verification files on the domain |
3. Recommended design
- Share button only on public content. Content that is private never gets a share link.
- Unguessable, non-expiring id (long random), never a counter. OWASP’s IDOR sheet explains why direct references need checks; the id is not the access control, the visibility check is.
- Open in the app when installed. Android App Links require a verified association between the domain and the app (Android’s “Verify App Links”); iOS uses Universal Links with an association file on the domain (Apple’s “Supporting universal links in your app”). Both fall back to the web when the app is missing.
- Fallback page without content. When the app is not installed the web page shows only “download the app” with store links. This means an observer cannot tell if the item exists or not.
- Visibility is re-checked at every open: blocked users, deleted items and private accounts get a neutral message; if the account became private, show the follow-request path.
- Preview card is generic. Open Graph tags (the Open Graph protocol defines them) are what chat apps read for the preview. Use a generic title and image so that content does not leave the app through the preview.
- Short links are issued by your own domain (see multiple domains) so links keep working if one domain is lost.
- Abuse: reported items stop resolving immediately (see reports and moderation).
4. Scenarios and edge cases
- Recipient has no app: download page; after install, the link opens the item (deferred deep link where the platform supports it; depends on store tools).
- Owner makes the post private after sharing: the link shows the neutral message.
- Item deleted: same neutral message; do not distinguish “deleted” from “never existed”.
- Two domains serve links: both are in the verification files.
5. Common mistakes
- Share links for private content.
- Sequential ids.
- Web pages that show the content and its metadata to everyone.
- Preview cards with the item’s text.
- Skipping the visibility check because “the link is a secret”.
- Custom URL scheme as the only opening mechanism.
6. How to audit
- What: the link id is not guessable.
- How to check: create several links; compare ids.
- Evidence: random-looking ids with no sequence.
- What: the app opens directly from the link.
- How to check: tap the link on a phone with the app installed and one without.
- Evidence: app opens; download page otherwise.
- What: the web fallback shows no content.
- How to check: open the link in a desktop browser.
- Evidence: page content.
- What: visibility is re-checked.
- How to check: make the item private or delete it, reopen the old link.
- Evidence: neutral message.
Sources
- Verify App Links — Android Developers
- Supporting universal links in your app — Apple Developer Documentation
- The Open Graph protocol — Open Graph protocol
- Insecure Direct Object Reference Prevention Cheat Sheet — OWASP Cheat Sheet Series
- User Privacy Protection Cheat Sheet — OWASP Cheat Sheet Series
- Application Security Verification Standard (ASVS) — OWASP