Skip to content

Avoid persisting Cashu proofs in localStorage#511

Open
ayushshrivastv wants to merge 5 commits into
shopstr-eng:mainfrom
ayushshrivastv:ayushshrivastv/avoid-cashu-proof-localstorage
Open

Avoid persisting Cashu proofs in localStorage#511
ayushshrivastv wants to merge 5 commits into
shopstr-eng:mainfrom
ayushshrivastv:ayushshrivastv/avoid-cashu-proof-localstorage

Conversation

@ayushshrivastv
Copy link
Copy Markdown
Contributor

@ayushshrivastv ayushshrivastv commented Jun 4, 2026

Shopstr saves decrypted Cashu wallet proofs directly into browser localStorage under tokens. Anyone with DevTools access can open Application storage or just run localStorage.getItem("tokens") and copy spendable wallet proofs... which can lead to fund theft.

shopstr/pages/_app.tsx

Lines 786 to 788 in e1f7dc3

localStorage.setItem(
"tokens",
JSON.stringify(walletResult.cashuProofs)

the core change is: stop writing spendable Cashu proofs to localStorage["tokens"] and instead hold them in a module level in memory variable, accessed via a setCachedCashuProofs() setter exported from nostr-helper-functions.ts.

Every localStorage.setItem("tokens", JSON.stringify(...)) across the codebase across 9 components is replaced with setCachedCashuProofs(...), legacy localStorage tokens are migrated, and transaction critical wallet paths no longer depend on getLocalStorageData().tokens. This avoids exposing spendable proofs through browser storage.

…alStorage under tokens. Anyone with DevTools access can open Application storage or run localStorage.getItem("tokens") and copy spendable wallet proofs, which can lead to fund theft.

[_app.tsx](https://github.com/shopstr-eng/shopstr/blob/e1f7dc33b8d75201f55d223941a3a18e6599699e/pages/_app.tsx#L786-L788)
@ayushshrivastv ayushshrivastv marked this pull request as ready for review June 4, 2026 09:54
@GautamBytes
Copy link
Copy Markdown
Contributor

@calvadev can you review it once whenever feasible?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants