Security model
| Threat | Mitigation |
|---|---|
| Parent page JS reading your nsec | Key lives only in a cross-origin iframe; Same-Origin Policy makes it unreachable |
| Owner of the clientId obtaining users' keys | Not prevented. The owner controls the Web3Auth project's allowlist, so they can run Web3Auth on a page of their own and get the key of any user who signs in there (true of every Web3Auth embedded wallet). Users trust the app owner with the identity they create in that app; users who don't sign in with their own extension or bunker |
| Browser extension / XSS on parent page | Same isolation — the iframe context is physically separate |
| Domain spoofing to steal Web3Auth quota | The page origin must be in the NIP-33 registry on Nostr or in the clientId's Web3Auth allowlist (only its owner can edit it); the registrar only registers allowlisted origins. The registry's root key is built into the signer, so a page can't point the signer at a registry it signed itself. Shared sign-in is open to every site by design |
| A site obtaining shared-mode users' keys | The shared project's Web3Auth allowlist lists only the signer's origin, so no site can run Web3Auth with its clientId. If someone adds a site there, the signer pauses new shared sign-ins and a check every 6 hours alerts the operator (Watching the shared project) |
| Rogue iframe injected by attacker | event.source === window.parent check + _parentOrigin derived from document.ancestorOrigins (not URL params) |
| Host page hiding or covering a prompt (clickjacking) | Approve, Allow, Unlock and reveal-key buttons react only 0.7 s after they appear, after the iframe is resized, or after the tab becomes visible again; in Chromium, also only while the browser vouches that nothing covers or hides them. In shared sign-in, where any site may embed the signer, decrypts, profile, follow-list and relay-list replacements, deletions, Evolustr app keys and key export are shown in a popup on the signer's own origin, which no page can frame or style (two clicks). Moving the iframe under the cursor without resizing it isn't detected in the iframe itself |
| A third site framing the app | The signer refuses to run when the page that embeds it is itself inside a frame (NESTED_FRAME): only the direct parent's origin is known |
| null-origin postMessage attacks | All window.addEventListener("message") handlers reject event.origin === "null" unconditionally |
Production Hardening Checklist
One-time setup
- [ ] Set the repository variable
ROOT_PUBKEY_HEX(and optionallyREGISTRY_RELAYS) - [ ] Run
wrangler secret put ROOT_PRIVATE_KEY_HEX— never commit the private key - [ ] Create both KV namespaces (
REGISTRY_KV,CHALLENGES_KV) and updatewrangler.tomlIDs - [ ] Add
CLOUDFLARE_API_TOKENandCLOUDFLARE_ACCOUNT_IDas GitHub repository secrets - [ ] Enable GitHub Pages (Settings → Pages → Source: GitHub Actions)
- [ ] Update
registrarUrl(andportalClientId) insite-config.js - [ ] Shared sign-in: set
VITE_SHARED_CLIENT_IDto a Web3Auth project of your own whose allowlist lists only your signer's origin (SHARED_CLIENT_IDinbunker/src/lib/shared.tsis the hosted signer's, used only on its origins), or leave it empty for none; list that origin inscripts/sharedProjectExpected.json(production)
After first deploy
- [ ] Pass
bunkerOrigin(your signer's origin) toNostrBridge.init()— otherwise the hosted signer is used - [ ] Add SRI hashes to CDN
<script>tags insigner.html - [ ] Restrict
Access-Control-Allow-Origininregistrar-worker.jsto your admin origins - [ ] Configure
REGISTRY_RELAYSinsigner.htmlto relays you control or trust - [ ] Set up Cloudflare Rate Limiting rules on the registrar endpoints
- [ ] Configure your Web3Auth dashboard verifiers to match your
clientId