mirror of
https://gitlab.com/soapbox-pub/mkstack.git
synced 2026-12-03 08:07:21 +00:00
Warn that deep links are attacker-triggerable navigations
Any web page can open a custom-scheme URL, and `DeepLinkHandler` turns that into a `navigate()` call — so a route that acts on mount (publishing, following, paying, deleting) is an action any website can fire silently, with no user intent beyond a tap on an unrelated page. The `appUrlOpen` event gives no way to tell a verified universal link from a custom scheme, so the destination has to be treated as attacker-chosen. Document the constraint where it will be read, rather than filtering to `https:` in the component: this skill documents custom schemes as a supported setup, and filtering would silently break them.
This commit is contained in:
2 files changed
+25
No files matched your search
@@ -109,6 +109,20 @@ Render `<DeepLinkHandler />` **inside** `<BrowserRouter>` so `useNavigate()` wor
|
||||
</BrowserRouter>
|
||||
```
|
||||
|
||||
**A deep link is an untrusted navigation.** Any web page the user visits can
|
||||
open `myapp://whatever` — no prompt, no gesture beyond the tap that got them to
|
||||
the page. `DeepLinkHandler` turns that into a `navigate()` call, so a custom
|
||||
scheme lets an attacker put the user on any route in your app. Universal links
|
||||
(`https://`) are safer, since the OS only routes them to you after verifying
|
||||
`apple-app-site-association` / `assetlinks.json`, but the app has no way to tell
|
||||
the two apart once the event arrives.
|
||||
|
||||
So: **no route may perform a side effect on mount.** A route that publishes an
|
||||
event, follows a user, sends a payment, or deletes something as soon as it
|
||||
renders is an action any website can trigger silently. Render a confirmation
|
||||
the user has to click instead. If your app has no custom scheme, restricting
|
||||
the handler to `url.protocol === 'https:'` is worth doing as well.
|
||||
|
||||
### 7. Add platforms and build
|
||||
|
||||
```bash
|
||||
|
||||
@@ -14,6 +14,17 @@ import { Capacitor } from '@capacitor/core';
|
||||
* Must be rendered **inside** a `<BrowserRouter>` (so `useNavigate` works).
|
||||
* Safe to render unconditionally — on web it is a no-op.
|
||||
*
|
||||
* ## Deep links are untrusted input
|
||||
*
|
||||
* Any web page the user visits can open `myapp://anything`, which arrives here
|
||||
* and becomes a `navigate()` call. Universal links are verified by the OS;
|
||||
* custom schemes are not, and the `appUrlOpen` event does not distinguish
|
||||
* them. Treat the destination as attacker-chosen: **no route may perform a
|
||||
* side effect on mount** (publishing an event, following, paying, deleting).
|
||||
* Such a route is an action any website can trigger without the user knowing.
|
||||
* Require a click on the page instead. Apps with no custom scheme should also
|
||||
* reject anything but `url.protocol === 'https:'` below.
|
||||
*
|
||||
* To enable deep links:
|
||||
*
|
||||
* **iOS (Universal Links):**
|
||||
|
||||
Reference in new issue
Block a user