Avoid persisting Cashu proofs in localStorage#511
Open
ayushshrivastv wants to merge 5 commits into
Open
Conversation
…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)
Contributor
|
@calvadev can you review it once whenever feasible? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
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 fromnostr-helper-functions.ts.Every
localStorage.setItem("tokens", JSON.stringify(...))across the codebase across 9 components is replaced withsetCachedCashuProofs(...), legacy localStorage tokens are migrated, and transaction critical wallet paths no longer depend ongetLocalStorageData().tokens. This avoids exposing spendable proofs through browser storage.