Skip to content

[Brig] Move password verification to the AuthenticationSubsystem, move to Argon2id with new settings.#4271

Merged
elland merged 30 commits intodevelopfrom
wpb-9746/password
Oct 9, 2024
Merged

[Brig] Move password verification to the AuthenticationSubsystem, move to Argon2id with new settings.#4271
elland merged 30 commits intodevelopfrom
wpb-9746/password

Conversation

@elland
Copy link
Contributor

@elland elland commented Sep 26, 2024

https://wearezeta.atlassian.net/browse/WPB-9746

Checklist

  • Add a new entry in an appropriate subdirectory of changelog.d
  • Read and follow the PR guidelines

@echoes-hq echoes-hq bot added the echoes: technical-roadmap/security More specific category, to highlight task that tackle security requirements. label Sep 26, 2024
@zebot zebot added the ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist label Sep 26, 2024
@fisx fisx changed the title Move password verification to the AuthenticationSubsystem, move to Argon2id with default settings. [WPB-9746] Move password verification to the AuthenticationSubsystem, move to Argon2id with default settings. Sep 26, 2024
@elland elland changed the title [WPB-9746] Move password verification to the AuthenticationSubsystem, move to Argon2id with default settings. [Brig] Move password verification to the AuthenticationSubsystem, move to Argon2id with default settings. Sep 26, 2024
@elland elland force-pushed the wpb-9746/password branch 5 times, most recently from d87fbc1 to e4cb90f Compare October 2, 2024 12:45
Copy link
Contributor

@mdimjasevic mdimjasevic left a comment

Choose a reason for hiding this comment

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

Here is a partial review

Comment on lines 281 to 282
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
PasswordStore.lookupHashedProviderPassword pid
>>= maybe (throw AuthenticationSubsystemBadCredentials) pure
PasswordStore.lookupHashedProviderPassword pid >>= noteS @'AuthenticationSubsystemBadCredentials

Copy link
Contributor Author

Choose a reason for hiding this comment

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

noteS has a different type signature, forcing us the thread the specific error as a member of every function in the call chain 🤔 is that something we want here?

Copy link
Contributor

Choose a reason for hiding this comment

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

The call chain ain't long here. Note that this is in the interpreter, not the application code. I expect we call this interpreter only once.

Comment on lines 292 to 293
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

@mdimjasevic
Copy link
Contributor

Have you searched for all usages of mkSafePasswordScrypt and checked that's as expected?

Copy link
Contributor

@mdimjasevic mdimjasevic left a comment

Choose a reason for hiding this comment

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

Some more comments inlined.

Given that this is changing the default hashing algorithm, and we forgot to do it before in some places, what would be good tests to add to capture this change?

Copy link
Contributor

Choose a reason for hiding this comment

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

Don't we have an equivalent in the UserStore effect?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not yet.

@elland elland force-pushed the wpb-9746/password branch from da03847 to 5ced70d Compare October 3, 2024 13:23
@elland elland force-pushed the wpb-9746/password branch from db9b19b to c1efb01 Compare October 7, 2024 06:59
@elland elland force-pushed the wpb-9746/password branch from c1efb01 to 0cd22c4 Compare October 7, 2024 07:04
VerifyPasswordError :: Local UserId -> PlainTextPassword6 -> AuthenticationSubsystem m ()
CreatePasswordResetCode :: EmailKey -> AuthenticationSubsystem m ()
ResetPassword :: PasswordResetIdentity -> PasswordResetCode -> PlainTextPassword8 -> AuthenticationSubsystem m ()
VerifyPassword :: PlainTextPassword6 -> Password -> AuthenticationSubsystem m (Bool, PasswordStatus)
Copy link
Member

Choose a reason for hiding this comment

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

From perspective of the AuthenticationSubsystem API this looks weird, why does anyone else have access to the hashed password outside this subsystem?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would consider this a temporary problem. This is used in Brig.API.User, it should go away as we move more of that logic into subsystems.

@elland elland force-pushed the wpb-9746/password branch from 1cae602 to 14f80e9 Compare October 8, 2024 07:46
@elland elland changed the title [Brig] Move password verification to the AuthenticationSubsystem, move to Argon2id with default settings. [Brig] Move password verification to the AuthenticationSubsystem, move to Argon2id with new settings. Oct 8, 2024
@elland elland merged commit 1f13ef2 into develop Oct 9, 2024
@elland elland deleted the wpb-9746/password branch October 9, 2024 06:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

echoes: technical-roadmap/security More specific category, to highlight task that tackle security requirements. ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants