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

[PM-9473] Add messaging for macOS passkey extension and desktop #10768

Merged
merged 6 commits into from
Dec 19, 2024

Conversation

dani-garcia
Copy link
Member

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-9473

📔 Objective

📸 Screenshots

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation 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 confirmed issue 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

Copy link

codecov bot commented Aug 28, 2024

Codecov Report

Attention: Patch coverage is 5.26316% with 144 lines in your changes missing coverage. Please review.

Project coverage is 33.47%. Comparing base (b046c49) to head (0c01337).
Report is 86 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...m/services/desktop-fido2-user-interface.service.ts 0.00% 50 Missing ⚠️
.../src/autofill/services/desktop-autofill.service.ts 0.00% 46 Missing ⚠️
...src/platform/main/autofill/native-autofill.main.ts 0.00% 23 Missing ⚠️
apps/desktop/src/autofill/preload.ts 0.00% 14 Missing ⚠️
apps/desktop/src/app/services/services.module.ts 0.00% 4 Missing ⚠️
...rc/platform/services/fido2/fido2-autofill-utils.ts 0.00% 3 Missing ⚠️
apps/browser/src/background/main.background.ts 0.00% 1 Missing ⚠️
apps/desktop/src/main.ts 0.00% 1 Missing ⚠️
.../fido2/fido2-user-interface.service.abstraction.ts 0.00% 1 Missing ⚠️
...ervices/fido2/noop-fido2-user-interface.service.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10768      +/-   ##
==========================================
- Coverage   33.49%   33.47%   -0.03%     
==========================================
  Files        2897     2916      +19     
  Lines       90351    91246     +895     
  Branches    17165    17357     +192     
==========================================
+ Hits        30262    30541     +279     
- Misses      57698    58299     +601     
- Partials     2391     2406      +15     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

github-actions bot commented Aug 28, 2024

Logo
Checkmarx One – Scan Summary & Details8f3d2523-1b87-417f-b431-ce02e198d0ef

New Issues

Severity Issue Source File / Package Checkmarx Insight
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/background/overlay.background.ts: 514 Attack Vector
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/background/overlay.background.ts: 502 Attack Vector
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/background/overlay.background.ts: 496 Attack Vector
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/background/overlay.background.ts: 580 Attack Vector
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/background/overlay.background.ts: 564 Attack Vector
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/background/overlay.background.ts: 670 Attack Vector
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/background/overlay.background.ts: 657 Attack Vector
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/background/overlay.background.ts: 646 Attack Vector
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/background/overlay.background.ts: 644 Attack Vector
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/background/overlay.background.ts: 645 Attack Vector
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/background/overlay.background.ts: 656 Attack Vector
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/background/overlay.background.ts: 653 Attack Vector
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/background/overlay.background.ts: 647 Attack Vector
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/background/overlay.background.ts: 643 Attack Vector
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/overlay/inline-menu/pages/list/autofill-inline-menu-list.ts: 1108 Attack Vector
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/overlay/inline-menu/pages/list/autofill-inline-menu-list.ts: 1127 Attack Vector
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/overlay/inline-menu/pages/list/autofill-inline-menu-list.ts: 1145 Attack Vector
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/overlay/inline-menu/pages/list/autofill-inline-menu-list.ts: 1074 Attack Vector
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/overlay/inline-menu/pages/list/autofill-inline-menu-list.ts: 819 Attack Vector
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/overlay/inline-menu/pages/list/autofill-inline-menu-list.ts: 1126 Attack Vector
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/overlay/inline-menu/pages/list/autofill-inline-menu-list.ts: 1126 Attack Vector
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/overlay/inline-menu/pages/list/autofill-inline-menu-list.ts: 1128 Attack Vector
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/overlay/inline-menu/pages/list/autofill-inline-menu-list.ts: 1128 Attack Vector
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/overlay/inline-menu/pages/list/autofill-inline-menu-list.ts: 1144 Attack Vector
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/overlay/inline-menu/pages/list/autofill-inline-menu-list.ts: 1144 Attack Vector
LOW Client_JQuery_Deprecated_Symbols /apps/cli/src/service-container/service-container.ts: 878 Attack Vector
LOW Unpinned Actions Full Length Commit SHA /build-web.yml: 337 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
LOW Unpinned Actions Full Length Commit SHA /build-web.yml: 385 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
LOW Unpinned Actions Full Length Commit SHA /build-web.yml: 306 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
LOW Unpinned Actions Full Length Commit SHA /build-web.yml: 227 Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps...
LOW Unprotected_Cookie /apps/web/src/app/auth/sso.component.ts: 175 Attack Vector

Fixed Issues

