{"id":"XE-13400","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"562","source_url":"https://github.com/xeprotocol/xe/issues/562","reporter_id":2252,"title":"Web vault caches plaintext wallet passphrase in sessionStorage for 30 minutes with auto-unlock","area":"sdk-docs-web","claimed_tier":"minor","assessed_tier":null,"verdict":"duplicate","duplicate_of":null,"tracked":true,"internal_ref":"#1088","internal_url":"https://github.com/xeprotocol/core/issues/1088","status":"closed","closed_reason":"duplicate","github_state":"closed","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-14T20:42:17.210520+00:00","updated_at":"2026-11-20T19:46:07.258967+00:00","source_created_at":"2026-11-14T13:15:24+00:00","told_at":"2026-11-20T19:45:40+00:00","status_changed_at":"2026-11-20T19:45:35.322543+00:00","url":"https://bounty.xe.network/XE-13400","body":"Suggested tier: Low (up to 100 XE), borderline Informational — team may rate Informational\n\nXE address (reward destination): 9b663fdac108be34a3b715ef78a9f9bd878af6ef8142f388c6514918e6852dd7\n\n## Summary\n\n`web/assets/vault.js`, `cacheUnlock()` (l.189–198, testnet-0005, commit `89a542e`) stores the vault passphrase **in plaintext** in `sessionStorage`, and `web/assets/wallet.js`, `routeStartup()` (l.79–97) auto-unlocks the wallet from that cache on page load without asking for the passphrase:\n\n```js\n// web/assets/vault.js:186-198\nconst UNLOCK_KEY = 'xe.session.unlock';\nconst UNLOCK_TTL_MS = 30 * 60 * 1000;\n\nexport function cacheUnlock(passphrase) {\n  if (!passphrase) return;\n  try {\n    sessionStorage.setItem(UNLOCK_KEY, JSON.stringify({\n      passphrase,\n      expires_at: Date.now() + UNLOCK_TTL_MS,\n    }));\n  } catch {   }\n}\n```\n\n```js\n// web/assets/wallet.js:92-98 — auto-unlock on every page load\nconst seed = await tryCachedDecrypt(w);\nif (seed) {\n  state.passphrase = loadCachedUnlock();\n  state.seed = seed;\n  state.keyPair = await loadKeyPair(seed);\n  await activateActive();\n  return;\n}\n```\n\n`cacheUnlock` is called on every unlock path (`wallet.js:272,339,387,408`), so any unlocked session leaves the plaintext passphrase cached for up to 30 minutes.\n\n## Impact\n\nAny script that can run in the wallet page's origin — a future XSS, or a malicious browser extension with page access — can read `sessionStorage['xe.session.unlock']` and recover the plaintext passphrase. That passphrase decrypts **every** wallet in the vault (all wallets share one vault passphrase), and the seed's WebCrypto key is imported **extractable** (`web/assets/xe-block.js:75`, `loadKeyPair`: `crypto.subtle.importKey('pkcs8', pkcs8, { name: 'Ed25519' }, true, ['sign'])`), so script can also export the raw private key directly.\n\nAggravating: the UI server sets **no security headers** on the wallet pages — `api/ui.go` serves the assets via `http.FileServer` (l.63) with no `Content-Security-Policy`, no `X-Frame-Options`, and no `X-Content-Type-Options` anywhere, so there is no second layer if a script-injection path ever appears.\n\n## Honest bounds — why Low, borderline Informational\n\n- **No XSS sink was found this round.** Attacker-controlled data in the wallet/explorer JS is rendered via `textContent`/`createElement`; every `innerHTML` use is a static string; no `eval`, `document.write`, `insertAdjacentHTML`, `outerHTML`, or `new Function`. Wallet pages load no third-party scripts.\n- `sessionStorage` is origin-scoped and per-tab (cleared when the tab closes), so the cache does not survive a browser restart and is not readable from another origin.\n- The vault crypto itself is solid: AES-256-GCM, PBKDF2-HMAC-SHA256 with 600k iterations, random salt/IV, encrypted recovery phrase stored separately. The weakness is the plaintext cache, not the encryption.\n- This is therefore a **defence-in-depth / hardening** finding: it turns any future script-injection bug (or a malicious extension) from a session hijack into full wallet compromise. The team may reasonably rate it Informational.\n\n## Steps to reproduce (code-level, no live wallet needed)\n\n1. Clone the audited commit: `git clone https://github.com/xeprotocol/xe && git rev-parse HEAD  # 89a542e`\n2. `web/assets/vault.js:189` — `cacheUnlock()` writes `{passphrase, expires_at: now+30min}` to `sessionStorage` under `xe.session.unlock`.\n3. `web/assets/wallet.js:79` — `routeStartup()` calls `tryCachedDecrypt()` and, on success, activates the wallet without prompting.\n4. In a browser with the vault open: unlock once, then run `JSON.parse(sessionStorage.getItem('xe.session.unlock'))` in the console — the plaintext passphrase is returned.\n5. `web/assets/xe-block.js:75` — `importKey(..., true, ...)` confirms the key is extractable.\n6. `api/ui.go:63` — the file server sets no CSP / frame / content-type headers.\n\n## Root cause\n\n`web/assets/vault.js:189-198` persists the plaintext passphrase instead of keeping the decrypted key in memory only (or storing a wrapped key); `web/assets/wallet.js:79-97` trusts that cache for silent auto-unlock.\n\n## Prior art — why this is filed separately from #66 point 4\n\n#66 point 4 (Oct 26, closed) raised this topic as a documentation question: the docs state the passphrase \"can be cached in sessionStorage for up to 30 minutes\" and asked the team to \"review\" script-injection protections. This issue is the concrete, code-level confirmation of that question, with evidence #66 did not have: the exact functions (`cacheUnlock` vault.js:189-198, auto-unlock `routeStartup` wallet.js:79-97, all four call sites), a reproduction (read the plaintext passphrase from the console after one unlock), and the extractable-key aggravation (`importKey(..., true, ...)` xe-block.js:75 — script can export the raw private key directly). #71 covers the missing security headers separately. The team may still rate this Informational or a duplicate of #66 — filed because the mechanism is now proven in code, not just documented.\n\n## Suggested fix\n\nNever persist the plaintext passphrase — keep the decrypted seed/key in memory only for the session (or store a key wrapped under a per-session key that never leaves memory). Add `Content-Security-Policy: script-src 'self'` plus `X-Frame-Options` and `X-Content-Type-Options` to the UI server, and import keys with `extractable: false`.","patch_refs":[],"thread":[{"id":14974,"source":"github","source_ref":"7049027084","author":"Joseph Denne","team":true,"body":"Thanks. This is the same finding as an earlier report that is not public, which was filed first; the programme pays the\nfirst verifiable submission, so this one closes as a duplicate. If you believe it is a different\nbug, file a new report that links https://bounty.xe.network/XE-13400 and says what differs; it is read like any other.","created_at":"2026-11-20T19:45:40+00:00"}]}