<!-- XE-13400 · Web vault caches plaintext wallet passphrase in sessionStorage for 30 minutes with auto-unlock · testnet -->
*Markdown view of <https://bounty.xe.network/XE-13400>. The page is the record; this is the same page for reading.*

XE-13400 · Bounty

# Web vault caches plaintext wallet passphrase in sessionStorage for 30 minutes with auto-unlock

Closed · duplicate
—claimed Minor
[xe#562](https://github.com/xeprotocol/xe/issues/562)
filed 2026-11-14 13:15 UTC
by AIRDROP TREASURESS

Verdict
:   Duplicate

Tier
:   —

Claimed
:   Minor

Area
:   SDK / docs / web

Duplicate of
:   —

Tracked
:   internally

Updated
:   2026-11-20 19:46 UTC

Told
:   2026-11-20 19:45 UTC

### Patches

None linked.

### History

- [626985](https://bounty.xe.network/log/626985) 2026-11-20 19:46 UTC github.state\_pushed
- [626927](https://bounty.xe.network/log/626927) 2026-11-20 19:46 UTC github.labels
- [625261](https://bounty.xe.network/log/625261) 2026-11-20 19:45 UTC reply.mirrored
- [624869](https://bounty.xe.network/log/624869) 2026-11-20 19:45 UTC proposal.adopted
- [624868](https://bounty.xe.network/log/624868) 2026-11-20 19:45 UTC reply.sent
- [624867](https://bounty.xe.network/log/624867) 2026-11-20 19:45 UTC ticket.status new → closed
- [620168](https://bounty.xe.network/log/620168) 2026-11-20 19:44 UTC proposal.adopted
- [620167](https://bounty.xe.network/log/620167) 2026-11-20 19:44 UTC ticket.facts area
- [620166](https://bounty.xe.network/log/620166) 2026-11-20 19:44 UTC proposal.adopted
- [620165](https://bounty.xe.network/log/620165) 2026-11-20 19:44 UTC ticket.facts
- [620164](https://bounty.xe.network/log/620164) 2026-11-20 19:44 UTC proposal.adopted
- [620163](https://bounty.xe.network/log/620163) 2026-11-20 19:44 UTC ticket.facts

[Full history](https://bounty.xe.network/log?ref=XE-13400) · [JSON](https://bounty.xe.network/v1/tickets/XE-13400) · [markdown](https://bounty.xe.network/XE-13400.md)

### Report

Suggested tier: Low (up to 100 XE), borderline Informational — team may rate Informational

XE address (reward destination): 9b663fdac108be34a3b715ef78a9f9bd878af6ef8142f388c6514918e6852dd7

## Summary

`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:

```
// web/assets/vault.js:186-198
const UNLOCK_KEY = 'xe.session.unlock';
const UNLOCK_TTL_MS = 30 * 60 * 1000;

export function cacheUnlock(passphrase) {
  if (!passphrase) return;
  try {
    sessionStorage.setItem(UNLOCK_KEY, JSON.stringify({
      passphrase,
      expires_at: Date.now() + UNLOCK_TTL_MS,
    }));
  } catch {   }
}
```

```
// web/assets/wallet.js:92-98 — auto-unlock on every page load
const seed = await tryCachedDecrypt(w);
if (seed) {
  state.passphrase = loadCachedUnlock();
  state.seed = seed;
  state.keyPair = await loadKeyPair(seed);
  await activateActive();
  return;
}
```

`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.

## Impact

Any 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.

Aggravating: 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.

## Honest bounds — why Low, borderline Informational

- **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.
- `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.
- 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.
- 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.

## Steps to reproduce (code-level, no live wallet needed)

1. Clone the audited commit: `git clone https://github.com/xeprotocol/xe && git rev-parse HEAD # 89a542e`
2. `web/assets/vault.js:189` — `cacheUnlock()` writes `{passphrase, expires_at: now+30min}` to `sessionStorage` under `xe.session.unlock`.
3. `web/assets/wallet.js:79` — `routeStartup()` calls `tryCachedDecrypt()` and, on success, activates the wallet without prompting.
4. 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.
5. `web/assets/xe-block.js:75` — `importKey(..., true, ...)` confirms the key is extractable.
6. `api/ui.go:63` — the file server sets no CSP / frame / content-type headers.

## Root cause

`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.

## Prior art — why this is filed separately from #66 point 4

#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.

## Suggested fix

Never 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`.

### Thread

**Joseph Denne**team2026-11-20 19:45 UTCgithub

Thanks. This is the same finding as an earlier report that is not public, which was filed first; the programme pays the
first verifiable submission, so this one closes as a duplicate. If you believe it is a different
bug, file a new report that links https://bounty.xe.network/XE-13400 and says what differs; it is read like any other.
