Minimise key persistence, secure password entry #2111
kyranjamie
started this conversation in
Ideas
Replies: 2 comments 2 replies
-
How would secure password entry field authenticate the background script prior to forwarding the clear text password? |
Beta Was this translation helpful? Give feedback.
1 reply
-
Is 2FA an option for browser extension as additional security measure? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Working on implementing Ledger support, I've been thinking about the way we manage keys in the wallet, and how this might be improved for software wallet users.
The wallet was implemented with a pattern that uses the background script to cache the seed phrase, once unlocked with the user's password. When a user opens the wallet, the popup script asks the background script if there are any keys, and—if there are—returns the entire wallet state object, which includes the plaintext private key. This practice is not dissimilar to Metamask.
The wallet's UI, a the React app ran in the pop up script, is the part of the software most susceptible to XSS attacks, supply chain attacks etc. As such there's a greater risk having the key there, than in the background script, for similar reasons to why the background script has access to browser APIs the popup does not.
Ideally, then, we should design the wallet in such a way where the plaintext key is only ever in memory of a single script's context (the background), as this would limit the opportunities for such attacks. Could the background script, the more isolated context, function like a hardware wallet: accepting unsigned transactions, asking for the password, decrypting the key, signing and returning the transaction?
Consider that the only time the plaintext key is needed is when:
This has left me wondering if it'd be possible to create separate, dependency-free pop up windows with tight content security policies, that communicates only with the background script, to accept the password needed to decrypt the key. This way, the main package-heavy app would never have access to any of the information needed to steal funds.
If it's possible to securely send messages only to the background script, this would make for a much more secure design. The flow would look something like this:
Curious to get everyone's feedback. Started this as a discussion as I'm not 100% this type of message passing is possible.
Edit 2022-01-24
Had another look into this and validated this could work.
tabId
sender
s originsendResponse
method of the event, which is returned only to the message's sender (the bg script). User's password is returned directly to bg scriptMore handling would be needed for wrong passwords etc, but overall this would allow the main app's code to never need to know the secret key.
Edit 2022-08-09
Rephrased discussion for clarity, added diagram
Beta Was this translation helpful? Give feedback.
All reactions