Severity Issue Source File / Package
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/overlay/inline-menu/pages/list/autofill-inline-menu-list.ts: 1166
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/overlay/inline-menu/pages/list/autofill-inline-menu-list.ts: 130
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/overlay/inline-menu/pages/list/autofill-inline-menu-list.ts: 86
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/overlay/inline-menu/pages/list/autofill-inline-menu-list.ts: 38
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/background/overlay.background.ts: 565
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/overlay/inline-menu/pages/list/autofill-inline-menu-list.ts: 1074
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/overlay/inline-menu/pages/list/autofill-inline-menu-list.ts: 1074
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/overlay/inline-menu/pages/list/autofill-inline-menu-list.ts: 1074
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/background/overlay.background.ts: 670
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/background/overlay.background.ts: 693
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/background/overlay.background.ts: 671
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/background/overlay.background.ts: 680
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/background/overlay.background.ts: 679
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/background/overlay.background.ts: 673
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/background/overlay.background.ts: 663
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/background/overlay.background.ts: 664
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/overlay/inline-menu/pages/list/autofill-inline-menu-list.ts: 1238
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/overlay/inline-menu/pages/list/autofill-inline-menu-list.ts: 1238
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/overlay/inline-menu/pages/list/autofill-inline-menu-list.ts: 1220
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/overlay/inline-menu/pages/list/autofill-inline-menu-list.ts: 1220
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/background/overlay.background.ts: 515
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/overlay/inline-menu/pages/list/autofill-inline-menu-list.ts: 1239
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/overlay/inline-menu/pages/list/autofill-inline-menu-list.ts: 1221
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/background/overlay.background.ts: 503
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/background/overlay.background.ts: 497
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/overlay/inline-menu/pages/list/autofill-inline-menu-list.ts: 1171
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/background/overlay.background.ts: 581
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/background/overlay.background.ts: 662
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/background/overlay.background.ts: 665
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/background/overlay.background.ts: 661
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/overlay/inline-menu/pages/list/autofill-inline-menu-list.ts: 1237
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/overlay/inline-menu/pages/list/autofill-inline-menu-list.ts: 1045
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/overlay/inline-menu/pages/list/autofill-inline-menu-list.ts: 1219
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/overlay/inline-menu/pages/list/autofill-inline-menu-list.ts: 1221
LOW Unpinned Actions Full Length Commit SHA /build-web.yml: 370
LOW Unpinned Actions Full Length Commit SHA /build-web.yml: 339
LOW Unpinned Actions Full Length Commit SHA /build-web.yml: 418
LOW Unpinned Actions Full Length Commit SHA /build-web.yml: 230
LOW Unprotected_Cookie /apps/web/src/app/auth/core/services/login/web-sso-component.service.ts: 19
LOW Unprotected_Cookie /apps/web/src/app/auth/sso-v1.component.ts: 175
LOW Use_of_Broken_or_Risky_Cryptographic_Algorithm /libs/key-management/src/user-asymmetric-key-regeneration/services/default-user-asymmetric-key-regeneration.service.ts: 66
LOW Use_of_Broken_or_Risky_Cryptographic_Algorithm /libs/key-management/src/user-asymmetric-key-regeneration/services/default-user-asymmetric-key-regeneration.service.ts: 111

apps/desktop/desktop_native/core/src/ipc/client.rs Outdated Show resolved Hide resolved
apps/desktop/macos/autofill-extension/Info.plist Outdated Show resolved Hide resolved
//
// If instead I make this a static, the deinit gets called correctly after each request.
// I think we still might want a static regardless, to be able to reuse the connection if possible.
static let client: MacOsProviderClient = {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: Investigate why deinit wasn't always called. Maybe we leave some request unanswered?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember having similar issues when I was working on Passkey Provider PoCs. I got the feeling that swift was really bad at keeping track of references and/or really eager to garbage collect objects that are still in use. If that is the issue here then it makes sense that putting it in a static variable solves it.

Long time ago though, so takes this with a pinch of salt

apps/desktop/src/app/app.component.ts Outdated Show resolved Hide resolved
import { Command } from "../platform/main/autofill/command";
import { RunCommandParams, RunCommandResult } from "../platform/main/autofill/native-autofill.main";

export default {
runCommand: <C extends Command>(params: RunCommandParams<C>): Promise<RunCommandResult<C>> =>
ipcRenderer.invoke("autofill.runCommand", params),

listenPasskeyRegistration: (
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is API just proxies the requests from NAPI to the renderer process, and we also pass a callback so the renderer can respond.

}: PickCredentialParams): Promise<{ cipherId: string; userVerified: boolean }> {
this.logService.warning("pickCredential", cipherIds, userVerification);

return { cipherId: cipherIds[0], userVerified: userVerification };
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When doing assertion, the user already selected a cipher from the quicktype bar, so we've already set allowCredentialDescriptorList to that credential ID, which means cipherIds should only contain the correct value.


// TODO: For some reason the credentialId is passed as an empty array in the request, so we need to
// get it from the cipher. For that we use the recordIdentifier, which is the cipherId.
if (request.recordIdentifier && request.credentialId.length === 0) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: Check why the provideCredentialWithoutUserInteraction on the extension doesn't provide the credentialId. It's not a big deal because we have the cipher ID, but there's no reason why it's not returning it.

});
}

private convertRegistrationRequest(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd appreciate a second look at these four conversion methods, there's a few fields that are left undefined because the swift extension doesn't have related values, and some values I had to set myself.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some minor comments but other than that I think it looks good!

Copy link
Contributor

@coroiu coroiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quality work! 💯

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: would it have been easier to compile into a regular C compatible library and use C <> ObjC <> Swift interop? Mostly I'm just wondering if you considered that approach and if/why you decided against it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh ok nevermind, we get uniffi support. Do you think it would be worth to try and use this for the objective-c part?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case I mostly used it because we needed to deal with callbacks and holding a reference to the object from the swift side, so I avoided using C-interop because I was worried about representing those callbacks in plain C, and dealing with memory leaks and undefined behavior.

The objective-c part is simpler as it's just calling a couple of functions, so for that I think all the boilerplate from uniffi might be too much.

Comment on lines +98 to +101
info!(
"Time to process request: {:?}",
request_start_time.elapsed()
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: are you thinking we should keep this in production or was it just something we added do debug the slow requests?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this is mostly for debug purposes, I was waiting until the PR removing sync was merged to test it again.

That said it woulnd't hurt to leave it, either.

apps/desktop/desktop_native/macos_provider/src/lib.rs Outdated Show resolved Hide resolved
alg,
type: "public-key",
})),
// TODO: Marked as optional but needs to be defined?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional in the client but apparently not optional in the authenticator, can't remember why 🤷, we can just leave it like this for now. Future macOS versions will provides this though

Comment on lines 103 to 112
requireUserVerification:
request.userVerification === "required" || request.userVerification === "preferred",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: can this ever be undefined? If yes, then that should be treated as preferred

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shouldn't ever be, this struct is coming from Rust and there UserVerification is not an optional field

});
}

private convertRegistrationRequest(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some minor comments but other than that I think it looks good!

@coroiu coroiu force-pushed the ps/PM-9035-desktop-build-logic-to-provide-credentials-to-os-on-sync branch from ed0cf93 to 0a0c3ef Compare November 15, 2024 11:32
@dani-garcia dani-garcia force-pushed the ps/PM-9473-macos-passkey-desktop-messaging branch 2 times, most recently from 4c91e50 to 212519a Compare December 5, 2024 13:03
@dani-garcia dani-garcia changed the base branch from ps/PM-9035-desktop-build-logic-to-provide-credentials-to-os-on-sync to ps/PM-9473-add-uniffi-to-extension December 5, 2024 13:04
@dani-garcia dani-garcia force-pushed the ps/PM-9473-add-uniffi-to-extension branch 4 times, most recently from 9836079 to 030e138 Compare December 5, 2024 14:59
@dani-garcia dani-garcia force-pushed the ps/PM-9473-macos-passkey-desktop-messaging branch from 212519a to fe2c6cd Compare December 5, 2024 15:02
@dani-garcia dani-garcia force-pushed the ps/PM-9473-add-uniffi-to-extension branch from 030e138 to a4594f6 Compare December 5, 2024 15:03
@dani-garcia dani-garcia force-pushed the ps/PM-9473-macos-passkey-desktop-messaging branch from fe2c6cd to 0c8e074 Compare December 5, 2024 15:29
@dani-garcia dani-garcia force-pushed the ps/PM-9473-macos-passkey-desktop-messaging branch from 0c8e074 to 6262a59 Compare December 5, 2024 16:09
@dani-garcia dani-garcia force-pushed the ps/PM-9473-add-uniffi-to-extension branch from a4594f6 to d20ded9 Compare December 6, 2024 16:35
@dani-garcia dani-garcia force-pushed the ps/PM-9473-macos-passkey-desktop-messaging branch from 6262a59 to 6c50198 Compare December 6, 2024 16:37
@dani-garcia dani-garcia force-pushed the ps/PM-9473-add-uniffi-to-extension branch from d20ded9 to cb2f7c3 Compare December 6, 2024 18:07
@dani-garcia dani-garcia force-pushed the ps/PM-9473-macos-passkey-desktop-messaging branch from 6c50198 to 646c0bc Compare December 6, 2024 18:08
@dani-garcia dani-garcia force-pushed the ps/PM-9473-macos-passkey-desktop-messaging branch from 646c0bc to 52a6760 Compare December 9, 2024 10:29
@dani-garcia dani-garcia changed the base branch from ps/PM-9473-add-uniffi-to-extension to main December 9, 2024 10:29
@dani-garcia dani-garcia marked this pull request as ready for review December 9, 2024 12:38
@dani-garcia dani-garcia requested review from a team as code owners December 9, 2024 12:38
coroiu
coroiu previously approved these changes Dec 11, 2024
@coroiu coroiu requested review from coltonhurst and removed request for justindbaur December 11, 2024 12:20
Copy link
Member

@coltonhurst coltonhurst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dani-garcia @coroiu thanks for all the hard work on this! I am still very new to many concepts being introduced here 😅

Mostly looks good, just a couple of questions.

@coroiu coroiu requested review from coroiu and coltonhurst December 18, 2024 08:40
Copy link
Contributor

@coroiu coroiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving my own changes, good job Andreas!

@coroiu coroiu merged commit 51f6594 into main Dec 19, 2024
71 checks passed
@coroiu coroiu deleted the ps/PM-9473-macos-passkey-desktop-messaging branch December 19, 2024 08:00
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

Successfully merging this pull request may close these issues.

3 participants