Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Security Concerns #1

Open
Damar225 opened this issue Mar 3, 2023 · 2 comments
Open

Security Concerns #1

Damar225 opened this issue Mar 3, 2023 · 2 comments

Comments

@Damar225
Copy link

Damar225 commented Mar 3, 2023

Hello, First I want to thank you for your effort to the open source community.

I saw in the doc you said that:

"It will not be secure against an attacker that inspects the source code of the page (eg: browser extensions) to find the key and can run arbitrary scripts on your origin to decrypt the stored state."

Can you please give some light on this statement, or give us a real world example on how an attacker could reach the private key?

Thank you.

@franky47
Copy link
Member

franky47 commented Mar 3, 2023

There are two parts to such an attack/threat model:

Recovery of the secret

Since the key is static, it may be extracted by inspecting the JavaScript bundle that is shipped to the browser. While client-side code has no such capability, browser extensions can inspect (and modify) network request payloads. So a malicious extension could extract the key.

Arbitrary code execution

We've already covered a malicious browser extension, that would have access to the origin local storage and the key.

Another would be arbitrary code execution from a third party. Since modern applications include hundreds (if not thousands) of dependencies, some of which get bundled in the final code that is executed on the client, it is possible that some untrusted code may access the local storage. To that, we can add unvetted runtime inclusion of third party code (eg: Google Tag Manager).

Coupled with the first part, it would allow them to use an instance of local-state-sync to receive a copy of the secret state (or perform the same operations to decrypt it, but why bother when there's already code to do it for you).


As a side note, this package was an experiment, I'm not sure it's actually possible to protect any kind of secret in the browser until browser APIs offer an interface to the system's keychain. The use of hardware security keys (eg: Yubikey) or enforcing to use modern authentication systems (like WebAuthn / passkeys) may help provide a solution. This is why I'm not publishing v1.0.0 in this state (there will need to be many breaking changes until an eventual v1).

@Damar225
Copy link
Author

Damar225 commented Mar 3, 2023

Thanks, this is very helpful.

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

No branches or pull requests

2 participants