-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[PS-2251] Implement argon2 kdf #4468
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
Conversation
Thank you for your contribution! We've added this to our internal Community PR board for review. |
Currently the pull request only stores memory (in the kdfIterations value). |
The server implementation still needs some work, but in the meantime the client has been updated to support more options. |
Since in the mobile pull request we are doing the kdf support first with fixed memory and parallelism, should I split this pull request into 2 requests, one doing the kdf support (same as on mobile), and one adding the kdf configuration (since that relies on server changes anyways)? |
Yes, let's do that. I think we will probably want to deploy the client support ahead of the configuration anyways so that people can get client updates propagated out ahead of being able to enable it. |
e9801ba
to
9bae3d0
Compare
Okay, pulled out all the kdfConfiguration related changes and rebased onto latest master. |
9bae3d0
to
fcd9383
Compare
[(ngModel)]="kdfIterations" | ||
required | ||
/> | ||
<ng-container *ngIf="kdf == 0"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to expose the structured enum to the UI instead of using magic ints.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in e3a5808
/> | ||
</ng-container> | ||
<ng-container *ngIf="kdf == 2"> | ||
<label for="kdfIterations">Memory (in KiB)</label> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need i18n support
<p> | ||
{{ "argon2MemoryDesc" | i18n: (recommendedMemory | number) }} | ||
</p> | ||
<bit-callout type="warning"> {{ "argon2Warning" | i18n }}} </bit-callout> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure we need this warning. What browsers do not support WASM?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, fair. Only IE really, but I'm not even sure bitwarden supports IE anyways.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed in 2a937d0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unsure if there are other configurations out there like this (i.e., first-party supported by a major OS/browser vendor), but
- enabling Lockdown Mode on iOS disables WASM (among other browser features) on Safari and any WebView implementation in all apps (including other browser apps).
- Attempting to access the web vault via Safari or any other browser is affected.
- I don't believe the Bitwarden native iOS app is affected (AFAIK the only WebView is for webauthn)
- Lockdown Mode is also available on macOS, but AFAIK only Safari is affected.
- The Bitwarden browser extension within Safari is affected, and I have not found a way to whitelist it. But the extension is mostly functional. (The UI svg/webfont icons for "copy username", "copy password", etc, do not render and are simply shown as squares. Initial login is slow too, but reasonable as Lockdown also disables JIT. There's support for whitelisting domains from Lockdown Mode, but the
safari-web-extension://${UUID}
URIs can't seem to be whitelisted.)
- The Bitwarden browser extension within Safari is affected, and I have not found a way to whitelist it. But the extension is mostly functional. (The UI svg/webfont icons for "copy username", "copy password", etc, do not render and are simply shown as squares. Initial login is slow too, but reasonable as Lockdown also disables JIT. There's support for whitelisting domains from Lockdown Mode, but the
@@ -32,41 +32,80 @@ <h1>{{ "encKeySettings" | i18n }}</h1> | |||
> | |||
<i class="bwi bwi-question-circle" aria-hidden="true"></i> | |||
</a> | |||
<select id="kdf" name="Kdf" [(ngModel)]="kdf" class="form-control" required> | |||
<select |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need to remove this to a config PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah.
fcd9383
to
e05752c
Compare
@Hinton Can you look into the wasm implementation. Is this how we want to do it? |
Had a wrong commit from another branch on my local master, so had to force push one more time. |
By the way about the wasm implementation: The argon2-browser project states that on node.js, native bindings should be used(https://www.npmjs.com/package/argon2), which I did. WASM would also work in node.js though. We could save an implementation/dependency by only using the WASM implmentation if we don't need the extra speed since as long as it is acceptable in WASM in the browser, it should be acceptable for the CLI too speed wise, right? |
@kspearrin @quexten there is webpack flag, |
I did see this flag during development, but didn't use it as it was experimental. But it seems it is enabled under future defaults? I'll switch to it at any rate. |
Hmm, so I tried the flag and I was able to remove the line: However, still required is:
because of:
(not exactly sure yet what the exact cause is) About the CSP changes: Ideally we could use SRI hashes, but for WASM, these are unsupported in chromium. https://bugs.chromium.org/p/chromium/issues/detail?id=945121 |
libs/node/package.json
Outdated
@@ -18,6 +18,7 @@ | |||
"build:watch": "npm run clean && tsc -watch" | |||
}, | |||
"dependencies": { | |||
"@bitwarden/common": "file:../common" | |||
"@bitwarden/common": "file:../common", | |||
"argon2": "^0.30.3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Hinton Is this where we want to include the node package?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, packages should only be in the root package.json. All of these should be moved over.
For native packages in the CLI, they also need to be added to the package.json
under CLI
. And native node modules for desktop needs to be added to src/package.json
under desktop to ensure they get cross compiled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anything we need to consider for packaging for the different app stores? I only tested running in dev mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved these to root.
I toyed around with the wasm stuff on this branch. The Argon2 wasm dependency seems to work quite different from the rust one I built myself. It seems we do need the webpack changes, and the I also read up on wasm, seems they don't support sha signatures which is a pitty. I guess our general sha CSP rules protectes against arbitrary wasm being loaded though. Do we have any warnings in case the wasm execution fails due to |
@quexten I finished updating the server PR with the necessary changes. I think @justindbaur is adding some tests to it. Did you start a branch somewhere else with the separate config changes yet? |
Not yet, I have the old branch, which I need to re-base onto this. I'll do that now. |
I targeted it to this pull request's source branch for now. Let me know whether I should merge it into this PR's source or submit it separately against bitwarden's master branch. |
@quexten Let's finish cleaning up this branch, merge it, and then we can target master and open a PR for your new config branch. |
@quexten I did some work cleaning things up here. I think it is good to go after we remove the changes to web angular components and locale files. |
@quexten we will create a help document for users comparing the two algorithms. Can you update the kdf algorithms tooltip link to point to https://bitwarden.com/help/kdf-algorithms |
@micahblut We can do that in the configuration branch. |
Feedback from Bitwarden Design:
|
I reverted the config pages in web vault. Good to go for me. @Hinton for final approval. |
Co-authored-by: Martin Weinelt <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kspearrin maybe I'm missing something, but there doesn't seem to be any way to configure the argon2 options?
We should also track and show a reasonable error if we can't load the argon2 wasm and block the login on those devices / changing kdf.
Other than that I think we're good. Do we want a feature flag for this until everything is wrapped up?
Config options got rolled back in 9537c5c. So at the moment, the clients can log in if the account is configured for argon2 but there is no way to switch to argon2, or configure argon2's parameters. Separate pull request for configuration that will be re-targeted to master once this is merged is here: |
@Hinton I don't think we need a feature flag since everything is planned to be in this release. Config options will follow after this is merged. |
@quexten Please open your config PR when ready. |
@kspearrin rebased onto latest master and opened #4578 |
Type of change
Objective
This pull request implements argon2id support via wasm (and native bindings on node js).
Some points of consideration: I tested on desktop (linux), web (chrome, firefox), manifest-v2 browser (chrome), manifest-v3 browser (chrome), cli (linux). All other platforms are untested by me, any help testing is appreciated, especially on safari and edge.
For now only memory is configurable, but in a future pull request me might introduce a kdfOptions object, to expose more configuration options (iterations, parallelism) to the user.
Code changes
Screenshots