security(web): move the web app to its own origin, app.mostro.network, with a gradual migration
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- flutter
- Ambito
- infrastructure, mobile, security
Direzione di ricerca
Start by reading .github/workflows/web-build.yml, CLAUDE.md § Web, and the referenced migration entry points: account_screen.dart, backup_ritual_screen.dart, and IdentityService. Map the work across hosting, deployment, migration screens, translations, announcements, and the rescue page; verify each phase against its exit criteria. Done means both origins work through the published transition, users can migrate safely, and old links continue to reach the new app.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem
The web app is served at https://mostro.network/app/. For the browser, the security boundary is the origin (scheme + host + port), not the path. So the app shares its origin, https://mostro.network, with every other site the org publishes under that domain. Today (gh api repos/MostroP2P/<repo>/pages) that is 10 repositories:
| Repo | Path | Build |
|---|---|---|
MostroP2P.github.io |
/ (the root) |
workflow |
protocol |
/protocol/ |
workflow |
docs-english |
/docs-english/ |
workflow |
docs-spanish |
/docs-spanish/ |
workflow |
mostro-cli-book |
/mostro-cli-book/ |
workflow |
golazo |
/golazo/ |
workflow |
blog |
/blog/ |
legacy Jekyll |
mostro |
/mostro/ |
legacy Jekyll |
mostrix |
/mostrix/ |
legacy Jekyll |
app |
/app/ |
workflow |
Any JavaScript that runs on any of those pages runs as the app, as far as the browser is concerned. It could come from a malicious PR, a compromised npm dependency or Jekyll theme in a docs build, or an XSS in a blog post. Such a script can:
- Read the user's seed. The 12 words are stored with
flutter_secure_storage(lib/core/services/identity_service.dart). On web,flutter_secure_storage_web2.1.1 encrypts them with AES-GCM, but it stores the raw AES key in the samelocalStorage, next to the ciphertext. We pass nowrapKey, so the key is not wrapped. A script onmostro.network/blog/can read both entries, decrypt the seed and send it out. The seed gives the identity and every trade key. - Read all the app's data in IndexedDB: trades, chat history, bond payout claims.
- Open
/app/in an iframe or a window and drive it: read its DOM, call into it, act as the user. - Take over the app persistently. The root repo can do this directly. Any other repo can do it too by unregistering the app's service worker, since
getRegistrations()returns every registration of the origin. A service worker scoped to/can intercept and replacemain.dart.jsand the wasm, and it stays installed after the malicious code is removed.
Encrypting harder inside the same origin does not fix this: any key the app can use, a same-origin script can use too. Even a non-extractable WebCrypto key can still be asked to decrypt. The only fix is to give the app its own origin.
Proposal
Serve the web app from https://app.mostro.network/.
- A different origin.
localStorage, IndexedDB, service workers and window access are isolated from the other nine sites. It stays same-site withmostro.network, but that only matters for cookies, and the app uses none. - One repository to trust instead of ten.
- #951 gets simpler. Android App Links and iOS Universal Links need
/.well-known/assetlinks.jsonand/.well-known/apple-app-site-associationat the root of the host. Onmostro.networkthat root belongs to another repo (MostroP2P.github.io). Onapp.mostro.networkthis repo publishes them itself. - No sub-path.
--base-hrefbecomes/, which removes a whole class of "blank page" mistakes (CLAUDE.md§ Web).manifest.jsonand the FCM worker registration are already relative, so they follow.
The rest of this issue is about doing it without trauma: both URLs work at the same time while users move, nobody loses funds or access, and the links already shared keep working.
Constraints that shape the plan
- The new origin starts empty. The browser will not share the old origin's storage with the new one. Each user moves their identity by backing up the seed on the old site and importing it on the new one. Then:
- the trade history comes back through the restore (#813);
- bond payout claims do not: per
CLAUDE.mdthey live in their ownbond_claimsstore and "no restore brings back" them. Users must settle open claims (and ideally open trades) before moving.
- No automatic transfer of the seed between origins. A
postMessage/iframe handoff is technically possible. But it is exactly the kind of code that, if wrong, hands the seed to the wrong origin, and the old origin is the one this issue says cannot be trusted. Manual backup → import is simpler. It is also honest: the seed was exposed to the whole origin, and users should know it. Never put the seed in a URL either: fragments end up in history and sync. - One GitHub Pages site per repo, one custom domain per site. The old path
mostro.network/app/exists only because the repo is namedappand inherits the org's domain. As soon as theapprepo gets a custom domain, GitHub redirectsmostro.network/app/*to it (to verify against the current Pages docs before relying on it). So one repo cannot serve both URLs at the same time. During the transition a second repo has to serve one of them. - The first run has no import. Today a seed is imported only from Account (
account_screen.dart→IdentityService), after the first run created a fresh identity. A migrating user should be steered to import, not left with a new empty identity. - The base path is derived from the repo name in
.github/workflows/web-build.yml(--base-href "/${GITHUB_REPOSITORY#*/}/", andBASE_PATHfor every smoke run). It needs to become an input.
Phases
Phase 0: preparation (no user-visible change)
- Verify
mostro.networkfor the org (Organization settings → Pages → Verified domains). Otherwise any GitHub user could claim a dangling*.mostro.networkPages domain (subdomain takeover).status.mostro.networkandstore.mostro.networkalready show subdomains are used, so this protects them too. - DNS:
app.mostro.network CNAME mostrop2p.github.io.(whoever manages the zone). - Create the subdomain's repo, e.g.
MostroP2P/app-web. It holds no app code, only a deploy workflow and the Pages setting (custom domainapp.mostro.network, Enforce HTTPS). - Make the base path an input of
web-build.yml(base-href, default/${repo}/), passed toflutter build web,pages_bundle_test.dartand everyBASE_PATH=… node smoke.mjs. CI runs the smoke test for both/app/and/, so the root build is proven before anyone uses it. - Check that
actions/upload-pages-artifactkeeps dot-folders, so.well-known/survives for #951. If it drops them, find the switch or the workaround now.
Phase 1: both sites serve the same app (silent)
- On every merge to
main, the same commit is built twice:apprepo →mostro.network/app/(unchanged,--base-href /app/);app-webrepo →app.mostro.network/(--base-href /).
- How
app-webdeploys: its own workflow, triggered by arepository_dispatchthatdeploy-pages.ymlsends after a successful deploy (fine-grained token,contents: readonapp-webonly, as a secret). It calls the reusableMostroP2P/app/.github/workflows/web-build.yml@<sha>withbase-href: /, thenactions/deploy-pages. The build stays defined in one place (theCLAUDE.mdrule forweb-build.yml), and both sites ship the same commit. - Nothing tells users yet. The team uses
app.mostro.networkfor a while and runs the smoke checks against it:- cross-origin isolation through the coi shim;
- the Rust bridge answering;
- the IndexedDB stores;
- a Blossom upload from the new origin (CORS);
- installability (
SMOKE_INSTALLABLE).
- Exit criterion: a full trade, chat with an attachment, a dispute chat and a restore work on
app.mostro.network.
Phase 2: the app learns to migrate (one release, both sites)
The code behaves differently by origin, which it reads at runtime (Uri.base), so one bundle serves both.
On the old origin (mostro.network):
- A banner on Book, dismissible but returning: "Mostro has a new address: app.mostro.network. Move your account." It is dismissible so trading is never blocked.
- A "Move to the new address" screen (Settings and banner), a guided checklist:
- Open trades: lists trades not finished yet, using the existing in-progress lookup, and advises finishing them first. It does not block: they can be restored on the new site.
- Open bond payout claims: blocks until settled or explicitly acknowledged. They are lost otherwise.
- Back up the 12 words (the existing backup ritual,
backup_ritual_screen.dart), unless already confirmed. - "Open app.mostro.network": opens
https://app.mostro.network/#/migratein a new tab, with no seed or data in the URL.
- Optionally, once the user confirms they finished on the new site, "Forget this browser's account here": the existing
delete_identitywipe on the old origin. Then a leak of the old origin no longer holds their seed.
On the new origin (app.mostro.network):
#/migrate(first run or not): explains the move, then imports the 12 words, with the same validation as Account (validate_mnemonic). The restore (#813) brings back the trades.- On the first run: the walkthrough is skipped or shortened, and the node choice is replaced by the node the restore finds, or the default. No throwaway identity is created first.
- Not on the first run: the import goes through the existing identity replacement.
- A first run without
#/migrateoffers "I already use Mostro: import my words" next to starting fresh. Users who type the new address by hand reach the import too.
Translations: all 7 locales, as usual.
Phase 3: announce (time-boxed transition)
- An announcement (kind 38387,
docs/ANNOUNCEMENTS.md) in all seven locales, plus the project's social channels: the new address, why, and the steps. - Docs and links point to
app.mostro.network: README,docs/DEEP_LINKS.md, node links (#950), the PWA instructions. - The transition window is set and published, e.g. 3 months. During it both sites run the same code. The old one keeps its banner, and its messages grow more insistent as the date nears.
- Installed PWAs (#658): the old installed app keeps working on the old origin. The migration screen tells users to install the new one and remove the old one, since a manifest cannot move across origins.
Phase 4: the old address becomes a rescue page, then a redirect
At the end of the window, mostro.network/app/ stops serving the app. It serves a small static page instead (no Flutter, no Rust):
- If this browser still holds an account on the old origin, the page offers to show the 12 words, one deliberate click, so nobody who missed the window loses their identity. It reads them the same way the app did: the
flutter_secure_storage_webentries inlocalStorage, decrypted with the key stored next to them. Same exposure as today, for the last time, and only on request. Then it offers to wipe them. - Otherwise, it redirects to the new address keeping the fragment:
location.replace('https://app.mostro.network/' + location.hash). GitHub Pages has no per-path server redirects, so it is done in JS, and every…/app/#/node?mostro=…link already shared keeps working. - The page has no other script, no third-party asset, and a strict CSP in a
<meta>tag.
This page stays until traffic to it is negligible, e.g. 6–12 more months.
Phase 5 (optional): simplify the hosting
When the rescue page is retired, the app repo can take the custom domain app.mostro.network itself. GitHub's own redirect then sends mostro.network/app/* to it, and app-web is archived. Alternatively, keep app-web as the permanent host and leave the app repo's Pages off. Either way only one repo serves the app again.
Effect on other work
- #950 (node links): merge it as planned. Its links still use
mostro.network/app/#/node?…until Phase 3, and they keep working through the Phase 4 redirect. From Phase 3 on, docs showapp.mostro.network/#/node?…. - #951 (App Links / Universal Links): should target
app.mostro.networkfrom the start.assetlinks.jsongoes in this repo'sweb/.well-known/, served at the subdomain's root, and the intent filter matcheshttps://app.mostro.network/. Building it onmostro.networkwould put the domain files in another repo and the trust in ten. - Web push (
PUSH_WEB_ENABLED, docs/PUSH_NOTIFICATIONS.md T4.5): still off, so nothing to migrate. When it ships, it ships on the new origin only.
Acceptance
https://app.mostro.network/serves the app, cross-origin isolated, with the same smoke checks CI runs for/app/today.- During Phases 1–3 both addresses serve the same commit, built once per base path from
web-build.yml. - On the old origin a user can follow the guided move:
- open bond claims block it;
- the seed backup is part of it;
- the new site opens with no secret in the URL.
- On the new origin
#/migrate, and the first run, import an existing seed without creating a throwaway identity first, and the restore brings back the trades. - At the end the old address serves the rescue page:
- it shows the old account's words on request;
- otherwise it redirects to the new address keeping the fragment.
mostro.networkis a verified domain of the org.CLAUDE.md(§ Web),docs/DEEP_LINKS.mdand the README describe the new address.
Open questions
- Name of the subdomain's repo (
app-web?webapp?) and who manages themostro.networkDNS zone. - Length of the transition window (Phase 3) and of the rescue page (Phase 4).
- Should Phase 2's old-origin wipe ("forget this browser's account") be offered right after the import, or only once the new site has finished a restore?
- Do we want the rescue page to show the words at all, or only point to "open the old app version" for a while longer?
Related
- #950, #951: node links and App Links. #951 should target the new host.
- #658: installable web app.
- #813: restore after a node switch, the mechanism that brings trades back on the new site.
docs/ANNOUNCEMENTS.md: the channel for the announcement.
- Lingua principale
- Dart
- Stelle
- 11
- Fork
- 9
- Merge medio
- 2g 1h
- PR unite (30g)
- 16
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di MostroP2P/app
-
documentation priority: low
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
I maintainer di solito rispondono entro 1 giorno
-
area: ui bug priority: medium
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
area: ui bug priority: high
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
Bug: Button "Share logs" does nothingForse già presa @Luquitasjeffrey l’ha presa 8 giorni fa. Aperta
Difficoltà 2/5 Mezza giornata Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
area: rust-core bug priority: low
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di MostroP2P/app
Issue simili
-
Python example: list a model's scenes and their camerasForse già presa @rudraparmar76 l’ha presa oggi. Apertadocumentation good first issue python
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
iamahsanmehmood/openskp#796 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
needs triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
-
Plural rendering: first matching part wins, but gen-l10n lets the last one win (=1 shadows one)Apertabug help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
crowdin/flutter-sdk#97 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 63/100
MrSpideyNihal/lockfeed#16 ·
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
InlitX/GymMane#529 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno