Web vault caches plaintext wallet passphrase in sessionStorage for 30 minutes with auto-unlock
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; everyinnerHTMLuse is a static string; noeval,document.write,insertAdjacentHTML,outerHTML, ornew Function. Wallet pages load no third-party scripts. sessionStorageis 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)
- Clone the audited commit:
git clone https://github.com/xeprotocol/xe && git rev-parse HEAD # 89a542e web/assets/vault.js:189—cacheUnlock()writes{passphrase, expires_at: now+30min}tosessionStorageunderxe.session.unlock.web/assets/wallet.js:79—routeStartup()callstryCachedDecrypt()and, on success, activates the wallet without prompting.- 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. web/assets/xe-block.js:75—importKey(..., true, ...)confirms the key is extractable.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
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.