-
Notifications
You must be signed in to change notification settings - Fork 17
[PM-22136] Expose encrypt_fido2_credentials to support cipher encryption in TS clients #331
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
…use by the TS clients
Great job, no security vulnerabilities found in this Pull Request |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #331 +/- ##
==========================================
- Coverage 71.88% 71.85% -0.04%
==========================================
Files 240 240
Lines 19625 19635 +10
==========================================
Hits 14108 14108
- Misses 5517 5527 +10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Can we please provide some more information about why this is needed? The mobile clients uses this implementation so if we have issues with fido 2 credentials not being encrypted correctly that would apply to mobile as well and is something we need to address.
Necessary while the FIDO2 credentials remain in the LoginView in an encrypted form.
As in you want to expose them decrypted? That shouldn't be necessary ever. Or you want to remove it once the SDK can load from state?
It's there in encrypted form so that we can generate a cipher key if needed as we have to re-encrypt the whole object.
Changes look good. Just waiting for the request changes to come in before approving |
The TS clients do not currently use the SDK for creating fido 2 credentials. So, whenever we encrypt ciphers with new credentials with the SDK we do not have an encrypted copy to pass along to the SDK. In order to use the SDK for all encryption, we need to expose this method in the meantime to explicitly encrypt the fido2 credentials. Mobile uses the SDK for Fido2 credential creation so they don't need to worry about encrypting the credentials manually. Once the TS clients use the SDK for Fido2 credential management (PM-8313) we'll be able to remove this and the decrypted Fido2Credentials from the LoginView in the TS clients.
Yep, we can remove the credentials from the LoginView once the SDK can load from state. Then we won't need to always pass the encrypted fido 2 credentials back and forth (as far as I understand it) |
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.
There is a set_new_fido2_credentials
on CipherView
for this purpose which is currently used internally in the sdk for the fido authenticator. This can probably be exposed with some simple glue code.
sdk-internal/crates/bitwarden-vault/src/cipher/cipher.rs
Lines 563 to 575 in f2bc708
pub fn set_new_fido2_credentials( | |
&mut self, | |
ctx: &mut KeyStoreContext<KeyIds>, | |
creds: Vec<Fido2CredentialFullView>, | |
) -> Result<(), CipherError> { | |
let key = self.key_identifier(); | |
let ciphers_key = Cipher::decrypt_cipher_key(ctx, key, &self.key)?; | |
require!(self.login.as_mut()).fido2_credentials = | |
Some(creds.encrypt_composite(ctx, ciphers_key)?); | |
Ok(()) |
cipher_view.set_new_fido2_credentials(creds);
|
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.
LGTM
🎟️ Tracking
PM-22136
📔 Objective
The TS clients use fully decrypted FIDO2 credentials which need to be re-encrypted separately before using the SDK to encrypt the rest of the Cipher. Otherwise, the FIDO2 credential encryption key will be lost.
Once the decrypted FIDO2 Credentials are removed from the LoginView in TS, this method can be removed.
Related Clients PR: bitwarden/clients#15337
⏰ Reminders before review
team
🦮 Reviewer guidelines
:+1:
) or similar for great changes:memo:
) or ℹ️ (:information_source:
) for notes or general info:question:
) for questions:thinking:
) or 💭 (:thought_balloon:
) for more open inquiry that's not quite a confirmedissue and could potentially benefit from discussion
:art:
) for suggestions / improvements:x:
) or:warning:
) for more significant problems or concerns needing attention:seedling:
) or ♻️ (:recycle:
) for future improvements or indications of technical debt:pick:
) for minor or nitpick changes